sys/stdio_uart: add pseudomodule stdio_flush_rx
Contribution description
This PR introduces a new pseudomodule. It is currently only implemented for stdio_uart.
The use case is to clear the input buffer so we can throw away the remaining input (like \n for example) after a call of scanf for the next call of scanf.
Testing procedure
Have an application with multiple calls of scanf and use stdio_flush_rx at some places and don't use it on others.
bikeshedding: you'd "flush" output, "drain" input?
bikeshedding: you'd "flush" output, "drain" input?
I think I'd rather go with a simple "clear" then instead, maybe "stdio_clear_input"?
Should we get this in for the release?
Murdock results
:x: FAILED
8d4c2e9eece08a3ac386fa171312afebfcdd75a1 sys/stdio_uart: add pseudomodule stdio_flush_rx
| Success | Failures | Total | Runtime |
|---|---|---|---|
| 152 | 0 | 7956 | 01m:37s |
Artifacts
Needs a rebase, you can move this to sys/stdio/stdio.c now.
What about ethos? stdio.c is not being compiled when using stdio_ethos.
stdio.inc.mk
STDIO_LEGACY_MODULES = \
ethos_stdio \
stdio_ethos \
stdio_native # requires #19002 \
#
# select stdio_uart if no other stdio module is slected
ifeq (,$(filter $(STDIO_MODULES),$(USEMODULE)))
USEMODULE += stdio_uart
endif
ifeq (,$(filter $(STDIO_LEGACY_MODULES),$(USEMODULE)))
USEMODULE += stdio
endif
undefined reference to 'stdio_flush_rx' collect2: error: ld returned 1 exit status
True, ethos would need a custom implementation.
Alternatively it could be ported to the new interface which would require something like https://github.com/RIOT-OS/RIOT/pull/18066