Projet: Fonctions python pour récupérer l’erreur PPM calculé par ntp entre une pps et le quartz local.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
class TimevalStruct(Structure): _fields_ = [ ("tv_sec", c_long), ("tv_usec", c_long), ] class TimexStruct(Structure): _fields_ = [ ("modes", c_int), ("offset", c_long), ("freq", c_long), ("maxerror", c_long), ("esterror", c_long), ("status", c_int), ("constant", c_long), ("precision", c_long), ("tolerance", c_long), ("time", TimevalStruct), ("tick", c_long), ("ppsfreq", c_long), ("jitter", c_long), ("shift", c_int), ("stabil", c_long), ("jitcnt", c_long), ("calcnt", c_long), ("errcnt", c_long), ("stbcnt", c_long), ("tai", c_int), ] libc = cdll.LoadLibrary(find_library("c")) timex = TimexStruct() p_timex = pointer(timex) def ntp_adjtime(): libc.ntp_adjtime(p_timex) return p_timex.contents def getppm(): adjtime = ntp_adjtime() return adjtime.freq/(1 << 16) |