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

Exception in mavutil.py after bad_data multi-instance message #807

Open
clydemcqueen opened this issue May 2, 2023 · 0 comments · May be fixed by #822
Open

Exception in mavutil.py after bad_data multi-instance message #807

clydemcqueen opened this issue May 2, 2023 · 0 comments · May be fixed by #822

Comments

@clydemcqueen
Copy link

Summary:

For multi-instance message types, e.g., https://mavlink.io/en/messages/common.html#DISTANCE_SENSOR, a call to add_message with a bad_data message will fail to initialize the messages[mtype]._instances dictionary. The next good message after that will cause an exception.

Traceback:

$ mavlogdump.py --quiet --types DISTANCE_SENSOR ~/Desktop/sa_tests/2023_04_18_surftrak3/2023-04-18\ 11-03-34.tlog
Traceback (most recent call last):
  File "/home/clyde/.local/bin/mavlogdump.py", line 242, in <module>
    m = mlog.recv_match(blocking=args.follow, type=match_types)
  File "/home/clyde/.local/lib/python3.10/site-packages/pymavlink/mavutil.py", line 1633, in recv_match
    m = self.recv_msg()
  File "/home/clyde/.local/lib/python3.10/site-packages/pymavlink/mavutil.py", line 481, in recv_msg
    self.post_message(msg)
  File "/home/clyde/.local/lib/python3.10/site-packages/pymavlink/mavutil.py", line 1436, in post_message
    super(mavlogfile, self).post_message(msg)
  File "/home/clyde/.local/lib/python3.10/site-packages/pymavlink/mavutil.py", line 378, in post_message
    add_message(self.sysid_state[src_system].messages, type, msg)
  File "/home/clyde/.local/lib/python3.10/site-packages/pymavlink/mavutil.py", line 99, in add_message
    messages[mtype]._instances[instance_value] = msg
TypeError: 'NoneType' object does not support item assignment

A possible fix is to modify the if statement:

if mtype not in messages or messages[mtype]._instances is None:

Reference this conversation:
https://discuss.bluerobotics.com/t/mavlogdump-py-crashes-while-reading-distance-sensor-msgs-in-some-tlog-files/14228

clydemcqueen added a commit to clydemcqueen/pymavlink that referenced this issue May 9, 2023
clydemcqueen added a commit to clydemcqueen/pymavlink that referenced this issue May 29, 2023
@clydemcqueen clydemcqueen linked a pull request May 29, 2023 that will close this issue
clydemcqueen added a commit to clydemcqueen/pymavlink that referenced this issue Jul 11, 2023
clydemcqueen added a commit to clydemcqueen/pymavlink that referenced this issue Jul 11, 2023
clydemcqueen added a commit to clydemcqueen/pymavlink that referenced this issue Jul 12, 2023
tridge pushed a commit to clydemcqueen/pymavlink that referenced this issue Jul 22, 2023
clydemcqueen added a commit to clydemcqueen/pymavlink that referenced this issue Nov 20, 2023
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 a pull request may close this issue.

1 participant