Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mavproxy_link.py: correct behaviour with old bindings #1191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

peterbarker
Copy link
Contributor

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

MAV> Detected vehicle 1:1 on link 0
Exception in thread main_loop:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/pbarker/.local/lib/python2.7/site-packages/MAVProxy-1.8.62-py2.7.egg/EGG-INFO/scripts/mavproxy.py", line 1129, in main_loop
  File "/home/pbarker/.local/lib/python2.7/site-packages/MAVProxy-1.8.62-py2.7.egg/EGG-INFO/scripts/mavproxy.py", line 819, in process_master
  File "/home/pbarker/.local/lib/python2.7/site-packages/pymavlink-2.4.39-py2.7.egg/pymavlink/dialects/v20/python2/ardupilotmega.py", line 16823, in parse_buffer
    m = self.parse_char(s)
  File "/home/pbarker/.local/lib/python2.7/site-packages/pymavlink-2.4.39-py2.7.egg/pymavlink/dialects/v20/python2/ardupilotmega.py", line 16762, in parse_char
    self.__callbacks(m)
  File "/home/pbarker/.local/lib/python2.7/site-packages/pymavlink-2.4.39-py2.7.egg/pymavlink/dialects/v20/python2/ardupilotmega.py", line 16750, in __callbacks
    self.callback(msg, *self.callback_args, **self.callback_kwargs)
  File "build/bdist.linux-x86_64/egg/MAVProxy/modules/mavproxy_link.py", line 950, in master_callback
    self.master_msg_handling(m, master)
  File "build/bdist.linux-x86_64/egg/MAVProxy/modules/mavproxy_link.py", line 638, in master_msg_handling
    if self.heartbeat_is_from_autopilot(m):
  File "build/bdist.linux-x86_64/egg/MAVProxy/modules/mavproxy_link.py", line 603, in heartbeat_is_from_autopilot
    mavutil.mavlink.MAV_TYPE_BATTERY,
AttributeError: 'module' object has no attribute 'MAV_TYPE_BATTERY'

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
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we're better off forming this as a set() when link module starts up, it would be a lot faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants