Skip to content

Commit

Permalink
mavproxy_link.py: correct behaviour with old bindings
Browse files Browse the repository at this point in the history
some of these MAV_TYPEs are not known in older bindings, e.g. MAV_TYPE_BATTERY.  Avoid fatal errors here when we're working with older bindings
  • Loading branch information
peterbarker committed Jul 3, 2023
1 parent 0384b76 commit 0c39700
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions MAVProxy/modules/mavproxy_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,23 +591,28 @@ def heartbeat_is_from_autopilot(self, m):
if m.get_srcComponent() in component_ids_which_are_not_vehicles:
return False

mav_types_which_are_not_vehicles = frozenset([
mavutil.mavlink.MAV_TYPE_GCS,
mavutil.mavlink.MAV_TYPE_ONBOARD_CONTROLLER,
mavutil.mavlink.MAV_TYPE_GIMBAL,
mavutil.mavlink.MAV_TYPE_ADSB,
mavutil.mavlink.MAV_TYPE_CAMERA,
mavutil.mavlink.MAV_TYPE_CHARGING_STATION,
mavutil.mavlink.MAV_TYPE_SERVO,
mavutil.mavlink.MAV_TYPE_ODID,
mavutil.mavlink.MAV_TYPE_BATTERY,
mavutil.mavlink.MAV_TYPE_LOG,
mavutil.mavlink.MAV_TYPE_OSD,
mavutil.mavlink.MAV_TYPE_IMU,
mavutil.mavlink.MAV_TYPE_GPS,
mavutil.mavlink.MAV_TYPE_WINCH,
])
if m.type in mav_types_which_are_not_vehicles:
found_mav_type = False
# not all of these are present in all versions of mavlink:
for t in [ "MAV_TYPE_GCS",
"MAV_TYPE_ONBOARD_CONTROLLER",
"MAV_TYPE_GIMBAL",
"MAV_TYPE_ADSB",
"MAV_TYPE_CAMERA",
"MAV_TYPE_CHARGING_STATION",
"MAV_TYPE_SERVO",
"MAV_TYPE_ODID",
"MAV_TYPE_BATTERY",
"MAV_TYPE_LOG",
"MAV_TYPE_OSD",
"MAV_TYPE_IMU",
"MAV_TYPE_GPS",
"MAV_TYPE_WINCH",
]:
if getattr(mavutil.mavlink, t, None) is not None:
found_mav_type = True
break

if not found_mav_type:
return False

return True
Expand Down

0 comments on commit 0c39700

Please sign in to comment.