mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +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 += socket_zep_hello
|
||||||
PSEUDOMODULES += soft_uart_modecfg
|
PSEUDOMODULES += soft_uart_modecfg
|
||||||
PSEUDOMODULES += stdin
|
PSEUDOMODULES += stdin
|
||||||
|
PSEUDOMODULES += stdio_available
|
||||||
PSEUDOMODULES += stdio_cdc_acm
|
PSEUDOMODULES += stdio_cdc_acm
|
||||||
PSEUDOMODULES += stdio_ethos
|
PSEUDOMODULES += stdio_ethos
|
||||||
PSEUDOMODULES += stdio_uart_rx
|
PSEUDOMODULES += stdio_uart_rx
|
||||||
|
@ -53,6 +53,11 @@ config MODULE_STDIO_UART_RX
|
|||||||
help
|
help
|
||||||
Reception when using UART-based STDIO needs to be enabled.
|
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
|
config MODULE_PRINTF_FLOAT
|
||||||
bool "Float support in printf"
|
bool "Float support in printf"
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -34,6 +36,18 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
void stdio_init(void);
|
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
|
* @brief read @p len bytes from stdio uart into @p buffer
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user