Repository navigation
Fix UART and USB serial timeout values reading back wrong on Zephyr boards - #11585
Merged
Merged
Conversation
The timeout getters divided kernel ticks by 1e6 as if they were microseconds, so usb_cdc write_timeout = 0.5 read back as 0.015625 on a 32768 Hz tick. Convert ticks to microseconds first, and report K_FOREVER as -1 so usb_cdc shows None. Setting usb_cdc timeout or write_timeout to None passed -1 to K_USEC(), which came out as zero. Store K_FOREVER instead, the value both start with. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
tannewt
requested changes
Oct 13, 2026
tannewt
left a comment
Member
There was a problem hiding this comment.
Code looks fine. Please add a native sim test that tests this.
native_sim ticks at 100 Hz, so before the fix timeout = 0.5 read back as 5e-05. The test sets 0.5, 2 and 0 on board.UART0() and checks each reads back in seconds. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Added
The test fails on main and passes here. Also rechecked on a Feather nRF52840 (Zephyr): main reads 0.5 as 0.016384 and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
timeoutandwrite_timeoutnow read back in seconds, andNonestaysNone.Why
On Zephyr boards, 0.5 read back as 0.015625, and setting
Noneturned into 0.Tests
nRF54LM20 DK,
usb_cdcdata enabled inboot.py.usb_cdc.data.write_timeoutusb_cdc.data.write_timeoutusb_cdc.data.write_timeoutusb_cdc.data.timeoutusb_cdc.data.timeoutbusio.UART(..., timeout=0.25).timeoutbusio.UART.timeoutWrites on Zephyr still ignore
write_timeout; this only fixes the values.Pico W and SiWx917-DK2605A are build-tested only.
Written with Claude; tested on hardware by me.
🤖 Generated with Claude Code