gpsdとchronyを使用すると、1秒あたりのパルスはありません。

gpsdとchronyを使用すると、1秒あたりのパルスはありません。

この答えからインスピレーションを得ました。https://askubuntu.com/a/1374637毎秒パルスなしでGPSDから時間を取得するためにクロニーを取得しようとしています。

わかりましたhttps://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.htmlつまり、毎秒1パルスが必要です。

1PPS(1秒あたり1パルス)出力を提供するGPSD、NTP、およびGPS受信機を使用して、高品質のNTPタイムサーバーを構築できます。

私が知っている限り、1秒あたりのパルスがないと、9600ボードのシリアル接続と(Linux)オペレーティングシステムで発生するジッタが原因で時間が遅れます。

+/- 1秒の正確な時間が許可されます。

元の回答の行を追加しました(シリアルポートの変更)。

refclock SHM 0 refid GPS precision 1e-1 offset 0 delay 0 stratum 2
refclock SOCK /var/run/chrony.ttymxc0.sock refid PPS

/etc/chrony.confへ。

それからフロントデスクで時計を始めました。報告される内容は次のとおりです。

root@imx6ul-var-dart:~# chronyd -d
2022-09-08T09:27:25Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC -PRIVDROP -SCFILTER -SIGND +ASYNCDNS -SECHASH +IPV6 -DEBUG)
2022-09-08T09:27:25Z Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift

ソケットを作成します。

root@imx6ul-var-dart:~# ls -lA /run/chrony.ttymxc2.sock 
srwxr-xr-x 1 root root 0 Sep  8 09:27 /run/chrony.ttymxc2.sock

次に、フォアグラウンドでgpsdを実行します。

