[−][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.
Implementations
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 (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
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, '_> 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]>,
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_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]
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]>,
Auto Trait Implementations
impl<'a, B, RS, WS> Send for SerialPort<'a, B, RS, WS> where
RS: Send,
WS: Send,
RS: Send,
WS: Send,
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> Unpin for SerialPort<'a, B, RS, WS> where
RS: Unpin,
WS: Unpin,
RS: Unpin,
WS: Unpin,
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>,