Skip to content

Unable to set timer for socket.read() function #4

@rjsu26

Description

@rjsu26

I am trying to write a CAN based flashing script using rust where I can write and read some data. My problem here is that: I want to exit the system if say 5 seconds have elapsed without any response to the last request.
Referring to the discussion of issue #2 and following the SO links there, I modified our library code from from :

setsockopt(
                    sock_fd,
                    SOL_CAN_ISOTP,
                    CAN_ISOTP_OPTS,
                    isotp_options_ptr,
                    ISOTP_OPTIONS_SIZE.try_into().unwrap(),
                )

to :

let mut tv = timeval { tv_sec: 5, tv_usec: 0 };
setsockopt(
                    sock_fd, 
                    SOL_CAN_ISOTP, 
                    SO_RCVTIMEO,
                    &tv as *const _ as *const c_void ,
                    size_of::<timeval>().try_into().unwrap()
                )

My compilation succeeded but during runtime I am facing the issue : "Err(Io { source: Os { code: 92, kind: Uncategorized, message: "Protocol not available" } })".

I need to implement this feature. Please guide me on doing this.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions