Commit 5679e4a3 authored by Florian Kaltenberger's avatar Florian Kaltenberger

making SFN dependent on GPS time (when available)

parent 828387c5
......@@ -604,6 +604,7 @@ void *emulatedRF_thread(void *param) {
void rx_rf(RU_t *ru,int *frame,int *slot) {
RU_proc_t *proc = &ru->proc;
NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
openair0_config_t *cfg = &ru->openair0_cfg;
void *rxp[ru->nb_rx];
unsigned int rxs;
int i;
......@@ -653,7 +654,13 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
}
}
proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023;
//compute system frame number (SFN) according to O-RAN-WG4-CUS.0-v02.00 (using alpha=beta=0)
// this assumes that the USRP has been synchronized to the GPS time
// OAI uses timestamps in sample time stored in int64_t, but it will fit in double precision for many years to come.
double gps_sec = ((double) ts)/cfg->sample_rate;
proc->frame_rx = ((int64_t) (gps_sec/0.01)) & 1023;
//proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023;
proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx,fp);
// synchronize first reception to frame 0 subframe 0
LOG_D(PHY,"RU %d/%d TS %llu , frame %d, slot %d.%d / %d\n",
......
......@@ -203,8 +203,8 @@ static int sync_to_gps(openair0_device *device) {
//Set to GPS time
uhd::time_spec_t gps_time = uhd::time_spec_t(time_t(s->usrp->get_mboard_sensor("gps_time", mboard).to_int()));
//s->usrp->set_time_next_pps(gps_time+1.0, mboard);
s->usrp->set_time_next_pps(uhd::time_spec_t(0.0));
s->usrp->set_time_next_pps(gps_time+1.0, mboard);
//s->usrp->set_time_next_pps(uhd::time_spec_t(0.0));
//Wait for it to apply
//The wait is 2 seconds because N-Series has a known issue where
//the time at the last PPS does not properly update at the PPS edge
......@@ -215,10 +215,10 @@ static int sync_to_gps(openair0_device *device) {
uhd::time_spec_t time_last_pps = s->usrp->get_time_last_pps(mboard);
std::cout << "USRP time: " << (boost::format("%0.9f") % time_last_pps.get_real_secs()) << std::endl;
std::cout << "GPSDO time: " << (boost::format("%0.9f") % gps_time.get_real_secs()) << std::endl;
//if (gps_time.get_real_secs() == time_last_pps.get_real_secs())
// std::cout << std::endl << "SUCCESS: USRP time synchronized to GPS time" << std::endl << std::endl;
//else
// std::cerr << std::endl << "ERROR: Failed to synchronize USRP time to GPS time" << std::endl << std::endl;
if (gps_time.get_real_secs() == time_last_pps.get_real_secs())
std::cout << std::endl << "SUCCESS: USRP time synchronized to GPS time" << std::endl << std::endl;
else
std::cerr << std::endl << "ERROR: Failed to synchronize USRP time to GPS time" << std::endl << std::endl;
}
if (num_gps_locked == num_mboards and num_mboards > 1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment