[][src]Struct cantact::Interface

pub struct Interface { /* fields omitted */ }

Interface for interacting with CANtact devices

Implementations

impl Interface[src]

pub fn new() -> Result<Interface, Error>[src]

Creates a new interface. This always selects the first device found by libusb. If no device is found, Error::DeviceNotFound is returned.

pub fn start(
    &mut self,
    rx_callback: impl FnMut(Frame) + Sync + Send + 'static
) -> Result<(), Error>
[src]

Start CAN communication on all configured channels.

After starting the device, Interface.send can be used to send frames. For every received frame, the rx_callback closure will be called.

pub fn stop(&mut self) -> Result<(), Error>[src]

Stop CAN communication on all channels.

pub fn set_bitrate(&mut self, channel: usize, bitrate: u32) -> Result<(), Error>[src]

Set bitrate for specified channel to requested bitrate value in bits per second.

pub fn set_monitor(
    &mut self,
    channel: usize,
    enabled: bool
) -> Result<(), Error>
[src]

Enable or disable a channel's listen only mode. When this mode is enabled, the device will not transmit any frames, errors, or acknowledgements.

pub fn set_enabled(
    &mut self,
    channel: usize,
    enabled: bool
) -> Result<(), Error>
[src]

Enable or disable a channel's listen only mode. When this mode is enabled, the device will not transmit any frames, errors, or acknowledgements.

pub fn set_loopback(
    &mut self,
    channel: usize,
    enabled: bool
) -> Result<(), Error>
[src]

Enable or disable a channel's loopback mode. When this mode is enabled, frames sent by the device will be received by the device as if they had been sent by another node on the bus.

This mode is primarily intended for device testing!

pub fn send(&mut self, f: Frame) -> Result<(), Error>[src]

Send a CAN frame using the device

pub fn channels(&self) -> usize[src]

Returns the number of channels this Interface has

Trait Implementations

impl Debug for Interface[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.