[−][src]Struct usbd_serial::CdcAcmClass
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 aWouldBlock
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 aWouldBlock
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]
alloc: &UsbBusAllocator<B>,
max_packet_size: u16
) -> CdcAcmClass<'_, B>
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]
fn get_configuration_descriptors(
&self,
writer: &mut DescriptorWriter<'_>
) -> Result<()>
[src]
&self,
writer: &mut DescriptorWriter<'_>
) -> Result<()>
fn reset(&mut self)
[src]
fn control_in(&mut self, xfer: ControlIn<'_, '_, '_, B>)
[src]
fn control_out(&mut self, xfer: ControlOut<'_, '_, '_, B>)
[src]
fn get_bos_descriptors(
&self,
writer: &mut BosWriter<'_, '_>
) -> Result<(), UsbError>
[src]
&self,
writer: &mut BosWriter<'_, '_>
) -> Result<(), UsbError>
fn get_string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
[src]
fn poll(&mut self)
[src]
fn endpoint_setup(&mut self, addr: EndpointAddress)
[src]
fn endpoint_out(&mut self, addr: EndpointAddress)
[src]
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,