mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
feat(vrtsim): add get_timestamp to openair_device_t and vrtsim
This function can be used to convert a timespec struct to a openair0_timestamp. It can be used to synchronize the realtime clock to the device sample number. Signed-off-by: Bartosz Podrygajlo <bartosz.podrygajlo@openairinterface.org>
This commit is contained in:
@@ -535,6 +535,10 @@ struct openair0_device {
|
||||
*/
|
||||
int (*trx_stop_func)(openair0_device_t *device);
|
||||
|
||||
/*! \brief Get timestamp from timespec
|
||||
*/
|
||||
openair0_timestamp_t (*get_timestamp)(openair0_device_t *device, struct timespec *ts);
|
||||
|
||||
/* Functions API related to UE*/
|
||||
|
||||
/*! \brief Set RX feaquencies
|
||||
|
||||
@@ -1100,6 +1100,14 @@ __attribute__((__visibility__("default"))) void vrtsim_produce_samples(openair0_
|
||||
shm_td_iq_channel_produce_samples(vrtsim_state->channel, num_samples);
|
||||
}
|
||||
|
||||
openair0_timestamp_t vrtsim_get_timestamp(openair0_device_t *device, struct timespec *ts)
|
||||
{
|
||||
vrtsim_state_t *vrtsim_state = (vrtsim_state_t *)device->priv;
|
||||
int64_t diff = (ts->tv_sec - vrtsim_state->start_ts.tv_sec) * 1000000000 + (ts->tv_nsec - vrtsim_state->start_ts.tv_nsec);
|
||||
double diff_samples = vrtsim_state->sample_rate * vrtsim_state->timescale * diff / 1e9;
|
||||
return diff_samples;
|
||||
}
|
||||
|
||||
__attribute__((__visibility__("default"))) int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg)
|
||||
{
|
||||
randominit();
|
||||
@@ -1119,6 +1127,9 @@ __attribute__((__visibility__("default"))) int device_init(openair0_device_t *de
|
||||
device->trx_write_beams_func = vrtsim_write_beams;
|
||||
device->trx_set_beams = vrtsim_set_beams;
|
||||
device->trx_set_beams2 = vrtsim_set_beams2;
|
||||
if (vrtsim_state->role == ROLE_SERVER) {
|
||||
device->get_timestamp = vrtsim_get_timestamp;
|
||||
}
|
||||
|
||||
device->type = RFSIMULATOR;
|
||||
device->openair0_cfg = &openair0_cfg[0];
|
||||
|
||||
Reference in New Issue
Block a user