You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
intkey=getchar_timeout_us(0); // get any pending key press but don't wait
For stdio_usb, the callback registered with stdio_set_chars_available_callback() is called with the stdio_usb_mutex locked. This means that such callbacks can't call any other stdio functions (they attempt to claim the mutex and fail). In particular, this means you can't call getchar_timeout_ms() inside the callback.
This actually rather a dire limitation on the stdio callback mechanism, but that's how it is at the moment, and it means this piece of code in pico-examples doesn't work.
Fortunately, in this case the resolution is easy because it's already using async context: the stdio callback needs to do async_context_set_work_pending() unconditionally, and then key_pressed_worker_func() can read the key value and act on it accordingly.
The text was updated successfully, but these errors were encountered:
(but I've just noticed you've closed 1603 which was "there's a bug", but left open 461 which is "must provide an example for this feature" where the commentary says that actually it's a bug!).
pico-examples/pico_w/wifi/iperf/picow_iperf.c
Line 50 in eca13ac
For stdio_usb, the callback registered with stdio_set_chars_available_callback() is called with the stdio_usb_mutex locked. This means that such callbacks can't call any other stdio functions (they attempt to claim the mutex and fail). In particular, this means you can't call getchar_timeout_ms() inside the callback.
This actually rather a dire limitation on the stdio callback mechanism, but that's how it is at the moment, and it means this piece of code in pico-examples doesn't work.
Fortunately, in this case the resolution is easy because it's already using async context: the stdio callback needs to do async_context_set_work_pending() unconditionally, and then key_pressed_worker_func() can read the key value and act on it accordingly.
The text was updated successfully, but these errors were encountered: