RaspberryPI + GPS + NTP 動作確認コマンド

## 確認系のコマンド
### GPSの起動と確認
- gpsd /dev/ttyAMA0 -n -F /var/run/gpsd.sock
- cgps -s

```
掴んでいる衛星の数などが表示される
║    Time:       2016-08-06T06:49:37.000Z   ║║PRN:   Elev:  Azim:  SNR:  Used: ║
║    Latitude:    35.       N               ║║  65    46    184    20      Y   ║
║    Longitude:  139.       E               ║║  71    21    031    00      Y   ║
║    Altitude:   58.8 m                     ║║  72    68    071    00      N   ║
║    Speed:      0.2 kph                    ║║  77    04    241    00      N   ║
║    Heading:    0.0 deg (true)             ║║  78    13    291    00      N   ║
║    Climb:      0.0 m/min                  ║║  79    06    330    00      N   ║
║    Status:     3D FIX (7 secs)            ║║  86    25    102    16      N   ║
║    Longitude Err:   n/a                   ║║  87    60    032    00      N   ║
║    Latitude Err:    n/a                   ║║  88    31    325    00      N   ║
║    Altitude Err:    +/- 46 m              ║║                                 ║
║    Course Err:      n/a                   ║║                                 ║
║    Speed Err:       n/a                   ║║                                 ║
║    Time offset:     0.745                 ║║                                 ║
```
- killall gpsd (動作確認のためだけなので）

### ntpdの動作確認
- PPSの動作を確認する

```
# cat /etc/modules 
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
pps-gpio  << pps-gpio がロードされることを確認

# ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1470466087.999157683, sequence: 272511 - clear  0.000000000, sequence: 0
source 0 - assert 1470466088.999161067, sequence: 272512 - clear  0.000000000, sequence: 0
source 0 - assert 1470466089.999163435, sequence: 272513 - clear  0.000000000, sequence: 0
```

- config を確認

```
# cat /etc/ntp.conf 
~~
server ntp.nict.jp iburst prefer  << PPSを使う場合基準時間の参照先 prefer の設定が必要
server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0 flag3 1 refid PPS
~~

```
- 動作確認

```
# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 PPS(0)          .PPS.            0 l    -   16    0    0.000    0.000   0.000
*ntp-a3.nict.go. .NICT.           1 u    -   64    1    5.696  109.951   2.323
 
# ntpq -c rv
associd=0 status=0115 leap_none, sync_pps, 1 event, clock_sync,
version="ntpd 4.2.8p3-RC1@1.3265-o Sun May 31 10:04:59 UTC 2015 (1)",
processor="armv6l", system="Linux/4.1.19+", leap=00, stratum=1,
precision=-18, rootdelay=0.000, rootdisp=8048.425, refid=PPS,
reftime=db500c70.26574bc5  Sat, Aug  6 2016 16:12:48.149,
clock=db500c71.e36d3c1e  Sat, Aug  6 2016 16:12:49.888, peer=53328, tc=4,
mintc=3, offset=110.674804, frequency=-19.973, sys_jitter=0.003815,
clk_jitter=34.903, clk_wander=0.000

stratum=1  << PPS参照のため
offset=110.674804  << 110msecのズレを表す、NTPDを起動した直後ではoffset幅が大きいが、しばらくすると収束する。
5分位経つと、以下のように 30μsec 程度まで縮まった。

# ntpq -c rv
associd=0 status=0115 leap_none, sync_pps, 1 event, clock_sync,
version="ntpd 4.2.8p3-RC1@1.3265-o Sun May 31 10:04:59 UTC 2015 (1)",
processor="armv6l", system="Linux/4.1.19+", leap=00, stratum=1,
precision=-18, rootdelay=0.000, rootdisp=1.225, refid=PPS,
reftime=db500dd0.264b3e58  Sat, Aug  6 2016 16:18:40.149,
clock=db500ddf.d6defe38  Sat, Aug  6 2016 16:18:55.839, peer=53328, tc=4,
mintc=3, offset=0.035973, frequency=-19.183, sys_jitter=0.125790,
clk_jitter=9.062, clk_wander=0.157
```