root@imx6ul-var-dart:~# gpsd -N -D3 -F /run/gpsd.sock /dev/ttymxc2
gpsd:WARN: This system has a 32-bit time_t.  This gpsd will fail at 2038-01-19T03:14:07Z.
gpsd:INFO: launching (Version 3.23)
gpsd:INFO: listening on port gpsd
gpsd:INFO: stashing device /dev/ttymxc2 at slot 0
gpsd:INFO: running with effective group ID 20
gpsd:INFO: running with effective user ID 65534
gpsd:INFO: startup at 2022-09-08T09:37:52.000Z (1662629872)
gpsd:CLIENT: => client(0): {"class":"VERSION","release":"3.23","rev":"3.23","proto_major":3,"proto_minor":14}\x0d\x0a
gpsd:CLIENT: <= client(0): ?WATCH={"enable":true,"json":true};\x0a
gpsd:INFO: SER: opening GPS data source type 2 at '/dev/ttymxc2'
gpsd:INFO: SER: speed 9600, 8N1
gpsd:INFO: SER: speed 9600, 8O1
gpsd:INFO: SER: speed 9600, 8N1
gpsd:INFO: SER: speed 9600, 8N1
gpsd:INFO: SER: speed 9600, 8N1
gpsd:INFO: gpsd_activate(2): activated GPS (fd 8)
gpsd:CLIENT: => client(0): {"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttymxc2","activated":"2022-09-08T09:38:02.070Z","native":0,"bps":9600,"parity":"N","stopbits":1,"cycle":1.00}]}\x0d\x0a{"class":"WATCH","enable":true,"json":true,"nmea":false,"raw":0,"scaled":false,"timing":false,"split24":false,"pps":false}\x0d\x0a
gpsd:INFO: /dev/ttymxc2 identified as type NMEA0183, 0 sec @ 9600bps
gpsd:CLIENT: => client(0): {"class":"DEVICE","path":"/dev/ttymxc2","driver":"NMEA0183","activated":"2022-09-08T09:38:02.073Z","native":0,"bps":9600,"parity":"N","stopbits":1,"cycle":1.00}\x0d\x0a
gpsd:WARN: NMEA0183: xxGSV field 3 value of 11 != actual count 7
gpsd:INFO: Sats used (0):
gpsd:CLIENT: => client(0): {"class":"SKY","device":"/dev/ttymxc2","nSat":7,"uSat":0,"satellites":[{"PRN":14,"el":27.0,"az":272.0,"ss":11.0,"used":false,"gnssid":0,"svid":14},{"PRN":17,"el":31.0,"az":309.0,"ss":32.0,"used":false,"gnssid":0,"svid":17},{"PRN":19,"el":3.0,"az":316.0,"ss":0.0,"used":false,"gnssid":0,"svid":19},{"PRN":21,"el":70.0,"az":96.0,"ss":13.0,"used":false,"gnssid":0,"svid":21},{"PRN":22,"el":38.0,"az":89.0,"ss":28.0,"used":false,"gnssid":0,"svid":22},{"PRN":24,"el":0.0,"az":357.0,"ss":0.0,"used":false,"gnssid":0,"svid":24},{"PRN":32,"el":31.0,"az":57.0,"ss":41.0,"used":false,"gnssid":0,"svid":32}]}\x0d\x0a
gpsd:WARN: NMEA0183: malformed GPGSV - fieldcount 18 % 4 != 0
gpsd:WARN: NMEA0183: xxGSV field 3 value of 9 != actual count 5
gpsd:INFO: Sats used (0):
gpsd:CLIENT: => client(0): {"class":"SKY","device":"/dev/ttymxc2","nSat":5,"uSat":0,"satellites":[{"PRN":76,"el":16.0,"az":340.0,"ss":33.0,"used":false,"gnssid":6,"svid":12},{"PRN":77,"el":0.0,"az":23.0,"ss":0.0,"used":false,"gnssid":6,"svid":13},{"PRN":83,"el":20.0,"az":115.0,"ss":9.0,"used":false,"gnssid":6,"svid":19},{"PRN":84,"el":77.0,"az":58.0,"ss":22.0,"used":false,"gnssid":6,"svid":20},{"PRN":85,"el":30.0,"az":309.0,"ss":29.0,"used":false,"gnssid":6,"svid":21}]}\x0d\x0a
gpsd:WARN: NMEA0183: can't use GLL time until after ZDA or RMC has supplied a year.
gpsd:CLIENT: => client(0): {"class":"TPV","device":"/dev/ttymxc2","mode":2,"lat":53.232661333,"lon":-2.098090167,"magvar":-1.0}\x0d\x0a
gpsd:INFO: PRN  1 az 309.0 el 80.0 (-0.134950,  0.109280,  0.984808)
gpsd:INFO: PRN  3 az 220.0 el 49.0 (-0.421707, -0.502570,  0.754710)
gpsd:INFO: PRN  8 az 161.0 el 31.0 ( 0.279066, -0.810468,  0.515038)
gpsd:INFO: PRN 14 az 272.0 el 27.0 (-0.890464,  0.031096,  0.453990)
gpsd:INFO: PRN 17 az 309.0 el 31.0 (-0.666144,  0.539433,  0.515038)
gpsd:INFO: PRN 21 az  96.0 el 70.0 ( 0.340147, -0.035751,  0.939693)
gpsd:INFO: PRN 22 az  89.0 el 38.0 ( 0.787891,  0.013753,  0.615661)
gpsd:INFO: PRN 32 az  57.0 el 31.0 ( 0.718881,  0.466847,  0.515038)
gpsd:INFO: Sats used (8):
gpsd:CLIENT: => client(0): {"class":"SKY","device":"/dev/ttymxc2","xdop":0.61,"ydop":0.84,"vdop":1.36,"tdop":1.27,"hdop":0.88,"gdop":2.47,"pdop":1.62,"nSat":11,"uSat":8,"satellites":[{"PRN":1,"el":80.0,"az":309.0,"ss":32.0,"used":true,"gnssid":0,"svid":1},{"PRN":3,"el":49.0,"az":220.0,"ss":12.0,"used":true,"gnssid":0,"svid":3},{"PRN":8,"el":31.0,"az":161.0,"ss":20.0,"used":true,"gnssid":0,"svid":8},{"PRN":10,"el":2.0,"az":53.0,"ss":14.0,"used":false,"gnssid":0,"svid":10},{"PRN":14,"el":27.0,"az":272.0,"ss":8.0,"used":true,"gnssid":0,"svid":14},{"PRN":17,"el":31.0,"az":309.0,"ss":32.0,"used":true,"gnssid":0,"svid":17},{"PRN":19,"el":3.0,"az":316.0,"ss":0.0,"used":false,"gnssid":0,"svid":19},{"PRN":21,"el":70.0,"az":96.0,"ss":14.0,"used":true,"gnssid":0,"svid":21},{"PRN":22,"el":38.0,"az":89.0,"ss":28.0,"used":true,"gnssid":0,"svid":22},{"PRN":24,"el":0.0,"az":357.0,"ss":0.0,"used":false,"gnssid":0,"svid":24},{"PRN":32,"el":31.0,"az":57.0,"ss":41.0,"used":true,"gnssid":0,"svid":32}]}\x0d\x0a
gpsd:INFO: PRN  1 az 309.0 el 80.0 (-0.134950,  0.109280,  0.984808)
gpsd:INFO: PRN  3 az 220.0 el 49.0 (-0.421707, -0.502570,  0.754710)
gpsd:INFO: PRN  8 az 161.0 el 31.0 ( 0.279066, -0.810468,  0.515038)
gpsd:INFO: PRN 14 az 272.0 el 27.0 (-0.890464,  0.031096,  0.453990)
gpsd:INFO: PRN 17 az 309.0 el 31.0 (-0.666144,  0.539433,  0.515038)
gpsd:INFO: PRN 21 az  96.0 el 70.0 ( 0.340147, -0.035751,  0.939693)
gpsd:INFO: PRN 22 az  89.0 el 38.0 ( 0.787891,  0.013753,  0.615661)
gpsd:INFO: PRN 32 az  57.0 el 31.0 ( 0.718881,  0.466847,  0.515038)
gpsd:INFO: PRN 68 az  44.0 el 44.0 ( 0.499695,  0.517450,  0.694658)
gpsd:INFO: PRN 75 az 285.0 el 14.0 (-0.937234,  0.251131,  0.241922)
gpsd:INFO: PRN 76 az 340.0 el 16.0 (-0.328771,  0.903291,  0.275637)
gpsd:INFO: PRN 83 az 115.0 el 20.0 ( 0.851651, -0.397131,  0.342020)
gpsd:INFO: PRN 84 az  58.0 el 77.0 ( 0.190769,  0.119206,  0.974370)
gpsd:INFO: PRN 85 az 309.0 el 30.0 (-0.673028,  0.545007,  0.500000)
gpsd:INFO: Sats used (14):
gpsd:CLIENT: => client(0): {"class":"SKY","device":"/dev/ttymxc2","xdop":0.46,"ydop":0.62,"vdop":1.36,"tdop":0.77,"hdop":0.88,"gdop":1.60,"pdop":1.62,"nSat":20,"uSat":14,"satellites":[{"PRN":1,"el":80.0,"az":309.0,"ss":32.0,"used":true,"gnssid":0,"svid":1},{"PRN":3,"el":49.0,"az":220.0,"ss":12.0,"used":true,"gnssid":0,"svid":3},{"PRN":8,"el":31.0,"az":161.0,"ss":20.0,"used":true,"gnssid":0,"svid":8},{"PRN":10,"el":2.0,"az":53.0,"ss":14.0,"used":false,"gnssid":0,"svid":10},{"PRN":14,"el":27.0,"az":272.0,"ss":8.0,"used":true,"gnssid":0,"svid":14},{"PRN":17,"el":31.0,"az":309.0,"ss":32.0,"used":true,"gnssid":0,"svid":17},{"PRN":19,"el":3.0,"az":316.0,"ss":0.0,"used":false,"gnssid":0,"svid":19},{"PRN":21,"el":70.0,"az":96.0,"ss":14.0,"used":true,"gnssid":0,"svid":21},{"PRN":22,"el":38.0,"az":89.0,"ss":28.0,"used":true,"gnssid":0,"svid":22},{"PRN":24,"el":0.0,"az":357.0,"ss":0.0,"used":false,"gnssid":0,"svid":24},{"PRN":32,"el":31.0,"az":57.0,"ss":41.0,"used":true,"gnssid":0,"svid":32},{"PRN":68,"el":44.0,"az":44.0,"ss":30.0,"used":true,"gnssid":6,"svid":4},{"PRN":69,"el":64.0,"az":144.0,"ss":0.0,"used":false,"gnssid":6,"svid":5},{"PRN":70,"el":12.0,"az":193.0,"ss":0.0,"used":false,"gnssid":6,"svid":6},{"PRN":75,"el":14.0,"az":285.0,"ss":28.0,"used":true,"gnssid":6,"svid":11},{"PRN":76,"el":16.0,"az":340.0,"ss":34.0,"used":true,"gnssid":6,"svid":12},{"PRN":77,"el":0.0,"az":23.0,"ss":0.0,"used":false,"gnssid":6,"svid":13},{"PRN":83,"el":20.0,"az":115.0,"ss":9.0,"used":true,"gnssid":6,"svid":19},{"PRN":84,"el":77.0,"az":58.0,"ss":22.0,"used":true,"gnssid":6,"svid":20},{"PRN":85,"el":30.0,"az":309.0,"ss":29.0,"used":true,"gnssid":6,"svid":21}]}\x0d\x0a
gpsd:CLIENT: => client(0): {"class":"TPV","device":"/dev/ttymxc2","mode":3,"time":"2022-09-08T09:20:35.000Z","ept":0.005,"lat":53.232662500,"lon":-2.098090333,"altHAE":84.6000,"altMSL":36.4000,"alt":36.4000,"epx":6.970,"epy":9.328,"epv":31.280,"magvar":-1.0,"speed":0.026,"geoidSep":48.200,"eph":16.720,"sep":30.780}\x0d\x0a

