mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
fix(fronthaul): Fix UTC-to-GPS timestamp conversion
Add missing leap second offsert for UTC-to-GPS coversion. Signed-off-by: Bartosz Podrygajlo <bartosz.podrygajlo@openairinterface.org>
This commit is contained in:
@@ -18,7 +18,7 @@ static uint64_t get_gps_ns(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
return ((uint64_t)ts.tv_sec - GPS_EPOCH_OFFSET_UNIX) * NS_PER_SEC + ts.tv_nsec;
|
||||
return ((uint64_t)ts.tv_sec - GPS_EPOCH_OFFSET_UNIX + GPS_LEAP_SECONDS) * NS_PER_SEC + ts.tv_nsec;
|
||||
}
|
||||
|
||||
void fh_timer_tick(fh_timer_t *timer)
|
||||
|
||||
@@ -23,6 +23,7 @@ typedef void (*fh_timer_cb)(uint64_t s_abs, void *user_data);
|
||||
|
||||
#define MAX_FH_TIMER_CBS 8
|
||||
#define GPS_EPOCH_OFFSET_UNIX 315964800ULL
|
||||
#define GPS_LEAP_SECONDS 18
|
||||
|
||||
typedef struct {
|
||||
fh_timer_cb fn;
|
||||
|
||||
@@ -25,7 +25,7 @@ static uint64_t get_gps_ns(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
return ((uint64_t)ts.tv_sec - GPS_EPOCH_OFFSET_UNIX) * NS_PER_SEC + ts.tv_nsec;
|
||||
return ((uint64_t)ts.tv_sec - GPS_EPOCH_OFFSET_UNIX + GPS_LEAP_SECONDS) * NS_PER_SEC + ts.tv_nsec;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -19,7 +19,7 @@ static uint64_t get_gps_ns(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
return ((uint64_t)ts.tv_sec - GPS_EPOCH_OFFSET_UNIX) * NS_PER_SEC + ts.tv_nsec;
|
||||
return ((uint64_t)ts.tv_sec - GPS_EPOCH_OFFSET_UNIX + GPS_LEAP_SECONDS) * NS_PER_SEC + ts.tv_nsec;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -20,7 +20,7 @@ static uint64_t get_gps_ns(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
return ((uint64_t)ts.tv_sec - GPS_EPOCH_OFFSET_UNIX) * NS_PER_SEC + ts.tv_nsec;
|
||||
return ((uint64_t)ts.tv_sec - GPS_EPOCH_OFFSET_UNIX + GPS_LEAP_SECONDS) * NS_PER_SEC + ts.tv_nsec;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -255,7 +255,7 @@ int oru_fh_get_utc_anchor_point(void *handle, uint32_t *frame, uint32_t *slot, s
|
||||
uint64_t total_syms_per_sec = (NR_SYMBOLS_PER_SLOT * 1000) << fh->cfg.numerology;
|
||||
uint64_t ns_per_symbol = 1000000000 / total_syms_per_sec;
|
||||
uint64_t leftover_syms = absolute_gps_symbol % total_syms_per_sec;
|
||||
ts->tv_sec = (absolute_gps_symbol / total_syms_per_sec) + GPS_EPOCH_OFFSET_UNIX;
|
||||
ts->tv_sec = (absolute_gps_symbol / total_syms_per_sec) + GPS_EPOCH_OFFSET_UNIX - GPS_LEAP_SECONDS;
|
||||
ts->tv_nsec = leftover_syms * ns_per_symbol;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user