Standard input/output backend using UART. More...
Standard input/output backend using UART.
To enable stdio over UART, enable the stdio_uart
module:
USEMODULE += stdio_uart
stdio_uart
is already the default stdio backend and therefore already enabled.stdin
module in your application: make BOARD=<your_board> term
will launch pyterm
with the correct parameters, so mostly you do not really need to care about the UART configuration.By convention RIOT boards used 8N1 encoding with a symbol rate of 115200 Bd for the UART used as stdio. However, some boards may have a different configuration due to hardware limitations. Most notably, many AVR boards use 9600 Bd as symbol rate instead, as they otherwise frequently loose an input character due to losing interrupts.
By default UNIX style line endings (\n
) are used. However, some terminal programs default to DOS style line endings (\r\n
). It usually is better to configure the terminal program on the host to use UNIX style line endings. In scenarios this is not possible/desired, you can enable the (pseudo-) module Support for DOS line endings in STDIO-UART to emit DOS style line endings instead.
RIOT's shell happily accepts both DOS and UNIX style line endings in any case, so typically no line ending conversion is needed on the input.
For testing purposes and using STDIO within an ISR should mostly work good enough and for some platforms even reliable. Production code however should fully avoid any access to STDIO from interrupt context. Instead, e.g. an event could be posted to an Event Queue and the actual STDIO operation being deferred to thread context.
Some reasons why STDIO over UART from ISR should be avoided:
Modules | |
Support for DOS line endings in STDIO-UART | |
Enable this (pseudo-) module to emit DOS style line endings (\r\n ) instead of UNIX style line endings (\n ) via STDIO over UART. | |
Files | |
file | stdio_uart.h |
Macros | |
#define | STDIO_UART_DEV UART_DEV(0) |
UART device to use for STDIO. | |
#define | STDIO_UART_BAUDRATE (115200) |
Baudrate for STDIO. | |
#define STDIO_UART_BAUDRATE (115200) |
Baudrate for STDIO.
Definition at line 111 of file stdio_uart.h.
#define STDIO_UART_DEV UART_DEV(0) |
UART device to use for STDIO.
Definition at line 104 of file stdio_uart.h.