CF-20 GPS Configuration (Ubuntu)

There are two mutually exclusive approaches to polling the GPS coordinates from the Sierra Wireless LTE/GPS (EM7355) module on the Panasonic CF-20 Toughbook.

Notes:

  • This approach was built specifically for the CF-20 Toughbook
  • This approach was tested on Ubuntu 21.10

Approach 1 - gpsd

Install and Configure gpsd

  1. Install gpsd packages.
$ sudo apt install gpsd gpsd-clients -y
  1. Edit /etc/default/gpsd.
START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyUSB2"
GPSD_OPTIONS="-n"
  1. Create a pre-exec script for gpsd called /usr/sbin/cf20-init-gps.sh.
#!/bin/bash
#
# Author        : Gaston Gonzalez
# Date          : 9 January 2022
# Description   : Starts the Sierra Wireless GPS module in away that allows gpsd to read
#                 the NMEA frames off the TTY device. This script was designed for use
#                 with the CF-20 Toughbook with the EM7355 LTE/GPS module.
#
# Precondition  : gpsd is stopped
# Postcondition : gpsd is ready to be started

GPS_DEVICE=/dev/ttyUSB2

/usr/bin/stty raw -F $GPS_DEVICE && echo \$GPS_START > $GPS_DEVICE
/usr/bin/mmcli -m 0 –location-enable-gps-unmanaged
  1. Make the script executable.
$ sudo chmod 755 /usr/sbin/cf20-init-gps.sh
  1. Edit /lib/systemd/system/gpsd.service and add a ExecStartPre command to the [Service] section. Also, add an After condition to the [Unit] section to change the startup order so that gpsd starts after multi-user.target. This will allow the modem to be available when the ExecStartPre script is executed.
[Unit]
Description=GPS (Global Positioning System) Daemon
Requires=gpsd.socket
# Needed with chrony SOCK refclock
After=chronyd.service
After=multi-user.target

[Service]
Type=forking
EnvironmentFile=/etc/default/gpsd
ExecStartPre=/usr/sbin/cf20-init-gps.sh
ExecStart=/usr/sbin/gpsd $GPSD_OPTIONS $OPTIONS $DEVICES

[Install]
WantedBy=multi-user.target
Also=gpsd.socket
  1. Enable the gpsd service and allow it to start on system startup.
$ sudo systemctl enable gpsd
$ sudo systemctl daemon-reload
$ sudo systemctl restart gpsd
  1. Test the GPS client.
$ gpsmon -n

Approach 2 - Obtain raw GPS without gpsd

This a manual approach for polling the GPS without using gpsd. It can be incorporated into a shell script to allow for on-demand polling.

The flow is as follows:

  1. Enable the GPS raw position output. NMEA is not needed.
  2. Grab the position. This should be executed in a loop until the GPS signal is acquired.
  3. Disable GPS to conserve the battery.
$ sudo mmcli -m 0 --enable
$ sudo mmcli -m 0 --location-enable-gps-raw
$ sudo mmcli -m 0 --location-get -J | jq '.modem.location.gps'
{
  "altitude": "707.400000",
  "latitude": "34.896579",
  "longitude": "-113.043081",
  "nmea": [],
  "utc": "171927.0"
}
$ sudo mmcli -m 0 --disable

Other useful GPS commands

$ gpscat /dev/ttyUSB2

Resources