fix: USART6 TX truncation (Issue #522) #526

Closed
sl-jetson wants to merge 0 commits from sl-controls/issue-522-usart6-truncation into main
Collaborator

Summary

  • Add jlink_tx_locked() helper in jlink.c that disables USART1_IRQn around every blocking HAL_UART_Transmit call
  • Prevents HAL_UART_IRQHandler (fired by DMA-RX IDLE interrupt) from resetting gState mid-frame and truncating telemetry output
  • Add s_tx_busy flag to drop any re-entrant TX caller (ESC debug, future USART6/VESC paths)
  • Correct stale config.h comment that misidentified the Jetson link as USART6 (moved to USART1 in Issue #120)

Root Cause

jlink_send_telemetry (50 Hz) and jlink_send_power_telemetry (1 Hz) both call HAL_UART_Transmit(&s_uart, …) on USART1. The USART1 IDLE interrupt (used for DMA circular RX) fires while polling TX is running, HAL_UART_IRQHandler resets gState to READY, and the next caller enters HAL_UART_Transmit before the hardware finishes the previous frame — producing leading nulls / truncated frames at 921600 baud.

Test plan

  • Flash to Mamba F722 and verify Jetson receives clean framed STATUS telemetry at 50 Hz with no leading null bytes
  • Force simultaneous 50 Hz + 1 Hz tick (tick ≡ 0 mod 1000 ms) and verify no frame corruption
  • Confirm DMA RX continues to receive Jetson DRIVE/HEARTBEAT frames while TX lock is held

🤖 Generated with Claude Code

## Summary - Add `jlink_tx_locked()` helper in `jlink.c` that disables `USART1_IRQn` around every blocking `HAL_UART_Transmit` call - Prevents `HAL_UART_IRQHandler` (fired by DMA-RX IDLE interrupt) from resetting `gState` mid-frame and truncating telemetry output - Add `s_tx_busy` flag to drop any re-entrant TX caller (ESC debug, future USART6/VESC paths) - Correct stale `config.h` comment that misidentified the Jetson link as USART6 (moved to USART1 in Issue #120) ## Root Cause `jlink_send_telemetry` (50 Hz) and `jlink_send_power_telemetry` (1 Hz) both call `HAL_UART_Transmit(&s_uart, …)` on USART1. The USART1 IDLE interrupt (used for DMA circular RX) fires while polling TX is running, `HAL_UART_IRQHandler` resets `gState` to `READY`, and the next caller enters `HAL_UART_Transmit` before the hardware finishes the previous frame — producing leading nulls / truncated frames at 921600 baud. ## Test plan - [ ] Flash to Mamba F722 and verify Jetson receives clean framed STATUS telemetry at 50 Hz with no leading null bytes - [ ] Force simultaneous 50 Hz + 1 Hz tick (tick ≡ 0 mod 1000 ms) and verify no frame corruption - [ ] Confirm DMA RX continues to receive Jetson DRIVE/HEARTBEAT frames while TX lock is held 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sl-jetson added 2 commits 2026-03-06 23:03:21 -05:00
Add saltybot_motor_daemon ROS2 package — Python daemon that subscribes
to /cmd_vel and drives the FC via W<speed>,<steer>\n over /dev/ttyTHS1
at 921600 baud.

- motor_daemon_node.py: 50 Hz fixed-rate TX, 200ms safety watchdog,
  Twist→ESC conversion (±1000 range), FC ack parsing (W:<s>,<st>),
  periodic ? status query, /diagnostics publisher, auto-reconnect
- config/motor_daemon_params.yaml: all tunable params with comments
- launch/motor_daemon.launch.py: parameterised launch file
- test/test_motor_daemon.py: 25 unit tests (all passing)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
USART1 IDLE interrupt (DMA circular RX) was calling HAL_UART_IRQHandler
mid-frame during polling HAL_UART_Transmit, resetting gState and causing
leading nulls / truncated frames on the Jetson telemetry link at 921600 baud.

Fix: introduce jlink_tx_locked() which disables USART1_IRQn around every
blocking HAL_UART_Transmit call, preventing IRQHandler from corrupting
gState while the TX loop is running.  A s_tx_busy flag drops any
re-entrant caller (ESC debug, future USART6/VESC paths).

Both jlink_send_telemetry (50 Hz) and jlink_send_power_telemetry (1 Hz)
now use jlink_tx_locked().  Also correct the stale config.h comment that
misidentified the Jetson link as USART6 (it moved to USART1 in Issue #120).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson closed this pull request 2026-03-07 09:20:14 -05:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#526
No description provided.