Changes between Version 19 and Version 20 of gps


Ignore:
Timestamp:
10/08/2021 09:35:53 PM (3 years ago)
Author:
Tim Harvey
Comment:

added gpsd section

Legend:

Unmodified
Added
Removed
Modified
  • gps

    v19 v20  
    575575Common use is to configure the Network Time Protocol Daemon (NTPD) with a PPS source to obtain a wallclock-time with sub-millisecond synchronization to UTC.
    576576
    577 The various Gateworks Board Support Packages includes PPS support (if a GPS is present). However, in order to hook NTPD with a PPS source, you have to have the fully featured ntpd package (i.e. not busybox). Below is an example of how to configure ntpd to use GPS and use PPS to keep syncronization:
    578 * Make sure you have the fully featured ntpd package via selecting ntpd in [wiki:OpenWrt/kernelconfig].
    579 * Run the following steps (This is on GW5400, please see proper /dev/ttyX for your device) [http://www.catb.org/gpsd/gpsd-time-service-howto.html GPSD Time Service]
    580 {{{#!bash
    581 $ killall -9 gpsd ntpd
    582 $ ntpd -gN
    583 $ sleep 2
    584 $ gpsd -n /dev/ttymxc4 # ttymxc4 for GW5400, might be different for different boards
    585 $ sleep 2
    586 $ cgps # not needed
    587 }}}
    588 * Note that cgps is part of the gpsd program. It is a "test client" for gpsd, though it shows very relevant information.
    589 * That's it! With gpsd and ntpd running, you have successfully configured your system time to come from GPS data.
    590 
     577The various Gateworks Board Support Packages includes PPS support (if a GPS is present). However, in order to hook NTPD with a PPS source, you have to have the fully featured ntpd package (i.e. not busybox).
     578
     579Note that the {{{gpsd}}} app will keep your NTP service syncrhonized to the time from a GPS:
     580 - see [#gpsd]
     581 - see https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html
    591582
    592583The PPS signal is also routed to a spare pin on the miniPCIe slots of many models:
     
    605596 - [http://lxr.linux.no/linux+v2.6.38.8/Documentation/ABI/testing/sysfs-pps Documentation/ABI/testing/sysfs-pps] - Linux sysfs pps class documentation (sysfs API for Userland apps to interface with PPS from LinuxPPS kernel support above)
    606597 - [http://lxr.linux.no/linux+v2.6.38.8/include/linux/pps.h include/linux/pps.h] - Linux ioctl pps documentation/support (ioctl API for Userland apps to interface with PPS from LinuxPPS kernel support above)
     598
     599
     600[=#gpsd]
     601= gpsd
     602gpsd is a service daemon that monitors one or more GPS devices via serial or USB making all the data on location/course/velocity available to be queried on a TCP port. There are multiple client applications that can connect to a gpsd server.
     603
     604Example:
     605 * Ubuntu Focal:
     606  1. Install apps
     607{{{#!bash
     608root@focal-venice:~# apt update
     609root@focal-venice:~# apt-get install gpsd gpsd-dbg gpsd-clients
     610}}}
     611  2. Configure gpsd via /etc/defaults/gpsd
     612{{{
     613root@focal-venice:~# cat /etc/default/gpsd
     614# Default settings for the gpsd init script and the hotplug wrapper.
     615
     616# Start the gpsd daemon automatically at boot time
     617START_DAEMON="true"
     618
     619# Use USB hotplugging to add new USB devices automatically to the daemon
     620USBAUTO="true"
     621
     622# Devices gpsd should collect to at boot time.
     623# They need to be read/writeable, either by user gpsd or the group dialout.
     624DEVICES=""
     625
     626# Other options you want to pass to gpsd
     627GPSD_OPTIONS=""
     628root@focal-venice:~# cat /etc/default/gpsd
     629root@focal-venice:~# sed -i 's;DEVICES="";DEVICES="/dev/ttymxc0";' /etc/default/gpsd
     630}}}
     631   * replace the above with the proper GPS device for your system - see [#uart]
     632  3. Restart the gpsd service
     633{{{#!bash
     634root@focal-venice:~# systemctl restart gpsd.socket
     635}}}
     636  4. Verify gpsd is listening:
     637{{{#!bash
     638root@focal-venice:~# netstat -a | grep gpsd
     639tcp        0      0 localhost:gpsd          0.0.0.0:*               LISTEN     
     640tcp6       0      0 localhost:gpsd          [::]:*                  LISTEN     
     641unix  2      [ ACC ]     STREAM     LISTENING     23508    /run/gpsd.sock
     642}}}
     643  4. Verify gpsd is working using one of its client apps, for example cgps which is a simple terminal client:
     644{{{#!bash
     645root@focal-venice:~# cgps
     646}}}
     647
     648
     649Troubleshooting:
     650 * you can run gpsd manually in foreground with the '-N' parameter and enable debugging with the '-D' parameter to see any errors. Make sure nothing is running that is listening to the gpsd port first
     651{{{#!bash
     652root@focal-venice:~# systemctl stop gpsd.socket
     653root@focal-venice:~# netstat -a | grep gps
     654root@focal-venice:~# gpsd -N -D3 /dev/ttymxc0
     655gpsd:INFO: launching (Version 3.21)
     656gpsd:INFO: listening on port gpsd
     657gpsd:INFO: stashing device /dev/ttymxc0 at slot 0
     658gpsd:INFO: running with effective group ID 20
     659gpsd:INFO: running with effective user ID 108
     660gpsd:INFO: startup at 2021-10-08T21:30:00.000Z (1633728600)
     661}}}
    607662
    608663