Struct framed_serial::SerialWrap
[−]
[src]
pub struct SerialWrap<T> where
T: SerialPort, { /* fields omitted */ }
Implment the traits required for a FramedConnection
based
on a serial::SerialPort
.
Note that the async processing of FramedConnection
depends on
a short timeout being set. At the time of writing, serial::open()
returned
a SerialPort with a default of 100 msec.
Methods
impl<T> SerialWrap<T> where
T: SerialPort,
[src]
T: SerialPort,
fn new(port: T) -> SerialWrap<T>
Constructor
Trait Implementations
impl<T> NonBlockingRx for SerialWrap<T> where
T: SerialPort,
[src]
T: SerialPort,
type Error = Error
The error type returned if getc
fails.
fn getc_try(&mut self) -> Result<Option<u8>, Self::Error>
Attempt to read a single octet from the port's receiver; if the buffer is empty return None. Read more
fn gets_try<I>(&mut self, buffer: &mut I) -> Result<usize, (usize, Self::Error)> where
I: AsMut<[u8]> + ?Sized,
I: AsMut<[u8]> + ?Sized,
Read a specified number of octets into the given buffer, or until the data runs out. Read more
impl<T> NonBlockingTx for SerialWrap<T> where
T: SerialPort,
[src]
T: SerialPort,
type Error = Error
The error type returned if function fails.
fn putc_try(&mut self, ch: u8) -> Result<Option<u8>, Self::Error>
Try and write a single octet to the port's transmitter.
Will return Ok(None)
if the FIFO/buffer was full
and the octet couldn't be stored or Ok(Some(ch))
if it was stored OK.
In some implementations, this can result in an Error.
If not, use type Error = !
.
fn puts_try<I>(&mut self, data: &I) -> Result<usize, (usize, Self::Error)> where
I: AsRef<[u8]> + ?Sized,
I: AsRef<[u8]> + ?Sized,
Write as much of a complete string to the UART as possible. Returns the number of octets sent, plus the result from the last putc
call. Aborts early if putc
fails in any way. Read more