Skip to content

UART PTY: Add exit wait on readers#14

Open
tannewt wants to merge 1 commit intoBabbleSim:mainfrom
tannewt:wait_uart_readers
Open

UART PTY: Add exit wait on readers#14
tannewt wants to merge 1 commit intoBabbleSim:mainfrom
tannewt:wait_uart_readers

Conversation

@tannewt
Copy link
Copy Markdown

@tannewt tannewt commented Feb 23, 2026

When set, --uartX_pty_wait_for_readers will wait for all available bytes to be read from the slave PTY before exiting. This prevents truncating the UART output.

Copy link
Copy Markdown
Contributor

@aescolar aescolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just like the other PR this one is also based very far behind in main. So it would need to be rebased.
Anyhow, could you elaborate on the problem this is trying to solve?

When set, --uartX_pty_wait_for_readers will wait for all available
bytes to be read from the slave PTY before exiting. This prevents
truncating the UART output.

Signed-off-by: Scott Shawcroft <scott@tannewt.org>
@tannewt
Copy link
Copy Markdown
Author

tannewt commented Feb 25, 2026

Just like the other PR this one is also based very far behind in main. So it would need to be rebased. Anyhow, could you elaborate on the problem this is trying to solve?

It's based on the version Zephyr 4.3.0 seems to be using. I've rebased it.

With the CircuitPython bsim tests we've got two serial output streams:

  1. stdout is the zephyr debug logging and printks.
  2. CircuitPython's serial console is done through a UART PTY. We use pyserial to connect to it.

To bound the time we need to run the tests, I added a flag to CircuitPython to exit the sim via posix_exit() once it has run code.py after a set number of times. This change is meant to ensure that pyserial reads all of the UART output before the process is exited and invalidates the PTY. Without it, the tests were quite flaky because they missed the last bit of output from the PTY. Using printks I could see all of the output queued. One test is actually still a little flaky for the same reason. I'm not sure why.

@aescolar
Copy link
Copy Markdown
Contributor

Thanks for the answer @tannewt , I will look at the issue and PR.
Not knowing about what your python connected code over serial does, but in general about how things like this are integrated, it may be more reliable from your integration point of view to have the python code that connects to it launch and kill the zephyr.exe executable when its done with it (or command it to terminate thru the same serial port).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants