Struct socketcan::CANSocket [] [src]

pub struct CANSocket {
    // some fields omitted
}

A socket for a CAN device.

Will be closed upon deallocation. To close manually, use std::drop::Drop. Internally this is just a wrapped file-descriptor.

Methods

impl CANSocket
[src]

fn open(ifname: &str) -> Result<CANSocketCANSocketOpenError>

Open a named CAN device.

Usually the more common case, opens a socket can device by name, such as "vcan0" or "socan0".

fn open_if(if_index: c_uint) -> Result<CANSocketCANSocketOpenError>

Open CAN device by interface number.

Opens a CAN device by kernel interface number.

fn set_read_timeout(&self, duration: Duration) -> Result<()>

Sets the read timeout on the socket

For convenience, the result value can be checked using ShouldRetry::should_retry when a timeout is set.

fn set_write_timeout(&self, duration: Duration) -> Result<()>

Sets the write timeout on the socket

fn read_frame(&self) -> Result<CANFrame>

Blocking read a single can frame.

fn write_frame(&self, frame: &CANFrame) -> Result<()>

Blocking write a single can frame.

Trait Implementations

impl Drop for CANSocket
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more