The Adafruit GPS HAT supports an NMEA command, $CDCMD,33,1, which provides reports on the status of the GPS module's antenna connection.
I'd like to issue this command when my Pi's GPS daemon starts up. Can I configure that somehow in the /etc/default/gpsd config file? By some other means?
If I shut down gpsd I can use `minicom` to send this command and see that it works. But I'd like this to be automatic, without having to stop gpsd, send the command, then start gpsd again.
How can I send an NMEA command, by default, to GPS HAT when gpsd starts?
Moderators: adafruit_support_bill, adafruit
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
- kshetline
- Posts: 9
- Joined: Wed Apr 01, 2020 3:00 pm
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: How can I send an NMEA command, by default, to GPS HAT when gpsd starts?
Good question.
I think you have a few options.
1) If you have install the gpsd-clients package as the guide suggests it provides some tools to communicate directly with the daemon so you do not need to stop / start it.
https://learn.adafruit.com/adafruit-ult ... sd-1723492
2) The easiest tool included would be the recommend cgps. Which is a curses based summary of connection status.
3) There is also a `gpsctl` utility which can talk to GPSD which might be more what you are looking for. You could add the command to /etc/rc.local for startup.
4) You can also generate a report by running gps_test.py example provided after install the gps python package
https://learn.adafruit.com/adafruit-ult ... ut-1723503
I think you have a few options.
1) If you have install the gpsd-clients package as the guide suggests it provides some tools to communicate directly with the daemon so you do not need to stop / start it.
https://learn.adafruit.com/adafruit-ult ... sd-1723492
2) The easiest tool included would be the recommend cgps. Which is a curses based summary of connection status.
Code: Select all
cgps -s
4) You can also generate a report by running gps_test.py example provided after install the gps python package
Code: Select all
pip3 install gps
gps_test.py
Code: Select all
import gps
# Listen on port 2947 (gpsd) of localhost
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
while True:
try:
report = session.next()
# Wait for a 'TPV' report and display the current time
# To see all report data, uncomment the line below
# print(report)
if report['class'] == 'TPV':
if hasattr(report, 'time'):
print(report.time)
except KeyError:
pass
except KeyboardInterrupt:
quit()
except StopIteration:
session = None
print("GPSD has terminated")
- kshetline
- Posts: 9
- Joined: Wed Apr 01, 2020 3:00 pm
Re: How can I send an NMEA command, by default, to GPS HAT when gpsd starts?
I had been hoping that gpsctl would do the trick, but when I try this:mikeysklar wrote: ↑Wed Sep 14, 2022 5:48 pm 3) There is also a `gpsctl` utility which can talk to GPSD which might be more what you are looking for. You could add the command to /etc/rc.local for startup.
Code: Select all
gpsctl -x "\$CDCMD,33,1*7C\r\n"
Code: Select all
gpsctl:ERROR: SER: device open of /dev/serial0 failed: Device or resource busy - retrying read-only
gpsctl:ERROR: SER: read-only device open of /dev/serial0 failed: Device or resource busy
gpsctl:ERROR: initial GPS device /dev/serial0 open failed
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: How can I send an NMEA command, by default, to GPS HAT when gpsd starts?
What serial device is your Ultimate GPS showing up on? I don't think it would be /dev/serial0 today. You can check the output of `dmesg` if you are not sure. My guess is your are using /dev/ttyUSB0
You might need to specify the serial port to help gpsctl.
What happens when you run:
If that works then you can go back to adding the -x <NMEA command> <serialport>
You might need to specify the serial port to help gpsctl.
What happens when you run:
Code: Select all
gpsctl /dev/ttyUSB0
- kshetline
- Posts: 9
- Joined: Wed Apr 01, 2020 3:00 pm
Re: How can I send an NMEA command, by default, to GPS HAT when gpsd starts?
mikeysklar wrote: ↑Thu Sep 15, 2022 4:47 pm What happens when you run:
Code: Select all
gpsctl /dev/ttyUSB0
Code: Select all
pi@clock:~ $ gpsctl /dev/ttyUSB0
gpsctl:ERROR: specified device not found in device list.
pi@clock:~ $ gpsctl /dev/serial0
/dev/serial0 identified as a MTK-3301 AXN_5.1.6_3333_18041700-0005 at 9600 baud.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: How can I send an NMEA command, by default, to GPS HAT when gpsd starts?
My bad about this being a HAT vs USB based Ultimate GPS.
We should be able to resolve this quickly.
Are you able to access /dev/serial0? Maybe sudo? To see the raw data?
If so, does gpsctl work with this command, rather than write a NMEA command?
We should be able to resolve this quickly.
Are you able to access /dev/serial0? Maybe sudo? To see the raw data?
Code: Select all
cat /dev/serial0
Code: Select all
$ gpsctl -Q fix
Time (UTC): 2019-04-18 15:31:27 (yyyy-mm-dd hh:mm:ss)
Latitude: 52.05994980 N
Longitude: 2.72698960 W
Altitude: 198.789 feet
Motion: 0.338 mph at 53.114 degrees heading
Satellites: 5 used for computing this fix
Accuracy: time (39 ns), height (+/-18.199 feet), position (+/-103.911 feet), heading(+/-8.230 degrees), speed(+/-0.132 mph)
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/