pub struct CdcSerial { /* private fields */ }
Expand description
This is currently a thin wrapper of USB operations, it requires hardware buffers at the device side. It uses the CDC ACM Data Interface Class to transfer data (the Communication Interface Class is used for probing and serial configuration).
Reference: USB Class Definitions for Communication Devices, Version 1.1, especially section 3.6.2.1, 5.2.3.2 and 6.2(.13).
Implementations§
Source§impl CdcSerial
impl CdcSerial
Sourcepub fn probe() -> Result<Vec<DeviceInfo>>
pub fn probe() -> Result<Vec<DeviceInfo>>
Probes for CDC-ACM devices. It checks the current configuration of each device. Returns an empty vector if no device is found.
Sourcepub fn build(dev_info: &DeviceInfo, timeout: Duration) -> Result<Self>
pub fn build(dev_info: &DeviceInfo, timeout: Duration) -> Result<Self>
Connects to the CDC-ACM device, returns the CdcSerial
handler.
Please get permission for the device before calling this function.
timeout
: Set for standardRead
andWrite
traits.
Sourcepub fn set_config(&mut self, conf: SerialConfig) -> Result<()>
pub fn set_config(&mut self, conf: SerialConfig) -> Result<()>
Applies serial parameters.
Trait Implementations§
Source§impl Read for CdcSerial
impl Read for CdcSerial
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moreSource§impl SerialPort for CdcSerial
impl SerialPort for CdcSerial
Source§fn set_timeout(&mut self, timeout: Duration) -> Result<()>
fn set_timeout(&mut self, timeout: Duration) -> Result<()>
Sets timeout for standard Read
and Write
implementations to do USB bulk transfers.
Source§fn read_clear_to_send(&mut self) -> Result<bool>
fn read_clear_to_send(&mut self) -> Result<bool>
Unsupported.
Source§fn read_data_set_ready(&mut self) -> Result<bool>
fn read_data_set_ready(&mut self) -> Result<bool>
Unsupported.
Source§fn read_ring_indicator(&mut self) -> Result<bool>
fn read_ring_indicator(&mut self) -> Result<bool>
Unsupported.
Source§fn read_carrier_detect(&mut self) -> Result<bool>
fn read_carrier_detect(&mut self) -> Result<bool>
Unsupported.
Source§fn bytes_to_read(&self) -> Result<u32>
fn bytes_to_read(&self) -> Result<u32>
Returns 0 because no buffer is maintained here, and all operations are synchronous.
Source§fn bytes_to_write(&self) -> Result<u32>
fn bytes_to_write(&self) -> Result<u32>
Returns 0 because no buffer is maintained here, and all operations are synchronous.
Source§fn flow_control(&self) -> Result<FlowControl>
fn flow_control(&self) -> Result<FlowControl>
Source§fn set_flow_control(&mut self, _flow_control: FlowControl) -> Result<()>
fn set_flow_control(&mut self, _flow_control: FlowControl) -> Result<()>
Source§fn write_request_to_send(&mut self, value: bool) -> Result<()>
fn write_request_to_send(&mut self, value: bool) -> Result<()>
Source§fn write_data_terminal_ready(&mut self, value: bool) -> Result<()>
fn write_data_terminal_ready(&mut self, value: bool) -> Result<()>
Source§fn clear_break(&self) -> Result<()>
fn clear_break(&self) -> Result<()>
Source§impl UsbSerial for CdcSerial
impl UsbSerial for CdcSerial
Source§fn configure(&mut self, conf: &SerialConfig) -> Result<()>
fn configure(&mut self, conf: &SerialConfig) -> Result<()>
Source§fn into_queues(self) -> (Queue<RequestBuffer>, Queue<Vec<u8>>)
fn into_queues(self) -> (Queue<RequestBuffer>, Queue<Vec<u8>>)
nusb
transfer queues of the read endpoint and the write endpoint.
This can be called after serial configuration to do asynchronous operations.Source§impl Write for CdcSerial
impl Write for CdcSerial
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)