SRSUE: Stack TTI based purely in radio timestamp

master
Xavier Arteaga 5 years ago committed by Xavier Arteaga
parent c29d8b418a
commit d96836a0fa

@ -52,7 +52,7 @@ SRSLTE_API void srslte_timestamp_init_uint64(srslte_timestamp_t* ts_time, uint64
SRSLTE_API int srslte_timestamp_copy(srslte_timestamp_t* dest, srslte_timestamp_t* src); SRSLTE_API int srslte_timestamp_copy(srslte_timestamp_t* dest, srslte_timestamp_t* src);
SRSLTE_API int srslte_timestamp_compare(srslte_timestamp_t* a, srslte_timestamp_t* b); SRSLTE_API int srslte_timestamp_compare(const srslte_timestamp_t* a, const srslte_timestamp_t* b);
SRSLTE_API int srslte_timestamp_add(srslte_timestamp_t* t, time_t full_secs, double frac_secs); SRSLTE_API int srslte_timestamp_add(srslte_timestamp_t* t, time_t full_secs, double frac_secs);

@ -53,7 +53,7 @@ int srslte_timestamp_copy(srslte_timestamp_t *dest, srslte_timestamp_t *src){
return ret; return ret;
} }
int srslte_timestamp_compare(srslte_timestamp_t* a, srslte_timestamp_t* b) int srslte_timestamp_compare(const srslte_timestamp_t* a, const srslte_timestamp_t* b)
{ {
int ret = 0; int ret = 0;

@ -343,11 +343,13 @@ private:
float current_srate = 0; float current_srate = 0;
// This is the primary cell // This is the primary cell
srslte_cell_t cell = {}; srslte_cell_t cell = {};
bool started = false; bool started = false;
float time_adv_sec = 0; float time_adv_sec = 0;
float next_time_adv_sec = 0; float next_time_adv_sec = 0;
uint32_t tti = 0; uint32_t tti = 0;
srslte_timestamp_t tti_ts = {};
srslte_timestamp_t radio_ts = {};
std::array<uint8_t, SRSLTE_BCH_PAYLOAD_LEN> mib; std::array<uint8_t, SRSLTE_BCH_PAYLOAD_LEN> mib;
uint32_t tx_worker_cnt = 0; uint32_t tx_worker_cnt = 0;

@ -34,7 +34,8 @@
namespace srsue { namespace srsue {
int radio_recv_callback(void *obj, cf_t *data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t *rx_time) { static int radio_recv_callback(void* obj, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* rx_time)
{
return ((sync*)obj)->radio_recv_fnc(data, nsamples, rx_time); return ((sync*)obj)->radio_recv_fnc(data, nsamples, rx_time);
} }
@ -587,8 +588,8 @@ void sync::run_thread()
nsamples = current_srate/1000; nsamples = current_srate/1000;
} }
Debug("Discarting %d samples\n", nsamples); Debug("Discarting %d samples\n", nsamples);
srslte_timestamp_t rx_time; srslte_timestamp_t rx_time = {};
if (!radio_h->rx_now(0, dummy_buffer, nsamples, &rx_time)) { if (!radio_recv_fnc(dummy_buffer, nsamples, &rx_time)) {
log_h->console("SYNC: Receiving from radio while in IDLE_RX\n"); log_h->console("SYNC: Receiving from radio while in IDLE_RX\n");
} }
// If radio is in locked state returns inmidiatetly. In that case, do a 1 ms sleep // If radio is in locked state returns inmidiatetly. In that case, do a 1 ms sleep
@ -641,8 +642,6 @@ void sync::run_thread()
// Increase TTI counter // Increase TTI counter
tti = (tti+1) % 10240; tti = (tti+1) % 10240;
stack->run_tti(tti);
} }
for (uint32_t p = 0; p < nof_rf_channels; p++) { for (uint32_t p = 0; p < nof_rf_channels; p++) {
@ -912,9 +911,32 @@ void sync::get_current_cell(srslte_cell_t* cell, uint32_t* earfcn)
int sync::radio_recv_fnc(cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* rx_time) int sync::radio_recv_fnc(cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* rx_time)
{ {
srslte_timestamp_t ts = {};
// Use local timestamp if timestamp is not provided
if (!rx_time) {
rx_time = &ts;
}
// Receive
if (radio_h->rx_now(0, data, nsamples, rx_time)) { if (radio_h->rx_now(0, data, nsamples, rx_time)) {
// Detect Radio Timestamp reset
if (srslte_timestamp_compare(rx_time, &radio_ts) < 0) {
srslte_timestamp_init(&radio_ts, 0, 0.0);
}
srslte_timestamp_copy(&radio_ts, rx_time);
// Advance stack in time
while (srslte_timestamp_compare(rx_time, &tti_ts) > 0) {
// Run stack
stack->run_tti(tti);
// Increase one millisecond
srslte_timestamp_add(&tti_ts, 0, 1.0e-3f);
}
if (channel_emulator && rx_time) { if (channel_emulator && rx_time) {
channel_emulator->set_srate(current_srate); channel_emulator->set_srate((uint32_t)current_srate);
channel_emulator->run(data, data, nsamples, *rx_time); channel_emulator->run(data, data, nsamples, *rx_time);
} }

Loading…
Cancel
Save