pub struct FdCanUSB<T>{ /* private fields */ }Expand description
FdCanUSB communications struct
Can be used with any transport type that implements std::io::Write and std::io::Read
The baud rate is unused, as the FdCanUSB communicates via USB CDC
§Example
use fdcanusb::{FdCanUSB, serial2};
let transport = serial2::SerialPort::open("/dev/fdcanusb", serial2::KeepSettings)?;
let mut fdcanusb = FdCanUSB::new(transport);§serial2 Integration
To use the FdCanUSB with a serial2::SerialPort, you can use the FdCanUSB::open method.
§Example
use fdcanusb::FdCanUSB;
let mut fdcanusb = FdCanUSB::open("/dev/fdcanusb", serial2::KeepSettings).expect("Failed to open serial port");Implementations§
source§impl FdCanUSB<SerialPort>
impl FdCanUSB<SerialPort>
source§impl<T> FdCanUSB<T>
impl<T> FdCanUSB<T>
sourcepub fn transfer_single(
&mut self,
frame: CanFdFrame,
response: bool,
) -> Result<Option<CanFdFrame>>
pub fn transfer_single( &mut self, frame: CanFdFrame, response: bool, ) -> Result<Option<CanFdFrame>>
Transfer a single frame.
If response is true, the function will wait for a response frame.
Otherwise, it will return None.
sourcepub fn write_frame(&mut self, frame: FdCanUSBFrame) -> Result<()>
pub fn write_frame(&mut self, frame: FdCanUSBFrame) -> Result<()>
Write a frame to the FdCanUSB
Frames are logged at the trace level by default.
sourcepub fn read_ok(&mut self) -> Result<()>
pub fn read_ok(&mut self) -> Result<()>
The FdCanUSB responds with OK after a correct frame is parsed.
read_ok waits for this response, and returns an error if it is not received.
sourcepub fn read_response(&mut self) -> Result<CanFdFrame>
pub fn read_response(&mut self) -> Result<CanFdFrame>
Read a response frame from the FdCanUSB.
Responses are logged at the trace level by default.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for FdCanUSB<T>where
T: Freeze,
impl<T> RefUnwindSafe for FdCanUSB<T>where
T: RefUnwindSafe,
impl<T> Send for FdCanUSB<T>where
T: Send,
impl<T> Sync for FdCanUSB<T>where
T: Sync,
impl<T> Unpin for FdCanUSB<T>where
T: Unpin,
impl<T> UnwindSafe for FdCanUSB<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more