Home › Forums › Forums › Technical Support for BerryGPS and BerryGPS-IMU › GPS settings are _not_ persistent!!! › Reply To: GPS settings are _not_ persistent!!!
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:
- 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
- Make script executable: sudo chmod u+x /path/to/script/gps_config.sh
- 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
- Set privileges: sudo chmod 644 /etc/systemd/system/gps_config.service
- Enable service: sudo systemctl enable gps_config.service
- Copy /lib/systemd/system/gpsd.service to /etc/systemd/system
- 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.