Modem Manager GPS issue

@RDB, since the modem is not working when using the container I cannot read the GPS from there.
However, when I use a standard RPi3 with a usb GPS attached, I install gpsd and python-gps packages inside the container, and use a small python script to get the readings.

@rytterlund what version of resinOS are you working with. I know the Quectel EC20 had some kernel issues with earlier versions, so I would recommend trying with the latest 2.9.6+rev1

@RDB, One thing I could suggest trying is to add some of the modemManager udev rules into your container aswell. I have done something similar before for Huawei modems as seen here: https://github.com/shaunmulligan/soracom-resin-modemAT/blob/shauns-branch/Dockerfile.template#L37

If you add the correct rules for your modem (look in the modemManager repo) then in theory the container udev will correctly ignore the modem device on restart.

@shaunmulligan i have a similar rule in my docker file.
It is copying the custom udev rules of the modem to the container.
But they will not work without the udevadm trigger command.
But the thing is that command makes the modem sometimes disappear. I tried adding a delay on this trigger command of 30 sec or so and that looked like it worked. then tried with 10 sec delay and that wasn’t stable.
Now iam not sure anymore if adding a delay on the trigger is stable at all.

@shaunmulligan Indeed the modem is passing me on default all the NMEA messages without having to enable it. When running the command I do get results from the modem:

$ mmcli -m 0 --command="AT+CGPSINFO"
response: '+CGPSINFO: ,,,,,,,,'

When adjusting the antenna a bit closer to the window, the result was much better:

$ mmcli -m 0 --command="AT+CGPSINFO"
response: '+CGPSINFO: **********,N,***********,E,260118,082556.0,45.2,0.0,288.8'

So now I was also able to get the data in the container from the serial port /dev/ttyUSB1 and parse the data into a lat long without having to do much configuration after all.

@RDB that is awesome news, glad you got it all worked out. It should also be possible to install the mmcli tool in your container (The repo I linked to earlier in the thread actually does that) this has the advantage not having to worry about which tty the NMEA sentences are on, but would require you to do polling instead of just ingesting GPS events as they come out.

How quickly does your SIM7100 get a GPS fix, I used to have the older SIM5360, but it would take a minute or so to get a fix with an active antenna. Also out of interest, what kinda application are you building, I am always very curious about GSM and GPS based projects :slight_smile:

@shaunmulligan you where right. I do have to send at least one time the command: AT+CGPSCOLD after a reboot. Otherwise the modem is nog going to stream the data to ttyUSB1.

I can do this manually with the mmcli command in the hostOS, but i would like to send this command one time to the ttyUSB2 within my docker file. Do you know what line i can use to send the command to the serial port?

I tried something like this on command line in the container, but i don’t see it changing:

echo -ne "AT" > /dev/ttyUSB2
echo -ne "CGPSCOLD" > /dev/ttyUSB2

Maybe you have an idea how to trigger the serial and get the stream started without having to add mmcl to the container? Maybe with a bash script and a docker file rule?

@shaunmulligan, I’m using the latest 2.9.6+rev1, and I’m also copying custom udev rules of the modem to the container. But It’s not working. @RDB, how did you get it to work?

@rytterlund did you get the host to recognise the modem with mmcli -L? And did you add a good cellular network manager file in the systems-connections folder? Mine has only the basics. Just APN, name of the connection, type gsm and autoconnect.

And did you comment out the udevadm trigger in the base img of the container? You dont nessesarily need the udev rules. Since you cannot use the udevadm trigger command anyway.

@RDB, I think the problem with the snippet you shared there is that you are sending the AT commands to the NMEA port, you need to send it to the ttyUSB that is for AT commands. So probably something like:

echo -ne "AT+CGPSCOLD" > /dev/ttyUSB3

Would be what you need. Personally I would just toss mmcli in the container, its a statically compiled C binary, so it basically adds very little size to the container and gives you a lot more control :slight_smile:

@shaunmulligan thnx for the suggestion and indeed the way with mmcli is better.
Now i figured i could use mmcli with DBUS and indeed i got that working without having to add mmcli to the container by using this command:

DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
	dbus-send \
	--system \
	--print-reply \
	--dest=org.freedesktop.ModemManager1 \
	/org/freedesktop/ModemManager1/Modem/0 \
	org.freedesktop.ModemManager1.Modem.Command \
	string:"AT+CGPSCOLD" uint32:10

@RDB, ah, that is a very nice little solution. I might borrow that for my projects :slight_smile:

This is working only if there is a simcard attached to the device. Do you guys know if the GPS will work without the simcard? Or how to achieve this? Because i get this error now:

Command failed:  DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket dbus-send --system --print-reply --dest=org.freedesktop.ModemManager1 /org/freedesktop/ModemManager1/Modem/0 org.freedesktop.ModemManager1.Modem.Command string:"AT+CGPSCOLD" uint32:10

Error org.freedesktop.DBus.Error.UnknownMethod: Method Command is not implemented on interface org.freedesktop.ModemManager1.Modem

@RDB I believe this is the way modemManager is designed, it won’t initialise the modem unless there is a SIM, and since the --command option requires an initialised modem to communicate, those commands naturally fail.

So you are just using the Modem for GPS only? I think you you have to try enable the GPS by sending AT commands directly to the serial port. But if you arent using the connectivity of the modem, I would almost recommend rather getting something like https://www.adafruit.com/product/746 , it tends to get a fix much faster than the LTE modems I have tested and has the option of passive or active antenna :slight_smile:

Hmm yes. Well it is meant to be used with a simcard anyway. So i will not put in an extra device or try to enable the modem for now.