pub struct BlockingStdIo<'d, T> { /* private fields */ }
Expand description
A utility for setting up a buffered and blocking communication for the Rust stdio
subsystem.
By default, all communication via std::io:stdin
/ std::io::stdout
on the ESP-IDF is non-blocking.
One consequence of this, is that if the user wants to read from std::io::stdin
, she has to constantly
poll the driver, since the respective hardware FIFO buffers are relatively small-ish.
Also the user would have to handle WouldBlock
errors on every call, which is not very ergonomic.
Instantiating the BlockingStdIo
instructs the ESP-IDF VFS (Virtual File System) to use the
interrupt-driven drivers instead, as well as their blocking read / write functions.
Implementations§
Source§impl<'d, T> BlockingStdIo<'d, T>where
T: BorrowMut<UartDriver<'d>>,
impl<'d, T> BlockingStdIo<'d, T>where
T: BorrowMut<UartDriver<'d>>,
Source§impl<'d, T> BlockingStdIo<'d, T>where
T: BorrowMut<UsbSerialDriver<'d>>,
impl<'d, T> BlockingStdIo<'d, T>where
T: BorrowMut<UsbSerialDriver<'d>>,
Sourcepub fn usb_serial(driver: T) -> Result<Self, EspError>
pub fn usb_serial(driver: T) -> Result<Self, EspError>
Create a BlockingStdIo
instance for a USB-SERIAL driver
NOTE: By default, println!
and log!
output will be redirected to it in case
no UART connection is established to a Host PC. The peripheral is initialized at
startup and is using the ESP console slot 2 by default.
NOTE: ESP console slot 2 cannot be used to read from the HOST, only writing is supported. If reading from the HOST is necessary, reconfigure the ESP console by setting the following into your projects sdkconfig.default file:
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
Arguments:
driver
: The USB-SERIAL driver to use (i.e. aUsbSerialDriver
instance that can be mutably borrowed)