2026 sim: drive the Unity simulation with the real remote over the radio

Dongle (app):
- bridge mode: stands in for the robot's radio (ch 96 / 250k / HXPD1,
  auto-ack, dynamic payloads, ack payloads). Received packets go to the PC
  as A5-framed 'R' frames; the PC's 'A' frames become the ack payload of
  the next packet, like robot/Comms.cpp; dropped after ~0.5 s without a
  refresh. 'S' status once a second.
- USART RX through circular DMA into a ring buffer, overrun stall
  disabled, error flags cleared: a burst (e.g. SignalRGB probing the port)
  used to deafen the app until a replug.
- RX test mode ('x') accepts protocol v4's dynamic-length packets.
- safeboot_flash.py --knock: keeps knocking across a replug to catch
  safeboot's cold-boot window when the app doesn't answer.

Unity:
- SimRemote sources: Keyboard, or the real remote via the dongle
  (DongleLink.cs: kernel32 serial, auto-finds the CH340, all port I/O on
  one background thread). Packets go into the firmware byte for byte, the
  robot's telemetry goes back on the ack, so the remote's display shows
  the sim. Tested end to end with the real remote.
- Dropped the USB joystick and robot-serial-harness inputs and the old
  Serial/Serial2/Serial3/HandleHoystick scripts (and their components in
  Main.unity): no USB links to remote or robot any more.
- Test panel: dongle status; no sideways scroll bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-17 22:48:41 +01:00
1 parent 6b3b2629cd
commit 2b4750f8f4
24 files changed
+682 -710

No files matched your search

+36 -4
View File
@@ -155,7 +155,9 @@ python tools/safeboot_flash.py firmware/build/app.bin
```
This resets the running app into safeboot and rewrites only the app region. If
the app is dead, replug the stick and re-run — it will catch the knock window.
the app is dead or doesn't answer, start it with `--knock` and then replug the
stick: it keeps knocking (reopening the port as it comes back) until it lands in
safeboot's 1.5 s cold-boot window.
## Air settings
@@ -168,6 +170,36 @@ the Si24R1 over SPI (same register layout as the nRF24L01+).
- [x] identify the hardware, map the radio + serial pins
- [x] permanent two-stage firmware, wire-free USB flashing
- [ ] identify the LED and AT2401C TX/RX-enable pins (app toggles the 5 free pins)
- [ ] radio hub app: carry `CmdPacket` both ways, per-node addressing, telemetry
- [ ] Unity serial bridge (PC as hub when online, robot as hub when not) — see
`../README.md` "Planned"
- [x] bridge mode: the dongle stands in for the robot's radio, Unity runs the
robot firmware (sim) behind it — see "Bridge mode" below
- [ ] the other direction: Unity as the remote, driving the real robot
- [ ] AT2401C pins: at desk range and even a few rooms away with the remote at
minimum power, every on/off combination of PA1/PB1/PF0/PF1 received
every packet, so they couldn't be told apart; the link works without
driving them
## Bridge mode (Unity ↔ real remote)
The app listens on the hexapod's air settings as if it were the robot
(ch 96, 250 kbps, `HXPD1`, auto-ack, dynamic payload lengths, ack payloads)
and passes everything to the PC. Framing both ways over the USB serial
(115200 8N1):
```
A5 type len payload[len] sum sum = type + len + payload bytes (mod 256)
```
| Direction | Type | Payload |
|-----------|------|---------|
| PC → dongle | `L` | — : start bridging (LED on) |
| PC → dongle | `X` | — : stop |
| PC → dongle | `A` | ≤ 32 bytes: the robot's `Telemetry`, sent back on the auto-ack of the remote's next packet (reloaded after every packet, like `robot/Comms.cpp`). Dropped if not refreshed for ~0.5 s, so the remote never shows stale telemetry as live |
| dongle → PC | `R` | a packet the remote sent (its `CmdPacket`, any length; the firmware checks it) |
| dongle → PC | `S` | once a "second": packets received (u16 LE), ack payloads loaded (u16 LE). Its second runs ~30% long (blocking UART sends miss SysTick ticks); it's only for display |
Plain text never contains `A5`, so the PC skips anything between frames;
while bridging the app prints no text and only takes frames (and `b` for a
reflash). USB serial input goes through DMA into a ring buffer (no
interrupts in this app), and the USART's overrun stall is disabled, so a
burst can't deafen it. Unity's side is
`Hexapod_Simulation_Unity/Assets/HexapodSim/DongleLink.cs`.