gpsd 및 chrony를 사용하면 초당 펄스가 없습니다.

gpsd 및 chrony를 사용하면 초당 펄스가 없습니다.

이 답변에서 영감을 얻었습니다.https://askubuntu.com/a/1374637초당 펄스 없이 GPSD에서 시간을 얻기 위해 크로니를 얻으려고 합니다.

알아요https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html즉, 초당 하나의 펄스가 필요합니다.

1PPS(초당 1펄스) 출력을 제공하는 GPSD, NTP 및 GPS 수신기를 사용하여 고품질 NTP 시간 서버를 구축할 수 있습니다.

내가 아는 한, 초당 펄스가 없으면 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 0. SHM 1그리고 SOCKPPS에만 사용할 수 있습니다.

gpsd 로그에는 GPRMC 메시지 누락에 대한 힌트가 있습니다. gpsd가 SHM 0에 샘플을 쓸 수 있도록 전체 시간과 날짜가 포함된 메시지를 보내도록 수신기를 구성해야 합니다.

GPRMC 및 기타 메시지를 활성화하는 명령이 수신기 설명서에 있어야 합니다. 공급업체에서 구성 유틸리티를 제공할 수도 있습니다. 예를 들어, u-blox 수신기에는 u-center가 있습니다.

답변2

James Browning은 gpsd 메일링 리스트에 솔루션을 제공했습니다:

아름다운 문서를 제대로 읽는 사람은 아무도 없습니다(심지어 나조차도).

refclock SHM 0 poll 3 refid gps1
pool pool.ntp.org maxsources=3

driftfile /var/db/chrony/chrony.drift
bindcmdaddress /var/run/chrony/chrony.sock
rtcsync

크로니의 좋은 출발점입니다.

"pool" 줄은 chronyd에서 구문 분석되지 않았기 때문에 제거해야 했습니다.

관련 정보