AMC-975: Allow to select supported vehicle and to skip telemetry radi…#976
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the MAVLink connection logic to detect multiple vehicles on the same connection and handle unsupported autopilot types more gracefully. Instead of failing immediately when an unsupported vehicle is detected, the system now continues searching for a supported vehicle within the timeout period.
Key Changes:
- Modified heartbeat detection to collect all vehicles detected within the timeout window
- Changed behavior to skip unsupported autopilot types instead of returning an error immediately
- Updated logging messages to reflect the multi-vehicle detection capability
Comments suppressed due to low confidence (1)
ardupilot_methodic_configurator/backend_flightcontroller.py:493
- The loop continues when an unsupported autopilot is found but never breaks or returns when a supported autopilot is found. This means after processing a supported vehicle, the code falls through to line 498 and beyond, but
self.infostate may be set incorrectly if multiple vehicles were detected. The loop should explicitlybreakafter line 493 for a supported vehicle, or return success at that point.
for (sysid, compid), m in detected_vehicles.items():
self.info.set_system_id_and_component_id(sysid, compid)
logging_debug(
_("Connection established with systemID %d, componentID %d."), self.info.system_id, self.info.component_id
)
self.info.set_autopilot(m.autopilot)
if self.info.is_supported:
msg = _("Autopilot type {self.info.autopilot}")
logging_info(msg.format(**locals()))
else:
msg = _("Unsupported autopilot type {self.info.autopilot}")
# return msg.format(**locals())
continue
self.info.set_type(m.type)
msg = _("Vehicle type: {self.info.mav_type} running {self.info.vehicle_type} firmware")
logging_info(msg.format(**locals()))
| if not detected_vehicles: | ||
| return _("No MAVLink heartbeat received, connection failed.") | ||
| self.info.set_system_id_and_component_id(m.get_srcSystem(), m.get_srcComponent()) | ||
| logging_debug( | ||
| _("Connection established with systemID %d, componentID %d."), self.info.system_id, self.info.component_id | ||
| ) | ||
|
|
||
| self.info.set_autopilot(m.autopilot) | ||
| if self.info.is_supported: | ||
| msg = _("Autopilot type {self.info.autopilot}") | ||
| logging_info(msg.format(**locals())) | ||
| else: | ||
| msg = _("Unsupported autopilot type {self.info.autopilot}") | ||
| return msg.format(**locals()) | ||
| for (sysid, compid), m in detected_vehicles.items(): |
There was a problem hiding this comment.
After the loop completes (line 477-494), there's no handling for the case where all detected vehicles are unsupported. The code should return an error message after the loop if no supported vehicle was found, otherwise it will continue to line 498 with potentially incorrect vehicle state.
| logging_info(msg.format(**locals())) | ||
| else: | ||
| msg = _("Unsupported autopilot type {self.info.autopilot}") | ||
| # return msg.format(**locals()) |
There was a problem hiding this comment.
Commented-out code should be removed rather than left in the codebase. If this is temporary for debugging or comparison, add a TODO comment explaining why it's retained.
| # return msg.format(**locals()) |
878e02c to
2b582a3
Compare
2b582a3 to
d20fa86
Compare
Allow to select supported vehicle and to skip telemetry radio as another system on the same connection
amilcarlucas
left a comment
There was a problem hiding this comment.
Thanks for your contribution.
I corrected the linting issues, squashed the commits and rewrote the commit message to obey conventional commits standards.
d20fa86 to
1a5d2e7
Compare
|
Tested in windows, works for both udp and tcp |
…o as another system on the same connection
Possible fix for #975
pushed with --no-verify