pub struct CdcAcm<'a, B: UsbBus> { /* private fields */ }Expand description
CDC ACM virtual serial port class.
Construct with CdcAcm::new, passing the UsbBusAllocator.
Implementations§
Source§impl<'a, B: UsbBus> CdcAcm<'a, B>
impl<'a, B: UsbBus> CdcAcm<'a, B>
Sourcepub fn new(alloc: &'a UsbBusAllocator<B>) -> Self
pub fn new(alloc: &'a UsbBusAllocator<B>) -> Self
Create a CDC ACM instance, allocating the required endpoints and interfaces.
Bulk endpoints use the bus’s UsbBus::MAX_PACKET_SIZE (64 bytes on
full-speed buses, 512 on high-speed ones).
Sourcepub fn read(&self, buf: &mut [u8]) -> UsbResult<usize>
pub fn read(&self, buf: &mut [u8]) -> UsbResult<usize>
Read received bytes from the host into buf.
Returns the number of bytes read, or UsbError::WouldBlock when no
data is available.
Sourcepub fn write(&self, data: &[u8]) -> UsbResult<usize>
pub fn write(&self, data: &[u8]) -> UsbResult<usize>
Write bytes to the host.
Returns the number of bytes actually written, or UsbError::WouldBlock
when the previous packet has not yet been sent.
Sourcepub fn write_all(&self, data: &[u8], budget: u32) -> usize
pub fn write_all(&self, data: &[u8], budget: u32) -> usize
Queue data, splitting it into endpoint-sized packets.
While the endpoint is busy the call spins, spending one unit of budget
per attempt; the budget bounds the time spent waiting for a host that is
not collecting. Returns the number of bytes queued.
Sourcepub fn communication_interface(&self) -> InterfaceNumber
pub fn communication_interface(&self) -> InterfaceNumber
The communication interface number.
Sourcepub fn data_interface(&self) -> InterfaceNumber
pub fn data_interface(&self) -> InterfaceNumber
The data interface number.
Sourcepub fn port_open(&self) -> bool
pub fn port_open(&self) -> bool
true if the device is configured and the host has opened the serial port.
Sourcepub fn configured(&self) -> bool
pub fn configured(&self) -> bool
true if the device has been configured by the host.
Sourcepub fn line_coding(&self) -> LineCoding
pub fn line_coding(&self) -> LineCoding
Returns the current line coding (baud rate, data bits, etc.).
Trait Implementations§
Source§impl<B: UsbBus> UsbClass<B> for CdcAcm<'_, B>
impl<B: UsbBus> UsbClass<B> for CdcAcm<'_, B>
Source§fn configuration_descriptors(
&self,
w: &mut DescriptorWriter<'_>,
) -> UsbResult<()>
fn configuration_descriptors( &self, w: &mut DescriptorWriter<'_>, ) -> UsbResult<()>
Source§fn control_in(&mut self, xfer: ControlIn<'_, B>)
fn control_in(&mut self, xfer: ControlIn<'_, B>)
Source§fn control_out(&mut self, xfer: ControlOut<'_, B>)
fn control_out(&mut self, xfer: ControlOut<'_, B>)
Source§fn deconfigure(&mut self)
fn deconfigure(&mut self)
Source§fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
StringIndex, or None.Source§fn endpoint_out(&mut self, addr: EndpointAddress)
fn endpoint_out(&mut self, addr: EndpointAddress)
addr received an OUT packet.Source§fn endpoint_in_complete(&mut self, addr: EndpointAddress)
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
addr completed an IN transfer.Source§fn endpoint_setup(&mut self, addr: EndpointAddress)
fn endpoint_setup(&mut self, addr: EndpointAddress)
addr received a SETUP packet (non-EP0 control).Source§fn poll(&mut self)
fn poll(&mut self)
UsbDevice::poll.Source§fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
interface, or None.Source§fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool
fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool
interface. Return true if handled.