Mavproxy Module syntax error

Hello,

I found the module “nmea.py” (https://github.com/tridge/cuav/blob/master/cuav/modules/nmea.py ) and am now desperately trying to get it to work.
But anytime i start mavproxy, it will not load the module due to a syntax error.
I’m hoping anyone would like to look through my problem and could point me towards the right direction as to what i’m doing wrong.

I added the code as mavproxy_nmea.py to the directory /modules and started setup.py with setup.py build install --user

Now when i start mavproxy, everything works besides loading this module.
It reads back:
pi@raspberrypi:~/MAVProxy/MAVProxy/modules $ mavproxy.py --master=/dev/ttyACM0 --baudrate 115200 --load-module nmea --aircraft MyRover --moddebug 3 Connect /dev/ttyACM0 source_system=255 ERROR in command ['load', 'nmea']: invalid syntax (mavproxy_nmea.py, line 2) Traceback (most recent call last): File "/home/pi/.local/lib/python2.7/site-packages/MAVProxy-1.8.29-py2.7.egg/EGG-INFO/scripts/mavproxy.py", line 739, in process_stdin File "/home/pi/.local/lib/python2.7/site-packages/MAVProxy-1.8.29-py2.7.egg/EGG-INFO/scripts/mavproxy.py", line 551, in cmd_module File "/home/pi/.local/lib/python2.7/site-packages/MAVProxy-1.8.29-py2.7.egg/EGG-INFO/scripts/mavproxy.py", line 487, in load_module File "/home/pi/.local/lib/python2.7/site-packages/MAVProxy-1.8.29-py2.7.egg/EGG-INFO/scripts/mavproxy.py", line 641, in import_package File "/home/pi/.local/lib/python2.7/site-packages/MAVProxy-1.8.29-py2.7.egg/MAVProxy/modules/mavproxy_nmea.py", line 2 import math import os import serial import socket import subprocess import sys import time from MAVProxy.modules.lib import mp_module from ^ SyntaxError: invalid syntax no script MyRover/mavinit.scr Log Directory: MyRover/logs/2020-12-22/flight2 Telemetry log: MyRover/logs/2020-12-22/flight2/flight.tlog Waiting for heartbeat from /dev/ttyACM0 MAV> online system 1 HOLD> Mode HOLD MAV> Flight battery 100 percent Received 940 parameters Saved 940 parameters to MyRover/logs/2020-12-22/flight2/mav.parm MAV>

Keep in mind, the arrow pointing to the syntax error is underneath the “t” when importing the second python module. (See picture)

Simply starting python in the terminal and enter “import os” (or any other module) will work like a charm.

I would be glad for any clues.

Thanks

Edit:

A quick search with help('modules') under python shows, that the needed modules are indeed installed under /usr/lib/python2.7/os.py

From that picture, the mavproxy_nmea.py file appears to be corrupted - the entire file looks like it is on one line, rather that a seperate line for each “import”. How did you install mavproxy_nmea.py?

I’ve opened a PR here that brings this module into mainline mavproxy as ‘nmeaout’ module:


I’ve tested it and it works well

1 Like

It will take until this late evening for me to be able to have a look into the file and show you.

However, the import variables definitely are on single lines.