fixed blocked timers due to syncrhonization lost

master
Ismael Gomez 7 years ago
parent c7c2ab6ed5
commit 3aabd83289

@ -87,7 +87,7 @@ private:
void set_sampling_rate();
bool set_frequency();
void resync_sfn();
void resync_sfn(bool is_connected = false);
bool stop_sync();
void cell_search_inc();
@ -129,6 +129,7 @@ private:
IDLE = 0,
CELL_SEARCH,
CELL_SELECT,
CELL_RESELECT,
CELL_MEASURE,
CELL_CAMP
} phy_state;

@ -142,47 +142,44 @@ void mac::reset()
void mac::run_thread() {
int cnt=0;
while(started) {
while (!phy_h->sync_status() && started) {
usleep(5000);
if (phy_h->sync_status()) {
Debug("Setting ttysync to %d\n", phy_h->get_current_tti());
ttisync.set_producer_cntr(phy_h->get_current_tti());
}
while (!phy_h->sync_status() && started) {
usleep(5000);
if (phy_h->sync_status()) {
Debug("Setting ttysync to %d\n", phy_h->get_current_tti());
ttisync.set_producer_cntr(phy_h->get_current_tti());
}
}
if (started && phy_h->sync_status()) {
/* Warning: Here order of invocation of procedures is important!! */
ttisync.wait();
tti = phy_h->get_current_tti();
while(started) {
log_h->step(tti);
/* Warning: Here order of invocation of procedures is important!! */
ttisync.wait();
tti = phy_h->get_current_tti();
timers.step_all();
log_h->step(tti);
timers.step_all();
// Step all procedures
bsr_procedure.step(tti);
phr_procedure.step(tti);
// Step all procedures
bsr_procedure.step(tti);
phr_procedure.step(tti);
// Check if BSR procedure need to start SR
// Check if BSR procedure need to start SR
if (bsr_procedure.need_to_send_sr(tti)) {
Debug("Starting SR procedure by BSR request, PHY TTI=%d\n", tti);
sr_procedure.start();
}
if (bsr_procedure.need_to_reset_sr()) {
Debug("Resetting SR procedure by BSR request\n");
sr_procedure.reset();
}
sr_procedure.step(tti);
if (bsr_procedure.need_to_send_sr(tti)) {
Debug("Starting SR procedure by BSR request, PHY TTI=%d\n", tti);
sr_procedure.start();
}
if (bsr_procedure.need_to_reset_sr()) {
Debug("Resetting SR procedure by BSR request\n");
sr_procedure.reset();
}
sr_procedure.step(tti);
// Check SR if we need to start RA
if (sr_procedure.need_random_access()) {
ra_procedure.start_mac_order();
}
ra_procedure.step(tti);
// Check SR if we need to start RA
if (sr_procedure.need_random_access()) {
ra_procedure.start_mac_order();
}
ra_procedure.step(tti);
}
}

@ -422,7 +422,7 @@ int phch_recv::cell_meas_rsrp() {
return 0;
}
void phch_recv::resync_sfn() {
void phch_recv::resync_sfn(bool is_connected) {
wait_radio_reset();
@ -431,7 +431,7 @@ void phch_recv::resync_sfn() {
srslte_ue_mib_reset(&ue_mib);
Info("SYNC: Starting SFN synchronization\n");
sync_sfn_cnt = 0;
phy_state = CELL_SELECT;
phy_state = is_connected?CELL_RESELECT:CELL_SELECT;
}
void phch_recv::set_earfcn(std::vector<uint32_t> earfcn) {
@ -463,7 +463,7 @@ void phch_recv::reset_sync() {
Warning("SYNC: Resetting sync, cell_search_in_progress=%s\n", cell_search_in_progress?"yes":"no");
srslte_ue_sync_reset(&ue_mib_sync.ue_sync);
srslte_ue_sync_reset(&ue_sync);
resync_sfn();
resync_sfn(true);
}
void phch_recv::cell_search_inc()
@ -639,6 +639,7 @@ void phch_recv::run_thread() {
}
}
break;
case CELL_RESELECT:
case CELL_SELECT:
srslte_ue_sync_decode_sss_on_track(&ue_sync, true);
@ -664,8 +665,12 @@ void phch_recv::run_thread() {
sync_sfn_cnt++;
if (sync_sfn_cnt >= SYNC_SFN_TIMEOUT) {
sync_sfn_cnt = 0;
phy_state = CELL_SEARCH;
log_h->warning("SYNC: Timeout while synchronizing SFN\n");
if (phy_state == CELL_SELECT) {
phy_state = CELL_SEARCH;
} else {
phy_state = IDLE;
}
}
break;
case CELL_MEASURE:
@ -733,6 +738,7 @@ void phch_recv::run_thread() {
rrc->out_of_sync();
worker->release();
worker_com->reset_ul();
mac->tti_clock(tti);
break;
default:
radio_error();
@ -749,6 +755,9 @@ void phch_recv::run_thread() {
}
is_in_idle = true;
usleep(1000);
// Keep running MAC timer from system clock
tti = (tti+1) % 10240;
mac->tti_clock(tti);
break;
}
}

Loading…
Cancel
Save