Feature Request: function call when there is input available on stdin #547

Closed
opened 2021-08-25 12:11:28 -05:00 by carlk3 · 2 comments
carlk3 commented 2021-08-25 12:11:28 -05:00 (Migrated from github.com)

I'm working with the FreeRTOS port, and finding it difficult to use standard input (stdin) from a terminal. Polling stdin with getchar_timeout_us() either stalls or burns up all the CPU cycles, which doesn't play well in a multitasking OS. I can see how to make a UART-connected terminal work in an interrupt-driven fashion in pico-examples/uart/uart_advanced. However, I would like to maintain the ability to change the destination for stdin and stdout using CMake directives, with input/output directed to UART or USB CDC.

How about an enhancement to Serial input and output on Raspberry Pi Pico that would make it possible to register a callback or something that could receive keystrokes from a terminal as they are typed, asynchronously, regardless of whether serial input (stdin) and output (stdout) are directed to either serial UART or to USB CDC (USB serial)?

I'm working with the FreeRTOS port, and finding it difficult to use standard input (stdin) from a terminal. Polling stdin with `getchar_timeout_us()` either stalls or burns up all the CPU cycles, which doesn't play well in a multitasking OS. I can see how to make a UART-connected terminal work in an interrupt-driven fashion in `pico-examples/uart/uart_advanced`. However, I would like to maintain the ability to change the destination for stdin and stdout using CMake directives, with input/output directed to UART or USB CDC. How about an enhancement to *Serial input and output on Raspberry Pi Pico* that would make it possible to register a callback or something that could receive keystrokes from a terminal as they are typed, asynchronously, regardless of whether serial input (stdin) and output (stdout) are directed to either serial UART or to USB CDC (USB serial)?
kilograham commented 2021-10-07 18:34:56 -05:00 (Migrated from github.com)

the stdio abstraction is a bit messy as is, so i don't want to pile on any more for 1.2.1 release - try to improve it in a future release when there is more time

the stdio abstraction is a bit messy as is, so i don't want to pile on any more for 1.2.1 release - try to improve it in a future release when there is more time
kilograham commented 2023-01-31 15:48:09 -06:00 (Migrated from github.com)

merged into develop

merged into develop
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#547
No description provided.