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

Mavlogdump fails on tlog with .log suffix #710

Open
booo opened this issue Jul 19, 2022 · 0 comments · May be fixed by #900
Open

Mavlogdump fails on tlog with .log suffix #710

booo opened this issue Jul 19, 2022 · 0 comments · May be fixed by #900

Comments

@booo
Copy link

booo commented Jul 19, 2022

Mavlogdump fails on tlogs that have a .log suffix.

Traceback (most recent call last):
  File "/home/borgers/projects/MAVProxy/env/bin/mavlogdump.py", line 4, in <module>
    __import__('pkg_resources').run_script('pymavlink==2.4.31', 'mavlogdump.py')
  File "/home/borgers/projects/MAVProxy/env/lib/python3.10/site-packages/pkg_resources/__init__.py", line 651, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/home/borgers/projects/MAVProxy/env/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1448, in run_script
    exec(code, namespace, namespace)
  File "/home/borgers/projects/MAVProxy/env/lib/python3.10/site-packages/pymavlink-2.4.31-py3.10-linux-x86_64.egg/EGG-INFO/scripts/mavlogdump.py", line 83, in <module>
    mlog = mavutil.mavlink_connection(filename, planner_format=args.planner,
  File "/home/borgers/projects/MAVProxy/env/lib/python3.10/site-packages/pymavlink-2.4.31-py3.10-linux-x86_64.egg/pymavlink/mavutil.py", line 1776, in mavlink_connection
    if DFReader.DFReader_is_text_log(device):
  File "/home/borgers/projects/MAVProxy/env/lib/python3.10/site-packages/pymavlink-2.4.31-py3.10-linux-x86_64.egg/pymavlink/DFReader.py", line 1045, in DFReader_is_text_log
    ret = (f.read(8000).find('FMT,') != -1)
  File "/usr/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 2: invalid continuation byte

The DFReader_is_text_log function opens the binary file as text file and tries to do UTF-8 decoding which does not work in case of a binary tlog file. This happens because we assume that files with suffix .log can be opened as text: https://github.com/ArduPilot/pymavlink/blob/master/mavutil.py#L1773

We should not make such assumptions.

One solution could be to wrap the opening of the file in DFReader_is_text_log into a try/catch and return False in case of a exception.

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