[][src]Struct usbd_serial::CdcAcmClass

pub struct CdcAcmClass<'a, B: UsbBus> { /* fields omitted */ }

Packet level implementation of a CDC-ACM serial port.

This class can be used directly and it has the least overhead due to directly reading and writing USB packets with no intermediate buffers, but it will not act like a stream-like serial port. The following constraints must be followed if you use this class directly:

  • read_packet must be called with a buffer large enough to hold max_packet_size bytes, and the method will return a WouldBlock error if there is no packet to be read.
  • write_packet must not be called with a buffer larger than max_packet_size bytes, and the method will return a WouldBlock error if the previous packet has not been sent yet.
  • If you write a packet that is exactly max_packet_size bytes long, it won't be processed by the host operating system until a subsequent shorter packet is sent. A zero-length packet (ZLP) can be sent if there is no other data to send. This is because USB bulk transactions must be terminated with a short packet, even if the bulk endpoint is used for stream-like data.

Implementations

impl<B: UsbBus, '_> CdcAcmClass<'_, B>[src]

pub fn new(
    alloc: &UsbBusAllocator<B>,
    max_packet_size: u16
) -> CdcAcmClass<'_, B>
[src]

Creates a new CdcAcmClass with the provided UsbBus and max_packet_size in bytes. For full-speed devices, max_packet_size has to be one of 8, 16, 32 or 64.

pub fn max_packet_size(&self) -> u16[src]

Gets the maximum packet size in bytes.

pub fn line_coding(&self) -> &LineCoding[src]

Gets the current line coding. The line coding contains information that's mainly relevant for USB to UART serial port emulators, and can be ignored if not relevant.

pub fn dtr(&self) -> bool[src]

Gets the DTR (data terminal ready) state

pub fn rts(&self) -> bool[src]

Gets the RTS (request to send) state

pub fn write_packet(&mut self, data: &[u8]) -> Result<usize>[src]

Writes a single packet into the IN endpoint.

pub fn read_packet(&mut self, data: &mut [u8]) -> Result<usize>[src]

Reads a single packet from the OUT endpoint.

Trait Implementations

impl<B: UsbBus, '_> UsbClass<B> for CdcAcmClass<'_, B>[src]

Auto Trait Implementations

impl<'a, B> Send for CdcAcmClass<'a, B>

impl<'a, B> Sync for CdcAcmClass<'a, B>

impl<'a, B> Unpin for CdcAcmClass<'a, B>

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.