Skip to content

Add RTT telemetry and live plot tool (pyOCD + matplotlib) - #11

Merged
Candas1 merged 4 commits into
devfrom
rtt-monitor
Nov 27, 2026
Merged

Candas1 merged 4 commits into
devfrom
rtt-monitor

Conversation

@candas-agent

@candas-agent candas-agent commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

What

Firmware (only with DEBUG_RTT)

  • New debug command p (p1 on, p0 off, p toggles). Prints a header $H,<fields> and then one $T,<values> line every TIME_TELEMETRY ms (20 ms, config.h).
  • Fields follow the enabled features: ms, s1, s2, IMU ax..az, gx..gz, imu_temp, AHRS roll, pitch, yaw, sent frame tx_cmd1, tx_cmd2, tx_pitch, tx_dpitch, tx_sensors, feedback rx_frames, rx_cmd1, rx_cmd2, rx_speedR, rx_speedL, rx_bat, rx_temp, rx_led.
  • Hoverserial: getCommand(), getFeedback(), getFeedbackCount().
  • Removed the IMU text print commands a, g, t, q, e: telemetry carries the same values, and they freed the flash telemetry needed on GD32F130C6 (all/icm20948-ahrs were 256/124 bytes over). Telemetry print helpers are functions, not macros, for the same reason.

tools/rtt_monitor.py

  • pyOCD attaches (no reset/halt) with the generic cortex_m target, so GD32 needs no pack. The RTT control block address comes from _SEGGER_RTT in .pio/build/<env>/firmware.elf (--env/--elf), or --rtt-address/--rtt-size.
  • Sends p1, plots the groups present in the header (angles, gyro, accel, sent commands, sent pitch, received speed, battery/temp, sensors) over a sliding window (--window, 10 s), optional --csv. Other RTT lines are printed; console input is forwarded (?, i, ...). Sends p0 on exit.

README section and tools/requirements.txt added; CI gets a py_compile job for tools/*.py.

CI

30/33: only the known STM32F103C6 IMU+AHRS overflows remain (STM32F103C6 all went from 11.9 to 11.8 KB over).

Tested

  • Parser and plot with synthetic data (matplotlib, Agg).
  • Not tested on hardware: pyOCD connection, cortex_m attach on GD32, RTT throughput at 50 Hz (512 B up buffer; truncated lines are dropped).

🤖 Generated with Claude Code

candas-agent and others added 4 commits November 27, 2026 15:10
Firmware (DEBUG_RTT):
- Debug command p (p1 on, p0 off) prints "$H,<fields>" then
  "$T,<values>" every TIME_TELEMETRY ms (20). Fields follow the enabled
  features: sensors, IMU accel/gyro/temp, AHRS angles, frame sent to the
  mainboard and last valid feedback frame.
- Hoverserial: getCommand(), getFeedback(), getFeedbackCount().

tools/rtt_monitor.py:
- Attaches with pyOCD (generic cortex_m target, works for GD32 and STM32),
  reads the _SEGGER_RTT address from the firmware ELF, enables telemetry,
  plots it live with matplotlib, optional CSV, forwards console input.

CI: py_compile check for tools/*.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The TELEM macros expanded ~30 print calls of different types inline and
pushed GD32F130C6 all/icm20948-ahrs over 32 KB (by 572/440 bytes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Telemetry (p) prints the same accel/gyro/temperature/angle values, and
rtt_monitor.py plots them. Frees flash: GD32F130C6 all/icm20948-ahrs
were 256/124 bytes over 32 KB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Candas1
Candas1 marked this pull request as ready for review November 27, 2026 15:59
@Candas1
Candas1 merged commit e8e08f9 into dev Nov 27, 2026
31 of 34 checks passed
@candas-agent
candas-agent deleted the rtt-monitor branch November 27, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants