Repository navigation
Add a USB/BLE hardware check tool for hand controllers (bench Layer 1) - #133
Open
PaulDWhite wants to merge 4 commits into
Open
PaulDWhite wants to merge 4 commits into
PaulDWhite wants to merge 4 commits into
Conversation
tools/hw_check runs the release-checklist items the firmware already reports: firmware version, settings write/sanitize/persist/restore, reset reason and crash history, boot log, first-boot QC record, Fast-Link sensor/ESC/BMS telemetry, and OTA readiness. --dry-run runs every check against a simulated controller, and the unit tests fail if the tool's protocol description drifts from the firmware sources. CI runs both. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0131SpAAHXzdS5D8UQaHfNrC
pyserial's socket:// open() flushes input that already arrived, so on a slow CI runner the fake's boot log was discarded on reconnect. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0131SpAAHXzdS5D8UQaHfNrC
…lies On a real 8.1 unit most sync replies arrived with bytes missing: send_device_data() streamed serializeJson straight into USBSerial, so a short write dropped bytes and other tasks' log lines landed mid-reply. Serialize to a buffer and write the whole line, retrying short writes like diagnosticsSendJson does. hw_check now reports a damaged reply as garbled (with the raw line) instead of 'no reply', rejects sync replies with missing keys, and reads the settings back before saying a restore failed. The simulated controller gains a garbled-sync fault. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0131SpAAHXzdS5D8UQaHfNrC
On real hardware the first diag_sync after opening the port came back 32 bytes short; waiting 0.5 s after open avoided it in testing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0131SpAAHXzdS5D8UQaHfNrC
This branch has not been deployed
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.
Requested by paul · project thread
Before: you checked a hand controller against the 8.1 hardware checklist by hand, using the app and the serial monitor. On a real 8.1 unit, most replies to the USB
synccommand also arrived with bytes missing, which breaks the web config tool too.After:
python tools/hw_check/hw_check.pychecks a unit plugged in over USB and prints PASS/FAIL per item. Add--bleto include checks over the computer's Bluetooth. It covers:--dry-runruns every check against a simulated controller, with--faultto inject failures, and needs no hardware. Thesyncreply is now sent intact.The tool only reads what the firmware already exposes. It never arms the controller or sends throttle, and it restores every setting it changes.
Firmware fix (
src/sp140/device_settings.cpp)send_device_data()streamedserializeJsonstraight intoUSBSerial.diagnosticsSendJsonalready did this.How
protocol.pydescribes the firmware's wire formats.links.pyhandles pyserial and bleak, and reconnects across reboots.fake_controller.pyserves the serial protocol on a local socket, so the real pyserial path runs. It also models the BLE layout and Fast-Link packets.tools/hc_emulatoronly emulates the screen, so it can't stand in here.test_hw_check.pyhas two kinds of tests:The README lists what's covered, and what still needs the rest of Layer 1 (BLE OTA transfers, esptool flashing paths, soak loop), Layer 2 (fixture and CAN adapter) or Layer 3 (camera, phone).
Tested on hardware (PDPC-MAIN, COM4)
The unit ran 8.1 RC 9d869ca plus this fix. 9d869ca is a local RC build, not yet pushed.
--esptool --firmwarediag_syncreplies after the fixOn reboot, the port stayed COM4 and the whole boot log was captured. BLE checks were not run, because the unit isn't bonded to that PC.
Found while testing, not fixed here
After an esptool hardware reset,
diag_syncstill labels the bootusb_command_reboot. The planned-restart marker kept in RTC memory isn't cleared once a boot has used it.🤖 Generated with Claude Code
https://claude.ai/code/session_0131SpAAHXzdS5D8UQaHfNrC