如何读取ntptime状态码?

How to read the ntptime status code?

来自 NTP advanced configuration page 有以下文字

windl@elf:~ > ntptime
ntp_gettime() returns code 0 (OK)
  time bd6b9cf2.9c3c6c60  Thu, Sep 14 2000 20:52:34.610, (.610297702),
  maximum error 3480 us, estimated error 0 us.
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset 1.658 us, frequency 17.346 ppm, interval 128 s,
  maximum error 3480 us, estimated error 0 us,
  status 0x2107 (PLL,PPSFREQ,PPSTIME,PPSSIGNAL,NANO),
  time constant 6, precision 3.530 us, tolerance 496 ppm,
  pps frequency 17.346 ppm, stability 0.016 ppm, jitter 1.378 us,
  intervals 57, jitter exceeded 29, stability exceeded 0, errors 0.

其次是The first thing you should look at is the status (0x2107 in our case). The magic words in parentheses explain the meaning of the individual bits.

他们列出了 5 位位置,但提供了一个 4 位十六进制状态代码,可转换为 16 位。括号中代表关键字的位是哪些,其他位是什么意思?

这里是 NTP 状态代码列表

STA_PLL         0x0001  enable PLL updates (rw)
STA_PPSFREQ     0x0002  enable PPS freq discipline (rw)
STA_PPSTIME     0x0004  enable PPS time discipline (rw)
STA_FLL         0x0008  select frequency-lock mode (rw)

STA_INS         0x0010  insert leap (rw)
STA_DEL         0x0020  delete leap (rw)
STA_UNSYNC      0x0040  clock unsynchronized (rw)
STA_FREQHOLD    0x0080  hold frequency (rw)

STA_PPSSIGNAL   0x0100  PPS signal present (ro)
STA_PPSJITTER   0x0200  PPS signal jitter exceeded (ro)
STA_PPSWANDER   0x0400  PPS signal wander exceeded (ro)
STA_PPSERROR    0x0800  PPS signal calibration error (ro)

STA_CLOCKERR    0x1000  clock hardware fault (ro)
STA_NANO        0x2000  resolution (0 = us, 1 = ns) (ro)

来源:ftp://ftp.ripe.net/test-traffic/ROOT/libDelay/Delay.h

根据您列出的示例:status 0x2107 (PLL,PPSFREQ,PPSTIME,PPSSIGNAL,NANO)。 逻辑上 'OR' 状态位代码在一起 0x0001 | 0x0002 | 0x0004 | 0x0100 | 0x2000 结果为 0x2107.

可在此处找到状态代码的一些附加说明:
http://man7.org/linux/man-pages/man2/adjtimex.2.html