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 | | |
| 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). |
| 578 | |
| 579 | Note 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 |
| 598 | |
| 599 | |
| 600 | [=#gpsd] |
| 601 | = gpsd |
| 602 | gpsd 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 | |
| 604 | Example: |
| 605 | * Ubuntu Focal: |
| 606 | 1. Install apps |
| 607 | {{{#!bash |
| 608 | root@focal-venice:~# apt update |
| 609 | root@focal-venice:~# apt-get install gpsd gpsd-dbg gpsd-clients |
| 610 | }}} |
| 611 | 2. Configure gpsd via /etc/defaults/gpsd |
| 612 | {{{ |
| 613 | root@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 |
| 617 | START_DAEMON="true" |
| 618 | |
| 619 | # Use USB hotplugging to add new USB devices automatically to the daemon |
| 620 | USBAUTO="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. |
| 624 | DEVICES="" |
| 625 | |
| 626 | # Other options you want to pass to gpsd |
| 627 | GPSD_OPTIONS="" |
| 628 | root@focal-venice:~# cat /etc/default/gpsd |
| 629 | root@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 |
| 634 | root@focal-venice:~# systemctl restart gpsd.socket |
| 635 | }}} |
| 636 | 4. Verify gpsd is listening: |
| 637 | {{{#!bash |
| 638 | root@focal-venice:~# netstat -a | grep gpsd |
| 639 | tcp 0 0 localhost:gpsd 0.0.0.0:* LISTEN |
| 640 | tcp6 0 0 localhost:gpsd [::]:* LISTEN |
| 641 | unix 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 |
| 645 | root@focal-venice:~# cgps |
| 646 | }}} |
| 647 | |
| 648 | |
| 649 | Troubleshooting: |
| 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 |
| 652 | root@focal-venice:~# systemctl stop gpsd.socket |
| 653 | root@focal-venice:~# netstat -a | grep gps |
| 654 | root@focal-venice:~# gpsd -N -D3 /dev/ttymxc0 |
| 655 | gpsd:INFO: launching (Version 3.21) |
| 656 | gpsd:INFO: listening on port gpsd |
| 657 | gpsd:INFO: stashing device /dev/ttymxc0 at slot 0 |
| 658 | gpsd:INFO: running with effective group ID 20 |
| 659 | gpsd:INFO: running with effective user ID 108 |
| 660 | gpsd:INFO: startup at 2021-10-08T21:30:00.000Z (1633728600) |
| 661 | }}} |