Repository navigation
Switch to upload baud in place instead of reopening the port - #36
Merged
Merged
Conversation
The Nextion upload protocol (v1.1/v1.2) replies 0x05 at the upload baud within 500 ms of whmi-wri. Closing and reopening the serial port could miss that byte, and the reopen log line raised TypeError before any upload started. Keep the open transport, swap to the raw upload protocol, drain the whmi-wri command and change the baud rate in place. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 11, 2026
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.
Refs #19 (also covers the consolidated #26 report).
Problem
upload_firmwarecrashed before uploading anything:logger.info(f"... {upload_baud}" % (upload_baud))raisesTypeError: not all arguments converted during string formatting.whmi-wri, the client closed the serial port and reopened it at the upload baud. Per the official Upload Protocol v1.1 / v1.2, the device sends0x05within 500 ms and the host should change to baudrate, then wait_for_05. Close/reopen can miss that byte (the readiness timeout reported in Upgrade Failed for Nextion 10" Intelligent Series Display #19) and may toggle modem lines on USB adapters.Change
BasicProtocol, drain thewhmi-wricommand (serial.flush()), then setserial.baudratein place.Tests
test_upload_firmware_switches_baud_in_placedrives a full upload against a fake device transport: ready byte arrives right after the switch, two chunks (4096 + partial) are acked. Fails on master (TypeError), passes here.pytest: 65 passed. black/flake8 clean.Not verified
No physical Nextion hardware was available; the chunk-ACK timeout from #26 (Pi Zero
/dev/ttyS0) is not proven fixed. Keeping #19 open until someone confirms on a device.