MC7455: Use GPS at same time as ModemManager

What is the recommended way to support GPS while ModemManager is also running on MC7455?

I can get GPS running by sending some AT commands to /dev/ttyUSB2 and then watching the NMEA strings on /dev/ttyUSB1.

But it looks like /dev/ttyUSB2 is also being used by ModemManager, so that some AT commands might fail if sent at the same time.

Normally I would let ModemManager manage GPS:

mmcli -m 0 --location-enable-gps-raw

But ModemManager doesn’t support GPS on the MC7455 (at least not except in really recent versions) so I have to fall back to using NMEA strings on /dev/ttyUSB1. But it seems that this is not really well supported in parallel with ModemManager, unless there is some recommended method of using them simultaneously?

Thanks in advance

I have been using this udev rule for a while, allowing gpsd to control the GPS while MM is handling the rest:

# Sierra GPS interfaces - use gpsd instead of MM
#  note on udev matching: it seems all ATTRS matches must be found at the same
#  level, so we must use ENV{ID_VENDOR_ID} to be able to match against bInterfaceNumber
SUBSYSTEM=="tty",ACTION=="add",ENV{ID_VENDOR_ID}=="1199",ATTRS{bInterfaceNumber}=="02",SYMLINK="gps%n",ENV{ID_MM_PORT_IGNORE}="1",RUN+="/usr/sbin/gpsdctl add $devnode"
SUBSYSTEM=="tty",ACTION=="remove",ENV{ID_VENDOR_ID}=="1199",ATTRS{bInterfaceNumber}=="02",RUN+="/usr/sbin/gpsdctl remove $devnode"

These rules abuse the fact that Sierra Wireless use static USB interface numbers, so you know that USB interface #2 is GPS regardless of the ttyUSBx device number. So it works even if you have more than one Sierra modem connected, or other ttyUSBx devices.

For completeness: I also have a gpsd device hook to support automatic start/stop of the NMEA with the default modem settings. The VID/PID extraction is a bit hackish and can most likely be done better, but this Works For Me™:

bjorn@miraculix:~$ cat /etc/gpsd/device-hook 
#!/bin/sh
# $Id: device-hook,v 1.3 2017/12/23 12:42:49 bjorn Exp $
#
# gpsd will not poll a device before it is opened, at which time this script is called
# This means that we can unconditionally add the GPS without wasting any power,  It
# will be activated when the first client connects to gpsd, and this script is called
#
# gpsd will also deactivate the port after some inactivity period

# figure out the parent usb device
USBDEV=`ls -l "$1" |sed -ne 's!^c......... [0-9]* [^ ]* [^ ]* \([0-9]*\), \([0-9]*\) .*!/sys/dev/char/\1:\2/device/../..!p'`

# silently ignore any non-USB ports
if [ ! -r "$USBDEV/idVendor" ] || [ ! -r "$USBDEV/idProduct" ]; then
  exit 0
fi 

VID=`cat "$USBDEV/idVendor"`
PID=`cat "$USBDEV/idProduct"`

case "$2" in
  ACTIVATE)
    CMD=START
    ;;
  *)
    CMD=STOP
    ;;
esac

case "$VID:$PID" in
  "1199:9071" |\
  "1199:9079" |\
  "1199:9091" )
    echo \$GPS_$CMD >"$1"
    ;;
  *)
    ;;
esac

exit 0

Note that you obviously will have to modify the list of supported VID:PIDs if you use something else than MC7455/Lenovo EM7455/EM7565

For reference, the “preferred” way to sync this logic with ModemManager would have been to:

  • Flag the NMEA ttys as “GPS data” with MM udev rules. When this is done, MM won’t poke those ports for anything.
  • Modify the Sierra plugin so that we allow “unmanaged GPS” support control via MM, e.g. so that you can start/stop the GPS engine using AT commands through MM.
  • And then, just let gpsd run on the NMEA tty, while starting/stopping the GPS engine e.g. with mmcli.

For modems with a dedicated NMEA tty, developing the previous logic is quite simple. Bjorn, which are the GPS start/stop commands you’re using for these devices?

In MM 1.10 (to be released in the following days) will support GNSS location using the QMI LOC service (even when in MBIM mode) for the MC7455.

Write $GPS_START and $GPS_STOP to the NMEA tty. This is common for many Qualcomm devices dating back to at least Gobi2k

Thanks, this is helpful.

The above rule makes MM ignore /dev/ttyUSB1 (the NMEA port), but to set up GPS I also have to send some AT commands to /dev/ttyUSB2 so I think I need to another rule for bInterfaceNumber “03”. Hopefully ModemManager can still get the modem working without access to the AT command port.

Most instructions I’ve seen for GPS on MC7455 also send some commands to the AT command port (typically /dev/ttyUSB2), rather just the $GPS_START command to the NMEA port (typically /dev/ttyUSB1).

Can we also set ID_MM_PORT_IGNORE on the AT command port and assume ModemManager can still fully work via the QMI devices?

This should not be necessary, except possibly for the initial configuration.

Just a short warning notice:
Recent firmwares (e.g. MC7455 02.24.x) are quite allergic to an “early” $GPS_START.
When the command is received while the FW is still starting, it halfway starts the tracking session (i.e. “AT!GPSSTATUS?” reports “Active”, but there are no NMEA sentences on the dedicated port, nor any FIX reported by AT!GPSLOC?).
If you wait until the QMI “sync” handshake has completed, the are no issues.
The 7455 needs about 9 seconds from USB numeration until the $GPS_START is accepted properly, the 7565 needs about 7 seconds.