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
- Install
gpsdpackages.
$ sudo apt install gpsd gpsd-clients -y- Edit
/etc/default/gpsd.
START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyUSB2"
GPSD_OPTIONS="-n"- Create a pre-exec script for
gpsdcalled/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- Make the script executable.
$ sudo chmod 755 /usr/sbin/cf20-init-gps.sh- Edit
/lib/systemd/system/gpsd.serviceand add aExecStartPrecommand to the[Service]section. Also, add anAftercondition to the[Unit]section to change the startup order so thatgpsdstarts aftermulti-user.target. This will allow the modem to be available when theExecStartPrescript 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- Enable the
gpsdservice and allow it to start on system startup.
$ sudo systemctl enable gpsd
$ sudo systemctl daemon-reload
$ sudo systemctl restart gpsd- Test the GPS client.
$ gpsmon -nApproach 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:
- Enable the GPS raw position output. NMEA is not needed.
- Grab the position. This should be executed in a loop until the GPS signal is acquired.
- 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 --disableOther useful GPS commands
$ gpscat /dev/ttyUSB2