diff --git a/config_d/registers b/config_d/registers index 09c466a..25d51ae 100755 --- a/config_d/registers +++ b/config_d/registers @@ -42,7 +42,7 @@ BLOCKS_COMPAT_VERSION = 0 # Hardware timestamps PCAP_TS_SEC 10 - PCAP_TS_NSEC 11 + PCAP_TS_TICKS 11 # Position capture control PCAP_ARM 13 diff --git a/server/data_server.c b/server/data_server.c index 469ac54..34ab322 100644 --- a/server/data_server.c +++ b/server/data_server.c @@ -122,11 +122,9 @@ static void update_start_timestamp(void) pcap_start_ts = pcap_drv_start_ts; pcap_hw_ts_offset_ns_valid = false; } else { - int64_t drv_ts_num = - (int64_t) pcap_drv_start_ts.tv_sec * 1000000000 + int64_t drv_ts_num = (int64_t) pcap_drv_start_ts.tv_sec * NSECS + pcap_drv_start_ts.tv_nsec; - int64_t hw_ts_num = - (int64_t) pcap_hw_start_ts.tv_sec * 1000000000 + int64_t hw_ts_num = (int64_t) pcap_hw_start_ts.tv_sec * NSECS + pcap_hw_start_ts.tv_nsec; pcap_start_ts = pcap_hw_start_ts; pcap_hw_ts_offset_ns = drv_ts_num - hw_ts_num; diff --git a/server/hardware.c b/server/hardware.c index 251c5e8..ff5799d 100644 --- a/server/hardware.c +++ b/server/hardware.c @@ -328,7 +328,10 @@ void hw_get_start_ts(struct timespec *ts) void hw_get_hw_start_ts(struct timespec *ts) { ts->tv_sec = (time_t) read_named_register(PCAP_TS_SEC); - ts->tv_nsec = (typeof(ts->tv_nsec)) read_named_register(PCAP_TS_NSEC); + ts->tv_nsec = (typeof(ts->tv_nsec)) ((double) + read_named_register(PCAP_TS_TICKS) * NSECS / hw_read_nominal_clock()); + ts->tv_sec = ts->tv_nsec / NSECS; + ts->tv_nsec = ts->tv_nsec % NSECS; } #endif