Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not always set stdin to FNONBLOCK when PICO_PLATFORM=host #1334

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

czarnota
Copy link

@czarnota czarnota commented Mar 28, 2023

When I compile project with PICO_PLATFORM=host, then functions like scanf() and fgets() do not block anymore. They are blocking on the actual board, so I would expect them to also block when compiled with PICO_PLATFORM=host.
The solution I came up with is to only enable non-blocking input when _peekchar() is called.

@czarnota czarnota force-pushed the make-stdio-functions-blocking-in-platform-host branch from c30e392 to 1c807ae Compare March 28, 2023 16:52
Because the UART simulation was setting FNONBLOCK flag on stdin, all
stdio functions like scanf() or fgets() were non blocking.
The workaround is to use a non_blocking_getchar() function to do the UART
simulation, which will temporarily set stdin to non blocking.
This will make stdio functions blocking like they normally do.
@czarnota czarnota force-pushed the make-stdio-functions-blocking-in-platform-host branch from 1c807ae to d3cb972 Compare March 29, 2023 09:36
@kilograham kilograham added this to the 1.6.0 milestone May 25, 2023
@kilograham kilograham modified the milestones: 1.6.1, 1.6.0 May 19, 2024
@kilograham kilograham modified the milestones: 1.6.0, 1.7.0 Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants