Simple standard input/output (STDIO) abstraction for RIOT. More...
Simple standard input/output (STDIO) abstraction for RIOT.
STDIO in RIOT is split into two parts: An interface to the stdio transports consisting mainly of stdio_read and stdio_write provided by RIOT, and the standard C stdio functions (such as printf(), puts(), scanf()) provided by the standard C library.
While the standard features for input and output are enabled by default, some additional features have to be enabled explicitly due to higher memory consumption. This includes the following features:
| Module | Features |
|---|---|
printf_float | Support for printing floats/doubles |
printf_long_long | Support for printing (unsigned) long long |
stdin | Support for input (default is output only) |
The additional features can be enabled in the application Makefile:
stdin is automatically used, as it is a dependency.The various transports supported by RIOT are enabled by selecting the corresponding modules, such as STDIO over UART, STDIO over CDC ACM (usbus), or STDIO over SEGGER RTT. All available options are shown as modules in the list below:
| Module | Description |
|---|---|
stdio_cdc_acm | USB CDC ACM STDIO, see STDIO over CDC ACM (usbus) |
stdio_ethos | Ethernet-over-serial STDIO (legacy, see ethos) |
stdio_fb | Framebuffer STDIO |
stdio_native | Native board STDIO, forwarded to the host terminal |
stdio_nimble | Bluetooth LE STDIO on top of NimBLE |
stdio_null | Discards all output, no input support |
stdio_rtt | Segger RTT STDIO, see STDIO over SEGGER RTT |
stdio_semihosting | ARM/RISC-V semihosting STDIO |
stdio_slipdev | SLIP STDIO |
stdio_telnet | Telnet STDIO |
stdio_tinyusb_cdc_acm | USB CDC ACM STDIO on top of the tinyUSB stack |
stdio_uart | UART STDIO, see STDIO over UART |
stdio_udp | UDP STDIO |
stdio_usb_serial_jtag | USB Serial/JTAG STDIO (e.g. on some ESP32 variants) |
As with the additional features, you can specify the STDIO backend to be used in your application Makefile:
stdio_dispatch is pulled in automatically. It forwards stdio_write() to every selected backend and merges the input of all of them into a single stream. A maximum of 9 backends can be selected at the same time.stdio_uart being selected as a fallback, so that a usable STDIO is always available. This happens in a two-stage dependency selection mechanism where first stdio_default is selected, and if no other backend is selected in the second round of dependency resolution, stdio_uart is selected as a fallback. Refer to makefiles/stdio.inc.mk for the details.The pseudomodule stdio_available exists to mark that the selected STDIO backend supports stdio_available, the function used to query how many bytes are currently buffered for reading.
Topics | |
| Default STDIO provider | |
| This module selects the default STDIO method of a given board. | |
| STDIO for native | |
| Standard input/output backend for native. | |
| STDIO null driver | |
| Dummy implementation of the stdio interface. | |
| STDIO over CDC ACM (usbus) | |
| Standard input/output backend using usbus CDC ACM. | |
| STDIO over ESP32 Debug Serial/JTAG | |
| STDIO via the USB Serial/JTAG debug interface found on some ESP32 SoCs. | |
| STDIO over NimBLE | |
| Standard input/output backend using NimBLE. | |
| STDIO over SEGGER RTT | |
| STDIO mapping for running the STDIO over SEGGER's RTT interface. | |
| STDIO over Semihosting | |
| Standard input/output backend using ARM Semihosting. | |
| STDIO over UART | |
| Standard input/output backend using UART. | |
| STDIO over UDP | |
| STDIO over UDP implementation. | |
| STDIO over USB CDC-ACM (tinyUSB) | |
| Standard input/output backend using tinyUSB CDC ACM. | |
| STDIO over telnet | |
| Standard input/output via telnet. | |
| STDIO via SLIP | |
| Standard input/output backend multiplexed via SLIP. | |
| STDIO via ethos | |
| Standard input/output backend multiplexed via ethernet-over-serial. | |
Files | |
| file | stdio_base.h |
Data Structures | |
| struct | stdio_provider_t |
| stdio provider struct More... | |
Macros | |
| #define | STDIO_RX_BUFSIZE (64) |
| Buffer size for STDIO. | |
| #define | STDIO_PROVIDER(_type, _open, _close, _write) |
| stdio implementation methods | |
Enumerations | |
| enum | { STDIO_NULL , STDIO_UART , STDIO_RTT , STDIO_SEMIHOSTING , STDIO_USBUS_CDC_ACM , STDIO_TINYUSB_CDC_ACM , STDIO_ESP32_SERIAL_JTAG , STDIO_NIMBLE , STDIO_UDP , STDIO_TELNET , STDIO_ETHOS , STDIO_SLIP } |
Functions | |
| void | stdio_init (void) |
| initialize the module | |
| int | stdio_available (void) |
| Get the number of bytes available for reading from stdio. | |
| void | stdio_clear_stdin (void) |
| Clear the input buffer. | |
| ssize_t | stdio_read (void *buffer, size_t max_len) |
Read len bytes from the STDIN into buffer. | |
| ssize_t | stdio_write (const void *buffer, size_t len) |
Write len bytes from buffer into STDOUT. | |
| void | stdio_close (void) |
| Disable stdio and detach stdio providers. | |
Variables | |
| isrpipe_t | stdin_isrpipe |
| isrpipe for writing stdin input to | |
| #define STDIO_PROVIDER | ( | _type, | |
| _open, | |||
| _close, | |||
| _write ) |
stdio implementation methods
| _type | stdio provider type, for identification |
| _open | attach / init function |
| _close | close / disable function |
| _write | write function |
Definition at line 155 of file stdio_base.h.
| #define STDIO_RX_BUFSIZE (64) |
Buffer size for STDIO.
Definition at line 38 of file stdio_base.h.
| anonymous enum |
Definition at line 41 of file stdio_base.h.
| int stdio_available | ( | void | ) |
Get the number of bytes available for reading from stdio.
stdio_available module is enabled.| void stdio_clear_stdin | ( | void | ) |
Clear the input buffer.
| ssize_t stdio_read | ( | void * | buffer, |
| size_t | max_len ) |
Read len bytes from the STDIN into buffer.
| [out] | buffer | buffer to read into |
| [in] | max_len | nr of bytes to read |
| <0 | on error |
| ssize_t stdio_write | ( | const void * | buffer, |
| size_t | len ) |
Write len bytes from buffer into STDOUT.
| [in] | buffer | buffer to read from |
| [in] | len | nr of bytes to write |
| <0 | on error |