mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/stdio_base: add optional function stdio_available
A couple of `stdio` backend implementations allow to check for the number of available bytes for reading before the blocking `stdio_read` is called. This helps to implement non-blocking functionalities while waiting for `stdin`.
This commit is contained in:
parent
39b159e83b
commit
a71dec81a2
@ -152,6 +152,7 @@ PSEUDOMODULES += sock_udp
|
||||
PSEUDOMODULES += socket_zep_hello
|
||||
PSEUDOMODULES += soft_uart_modecfg
|
||||
PSEUDOMODULES += stdin
|
||||
PSEUDOMODULES += stdio_available
|
||||
PSEUDOMODULES += stdio_cdc_acm
|
||||
PSEUDOMODULES += stdio_ethos
|
||||
PSEUDOMODULES += stdio_uart_rx
|
||||
|
@ -53,6 +53,11 @@ config MODULE_STDIO_UART_RX
|
||||
help
|
||||
Reception when using UART-based STDIO needs to be enabled.
|
||||
|
||||
config MODULE_STDIO_AVAILABLE
|
||||
bool
|
||||
help
|
||||
Indicates that the implementation supports function stdio_available
|
||||
|
||||
config MODULE_PRINTF_FLOAT
|
||||
bool "Float support in printf"
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -34,6 +36,18 @@ extern "C" {
|
||||
*/
|
||||
void stdio_init(void);
|
||||
|
||||
#if IS_USED(MODULE_STDIO_AVAILABLE) || DOXYGEN
|
||||
/**
|
||||
* @brief Get the number of bytes available for reading from stdio.
|
||||
*
|
||||
* @warning This function is only available if the implementation supports
|
||||
* it and the @c stdio_available module is enabled.
|
||||
*
|
||||
* @return number of available bytes
|
||||
*/
|
||||
int stdio_available(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief read @p len bytes from stdio uart into @p buffer
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user