Files
PX4-Autopilot/src/modules
Pavel Guzenfeld 2a69f92bb1 fix(uxrce_dds_client): fix session reconnection after agent restart (#26848)
* fix(uxrce_dds_client): fix session reconnection after agent restart

When the Micro XRCE-DDS Agent is restarted (e.g. via systemd or
Docker), the PX4 client stays "Running, disconnected" forever and
never re-establishes the session. Three bugs prevented reconnection:

1. session.on_pong_flag was never reset after being checked. Once set
   to 1 by the first successful pong, it stayed 1 forever, causing
   checkConnectivity() to believe pings were still succeeding even
   after the agent was gone. Fixed by resetting to 0 after reading.

2. _subs->reset() was never called during session teardown. Stale
   uORB file descriptors from the previous session persisted across
   reconnection attempts, causing the new session's publishers to
   malfunction. Fixed by calling _subs->reset() in deleteSession().

3. _connected was not explicitly reset in deleteSession(). While the
   outer loop checked this flag, explicitly clearing it ensures clean
   state for the next reconnection attempt.

Closes #26022

Signed-off-by: Pavel Guzenfeld <pavelgu@gmail.com>

* fix(uxrce_dds_client): clear fds[].events in reset() for reconnection

Without clearing events, init() skips orb_subscribe() on reconnect
because the POLLIN guard (fds[idx].events == 0) is never true again.
This causes all fds to remain at -1, px4_poll() returns 0, TX rate
stays zero, and the client enters a disconnect/reconnect loop.

Reported-by: sansha (tested on Pixhawk 6X with serial transport)

* ci: re-trigger SITL tests (flaky offboard test)

* docs(uxrce_dds_client): explain why reset() clears fds[].events

---------

Signed-off-by: Pavel Guzenfeld <pavelgu@gmail.com>
2026-04-15 12:20:43 -08:00
..