pub struct SocketCan { /* private fields */ }
Implementations§
Source§impl SocketCan
impl SocketCan
pub fn new() -> Self
pub fn init_channel( &mut self, channel: &str, canfd: bool, ) -> Result<(), CanError>
pub fn read(&self, channel: &str) -> Result<CanMessage, CanError>
Sourcepub fn read_timeout(
&self,
channel: &str,
timeout: Duration,
) -> Result<CanMessage, CanError>
pub fn read_timeout( &self, channel: &str, timeout: Duration, ) -> Result<CanMessage, CanError>
Blocking read a single can frame with timeout.
pub fn write(&self, msg: CanMessage) -> Result<(), CanError>
Sourcepub fn write_timeout(
&self,
msg: CanMessage,
timeout: Duration,
) -> Result<(), CanError>
pub fn write_timeout( &self, msg: CanMessage, timeout: Duration, ) -> Result<(), CanError>
Blocking write a single can frame, retrying until it gets sent successfully.
Sourcepub fn set_nonblocking(
&self,
channel: &str,
nonblocking: bool,
) -> Result<(), CanError>
pub fn set_nonblocking( &self, channel: &str, nonblocking: bool, ) -> Result<(), CanError>
Change socket to non-blocking mode or back to blocking mode.
Source§impl SocketCan
impl SocketCan
Sourcepub fn set_filters(
&self,
channel: &str,
filters: &[CanFilter],
) -> Result<(), CanError>
pub fn set_filters( &self, channel: &str, filters: &[CanFilter], ) -> Result<(), CanError>
Sets CAN ID filters on the socket.
CAN packages received by SocketCAN are matched against these filters, only matching packets are returned by the interface.
See CanFilter
for details on how filtering works. By default, all
single filter matching all incoming frames is installed.
Sourcepub fn set_filter_drop_all(&self, channel: &str) -> Result<(), CanError>
pub fn set_filter_drop_all(&self, channel: &str) -> Result<(), CanError>
Disable reception of CAN frames.
Sets a completely empty filter; disabling all CAN frame reception.
Sourcepub fn set_filter_accept_all(&self, channel: &str) -> Result<(), CanError>
pub fn set_filter_accept_all(&self, channel: &str) -> Result<(), CanError>
Accept all frames, disabling any kind of filtering.
Replace the current filter with one containing a single rule that accepts all CAN frames.
Sourcepub fn set_error_filter(&self, channel: &str, mask: u32) -> Result<(), CanError>
pub fn set_error_filter(&self, channel: &str, mask: u32) -> Result<(), CanError>
Sets the error mask on the socket.
By default (ERR_MASK_NONE
) no error conditions are reported as
special error frames by the socket. Enabling error conditions by
setting ERR_MASK_ALL
or another non-empty error mask causes the
socket to receive notification about the specified conditions.
Sourcepub fn set_error_filter_drop_all(&self, channel: &str) -> Result<(), CanError>
pub fn set_error_filter_drop_all(&self, channel: &str) -> Result<(), CanError>
Sets the error mask on the socket to reject all errors.
Sourcepub fn set_error_filter_accept_all(&self, channel: &str) -> Result<(), CanError>
pub fn set_error_filter_accept_all(&self, channel: &str) -> Result<(), CanError>
Sets the error mask on the socket to accept all errors.
Sourcepub fn set_loopback(&self, channel: &str, enabled: bool) -> Result<(), CanError>
pub fn set_loopback(&self, channel: &str, enabled: bool) -> Result<(), CanError>
Enable or disable loopback.
By default, loopback is enabled, causing other applications that open the same CAN bus to see frames emitted by different applications on the same system.