-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix pyserial forcing nonblocking serial device on Linux and spurious null bytes #8
base: main
Are you sure you want to change the base?
Conversation
A bit more poking and I've narrowed down the problem to |
…tions and it doesn't seem to be broken there
Adding an update here from what was discussed in Slack:
A minimally reproducible example of the spurious nulls can be found here: https://git.ucsc.edu/ucsc-ectf-2023/serial-null-bytes. I'm seeing null characters from break conditions at the beginning and end of the "abcd" message sent by this example when testing with the bridge. |
Some further testing indicates that |
Enabling echo is causing failures in firmware loading. |
On Linux, pyserial forces
vmin
to 0 ifinter_byte_timeout
isNone
, which is the default behavior.When
vmin
is 0, reads to the device can return a minimum of 0 bytes, in other words they return immediately if no data is buffered.This breaks tools that assume reading from the serial device will block until data is found.
See this thread for more details.
In some cases, spurious null bytes are emitted due to break conditions being interpreted as nulls.
This is fixed by enabling
BRKINT
andNOFLSH
, which will prevent break conditions from being interpreted as null bytes.