Reply To: GPS settings are _not_ persistent!!!

Home Forums Forums Technical Support for BerryGPS and BerryGPS-IMU GPS settings are _not_ persistent!!! Reply To: GPS settings are _not_ persistent!!!

#17053
Michael Sacarny
Participant

Mark,

I'll outline it here, but an easier alternative would have been if gpsctl worked as stated. Although the -s command changes gps baud rate, I could never get the -c command to change sampling rate. Any help on tracking down that problem would be worthwhile, as that would result in a simpler, cleaner scripting solution.

What I ended up doing is letting gpsd boot up at start time as is the usual case. However, I make sure a gps configuration service runs first:

  1. Create gps_config.sh shell script to set gps baud and sample rates:

<p style="margin-left: 40px;">#!/bin/bash
stty -F /dev/serial0 9600
echo -e -n "\xB5\x62\x06\x08\x06\x00\xC8\x00\x01\x00\x01\x00\xDE\x6A" > /dev/serial0
echo -e -n "\xB5\x62\x06\x00\x14\x00\x01\x00\x00\x00\xD0\x08\x00\x00\x00\xE1\x00\x00\x07\x00\x03\x00\x00\x00\x00\x00\xDE\xC9" > /dev/serial0
stty -F /dev/serial0 57600

  1. Make script executable: sudo chmod u+x /path/to/script/gps_config.sh
  2. Create a gps_config.service file in /etc/systemd/system as follows:

<p style="margin-left: 40px;">[Unit]
Description=Configures gps sampling and baud rate for gpsd service.
[Service]
Type=simple
ExecStart=/bin/bash /path/to/script/gps_config.sh
[Install]
WantedBy=multi-user.target

  1. Set privileges: sudo chmod 644 /etc/systemd/system/gps_config.service
  2. Enable service: sudo systemctl enable gps_config.service
  3. Copy /lib/systemd/system/gpsd.service to /etc/systemd/system
  4. Edit /lib/systemd/system/gpsd.service:
    Add to [Unit] section: After=gps_config.service

After reboot, gpsd will start after gps has been configured. PPS synchronizes ntp as expected and gpsd clients are serviced as usual.

Blip, blop, bloop...