[][src]Struct usbd_serial::SerialPort

pub struct SerialPort<'a, B, RS = DefaultBufferStore, WS = DefaultBufferStore> where
    B: UsbBus,
    RS: BorrowMut<[u8]>,
    WS: BorrowMut<[u8]>, 
{ /* fields omitted */ }

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.

Implementations

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

pub fn new(
    alloc: &UsbBusAllocator<B>
) -> SerialPort<'_, B, DefaultBufferStore, DefaultBufferStore>
[src]

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]

pub fn new_with_store(
    alloc: &UsbBusAllocator<B>,
    read_store: RS,
    write_store: WS
) -> SerialPort<'_, B, RS, WS>
[src]

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 (request 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

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, '_> Read<u8> for SerialPort<'_, B, RS, WS> where
    B: UsbBus,
    RS: BorrowMut<[u8]>,
    WS: BorrowMut<[u8]>, 
[src]

type Error = UsbError

Read error

impl<B, RS, WS, '_> UsbClass<B> for SerialPort<'_, B, RS, WS> where
    B: UsbBus,
    RS: BorrowMut<[u8]>,
    WS: BorrowMut<[u8]>, 
[src]

impl<B, RS, WS, '_> Write<u8> for SerialPort<'_, B, RS, WS> where
    B: UsbBus,
    RS: BorrowMut<[u8]>,
    WS: BorrowMut<[u8]>, 
[src]

type Error = UsbError

Write error

Auto Trait Implementations

impl<'a, B, RS, WS> Send for SerialPort<'a, B, RS, WS> where
    RS: Send,
    WS: Send

impl<'a, B, RS, WS> Sync for SerialPort<'a, B, RS, WS> where
    RS: Sync,
    WS: Sync

impl<'a, B, RS, WS> Unpin for SerialPort<'a, B, RS, WS> where
    RS: Unpin,
    WS: Unpin

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.