[−][src]Struct usbd_serial::SerialPort
USB (CDC-ACM) serial port with built-in buffering to implement stream-like behavior.
The RS and WS type arguments specify the storage for the read/write buffers, respectively. By default an internal 128 byte buffer is used for both directions.
Methods
impl<'_, B> SerialPort<'_, B> where
B: UsbBus,
[src]
B: UsbBus,
pub fn new(
alloc: &UsbBusAllocator<B>
) -> SerialPort<B, DefaultBufferStore, DefaultBufferStore>
[src]
alloc: &UsbBusAllocator<B>
) -> SerialPort<B, DefaultBufferStore, DefaultBufferStore>
Creates a new USB serial port with the provided UsbBus and 128 byte read/write buffers.
impl<'_, B, RS, WS> SerialPort<'_, B, RS, WS> where
B: UsbBus,
RS: BorrowMut<[u8]>,
WS: BorrowMut<[u8]>,
[src]
B: UsbBus,
RS: BorrowMut<[u8]>,
WS: BorrowMut<[u8]>,
pub fn new_with_store(
alloc: &UsbBusAllocator<B>,
read_store: RS,
write_store: WS
) -> SerialPort<B, RS, WS>
[src]
alloc: &UsbBusAllocator<B>,
read_store: RS,
write_store: WS
) -> SerialPort<B, RS, WS>
Creates a new USB serial port with the provided UsbBus and buffer backing stores.
pub fn line_coding(&self) -> &LineCoding
[src]
Gets the current line coding.
pub fn dtr(&self) -> bool
[src]
Gets the DTR (data terminal ready) state
pub fn rts(&self) -> bool
[src]
Gets the RTS (ready to send) state
pub fn write(&mut self, data: &[u8]) -> Result<usize>
[src]
Writes bytes from data
into the port and returns the number of bytes written.
Errors
WouldBlock
- No bytes could be written because the buffers are full.
Other errors from usb-device
may also be propagated.
pub fn read(&mut self, data: &mut [u8]) -> Result<usize>
[src]
Reads bytes from the port into data
and returns the number of bytes read.
Errors
WouldBlock
- No bytes available for reading.
Other errors from usb-device
may also be propagated.
pub fn flush(&mut self) -> Result<()>
[src]
Sends as much as possible of the current write buffer. Returns Ok
if all data that has
been written has been completely written to hardware buffers Err(WouldBlock)
if there is
still data remaining, and other errors if there's an error sending data to the host. Note
that even if this method returns Ok
, data may still be in hardware buffers on either side.
Trait Implementations
impl<'_, B, RS, WS> UsbClass<B> for SerialPort<'_, B, RS, WS> where
B: UsbBus,
RS: BorrowMut<[u8]>,
WS: BorrowMut<[u8]>,
[src]
B: UsbBus,
RS: BorrowMut<[u8]>,
WS: BorrowMut<[u8]>,
fn get_configuration_descriptors(
&self,
writer: &mut DescriptorWriter
) -> Result<()>
[src]
&self,
writer: &mut DescriptorWriter
) -> Result<()>
fn reset(&mut self)
[src]
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
[src]
fn control_in(&mut self, xfer: ControlIn<B>)
[src]
fn control_out(&mut self, xfer: ControlOut<B>)
[src]
fn get_string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
[src]
Gets a class-specific string descriptor. Read more
fn poll(&mut self)
[src]
Called whenever the UsbDevice
is polled.
fn endpoint_setup(&mut self, addr: EndpointAddress)
[src]
Called when endpoint with address addr
has received a SETUP packet. Implementing this shouldn't be necessary in most cases, but is provided for completeness' sake. Read more
fn endpoint_out(&mut self, addr: EndpointAddress)
[src]
Called when endpoint with address addr
has received data (OUT packet). Read more
impl<'_, B, RS, WS> Write<u8> for SerialPort<'_, B, RS, WS> where
B: UsbBus,
RS: BorrowMut<[u8]>,
WS: BorrowMut<[u8]>,
[src]
B: UsbBus,
RS: BorrowMut<[u8]>,
WS: BorrowMut<[u8]>,
type Error = UsbError
Write error
fn write(&mut self, word: u8) -> Result<(), Self::Error>
[src]
fn flush(&mut self) -> Result<(), Self::Error>
[src]
impl<'_, B, RS, WS> Read<u8> for SerialPort<'_, B, RS, WS> where
B: UsbBus,
RS: BorrowMut<[u8]>,
WS: BorrowMut<[u8]>,
[src]
B: UsbBus,
RS: BorrowMut<[u8]>,
WS: BorrowMut<[u8]>,
Auto Trait Implementations
impl<'a, B, RS, WS> Unpin for SerialPort<'a, B, RS, WS> where
RS: Unpin,
WS: Unpin,
RS: Unpin,
WS: Unpin,
impl<'a, B, RS, WS> Sync for SerialPort<'a, B, RS, WS> where
RS: Sync,
WS: Sync,
RS: Sync,
WS: Sync,
impl<'a, B, RS, WS> Send for SerialPort<'a, B, RS, WS> where
RS: Send,
WS: Send,
RS: Send,
WS: Send,
Blanket Implementations
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> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,