RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

sys/stdio_uart: add pseudomodule stdio_flush_rx

Open HendrikVE opened this issue 2 years ago • 7 comments

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.

HendrikVE avatar Jul 19 '23 09:07 HendrikVE

bikeshedding: you'd "flush" output, "drain" input?

kaspar030 avatar Jul 19 '23 10:07 kaspar030

bikeshedding: you'd "flush" output, "drain" input?

I think I'd rather go with a simple "clear" then instead, maybe "stdio_clear_input"?

HendrikVE avatar Jul 19 '23 12:07 HendrikVE

Should we get this in for the release?

MrKevinWeiss avatar Oct 06 '23 07:10 MrKevinWeiss

Murdock results

:x: FAILED

8d4c2e9eece08a3ac386fa171312afebfcdd75a1 sys/stdio_uart: add pseudomodule stdio_flush_rx

Success Failures Total Runtime
152 0 7956 01m:37s

Artifacts

riot-ci avatar Nov 10 '23 18:11 riot-ci

Needs a rebase, you can move this to sys/stdio/stdio.c now.

benpicco avatar Apr 05 '24 12:04 benpicco

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

fabian18 avatar Apr 16 '24 14:04 fabian18

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

benpicco avatar Apr 16 '24 19:04 benpicco