-D6を使用しても/run/chrony.ttymxc2.sockへの言及はありません。

gpsdは/run/chrony.ttymxc2.sockが存在するかどうかを確認しないようです。

chronycでは次のことがわかります。

root@imx6ul-var-dart:~# chronyc -n sources
210 Number of sources = 2
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
#? GPS                           0   4     0     -     +0ns[   +0ns] +/-    0ns
#? PPS                           0   4     0     -     +0ns[   +0ns] +/-    0ns

余談:私はgpsdがchronyソケットの名前をどのように知っているか理解していませんが、gpsdは明示的にchronyをサポートしているようです。 (これは消費者を列挙するデータソースの奇妙なデザインですが、gpsdは一流のプロジェクトなので、ここには妥当な理由があると確信しています。)

root@imx6ul-var-dart:~# strings /usr/sbin/gpsd | grep chrony
accepted chrony sock
PPS chrony_send %s @ %s Offset: %0.9f
/run/chrony.%s.sock
/tmp/chrony.%s.sock
PPS:%s chrony socket %s doesn't exist
PPS:%s connect chrony socket failed: %s, error: %d, errno: %d/%s
PPS:%s using chrony socket: %s

また、次のような慢性的な設定を試しましたが、成功しませんでした。

refclock SOCK /var/run/chrony.ttymxc2.sock refid GPS precision 1e-1 offset 0 delay 0 stratum 2
refclock SOCK /var/run/chrony.ttymxc2.sock refid PPS      

refclock SHM 0 offset 0.5 delay 0.2 refid NMEA

refclock SOCK /var/run/chrony.ttymxc2.sock refid GPS precision 1e-1 offset 0 delay 0

refclock SHM 0 offset 0.0 delay 0.2                                  
refclock SHM 1 offset 0.0 delay 0.0  

毎秒パルスなしで時間を提供するためにgpsdを使用できますか?

それでは、構成は何ですか?

ベストアンサー1

このディレクティブとともに単独で使用する必要がありますrefclock SHM 0SHM 1そしてSOCKPPSでのみ利用可能です。

gpsd ログには GPRMC メッセージの欠落に関するヒントがあります。 gpsdがSHM 0にサンプルを書き込むことができるように、完全な時間と日付を含むメッセージを送信するようにリスナーを構成する必要があります。

GPRMCやその他のメッセージを有効にするコマンドは、リスナーのマニュアルに記載されている必要があります。ベンダーから構成ユーティリティを提供することもできます。たとえば、u-blox レシーバーには u-center があります。

おすすめ記事