Skip to content

mavlink_wifi: make UART auto-baud work again - #7

Merged
peterbarker merged 1 commit into
ArduPilot:masterfrom
peterbarker:sonix-autobaud
Nov 15, 2026
Merged

peterbarker merged 1 commit into
ArduPilot:masterfrom
peterbarker:sonix-autobaud

Conversation

@peterbarker

Copy link
Copy Markdown

Summary

Make the Sonix find the flight controller's baud rate again. Since 2017, auto-baud has never run because of a seconds/milliseconds mix-up, so the Sonix stayed at 625000 and couldn't talk to a flight controller set to 115200.

Description

mavlink_check_baudrate() compared get_sys_seconds_boot(), in seconds, with last_heartbeat_ms, in milliseconds, ever since last_heartbeat became last_heartbeat_ms in 84046b07 (June 2017). The check never passed. This went unnoticed because skyviper-v2450's SERIAL1_BAUD is 625000, the first rate the Sonix tries.

With this change:

  • milliseconds are used throughout
  • from boot, the Sonix waits 20 s for a heartbeat at 625000 (the flight controller takes about 15 s to send its first one), then tries each rate in turn for 4 s
  • once it has heard a heartbeat, it only searches again after 30 s of silence, rather than after any 3 s without one as before 2017. A flight controller restarting, or a busy link, doesn't move it off the right rate
  • each change of rate is printed on the console
  • entering MAVLink mode resets the rate index along with the rate, so the next search starts from 625000

Testing

On a SkyViper with SERIAL1_BAUD 625000, built together with #5 and #6:

Step Result
Sonix boot locked at 625000; no rate changes
Flight controller rebooted (about 15 s without heartbeats) stayed at 625000; no rate changes; all message rates back once it returned

Not exercised on the bench: the search itself, i.e. a flight controller at 115200, or more than 30 s of silence.

mavlink_check_baudrate() compared get_sys_seconds_boot(), in seconds,
with last_heartbeat_ms, in milliseconds, ever since last_heartbeat
became last_heartbeat_ms in 2017.  So auto-baud never ran: the Sonix
stayed at 625000, which skyviper-v2450's SERIAL1_BAUD matches, and
couldn't find a flight controller set to 115200.

Use milliseconds throughout.  Rather than switching rate after any
3 seconds without a heartbeat, as before 2017, wait 20 seconds from
boot (the flight controller takes about 15 to send its first) before
trying each rate in turn for 4 seconds, and once a heartbeat has been
heard, only search again after 30 seconds of silence.  A flight
controller restarting, or a busy link, no longer moves us off the
right rate.  Each change is shown on the console.

Entering MAVLink mode sets 625000 directly; reset the rate index with
it, so the next search starts from there.
@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: ACCEPT

Reviewed at head 3e5c0ee4d9.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/skyrockettoys-sonix/7/1.html#prSkyRocketToys-Sonix-7

No problems found: this one-commit fix makes UART auto-baud in mavlink_wifi.c work again by using milliseconds throughout. The new search timing at mavlink_wifi.c:1886 and the index reset on entering MAVLink mode at mavlink_wifi.c:1839 both checked out. Host simulations of the extracted function matched the commit message: a 20 s hold after boot, 4 s at each rate, a new search only after 30 s without a heartbeat, and no wrap problems. The firmware built at this head with no new warnings. It has not been run on SkyViper hardware.

@peterbarker
peterbarker merged commit ed91540 into ArduPilot:master Nov 15, 2026
1 check passed
@peterbarker
peterbarker deleted the sonix-autobaud branch November 16, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants