Added cell_measurement calibration with RSSI sensor

master
ismagom 9 years ago
parent 67a5e0f0f1
commit 5074e9181b

@ -236,6 +236,8 @@ int main(int argc, char **argv) {
} }
cuhd_start_rx_stream(uhd); cuhd_start_rx_stream(uhd);
float rx_gain_offset = 0;
/* Main loop */ /* Main loop */
while (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) { while (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) {
@ -301,16 +303,26 @@ int main(int argc, char **argv) {
snr = SRSLTE_VEC_EMA(srslte_chest_dl_get_snr(&chest),snr,0.05); snr = SRSLTE_VEC_EMA(srslte_chest_dl_get_snr(&chest),snr,0.05);
nframes++; nframes++;
} }
if ((nframes%100) == 0 || rx_gain_offset == 0) {
if (cuhd_has_rssi(uhd)) {
rx_gain_offset = 10*log10(rssi)-cuhd_get_rssi(uhd);
} else {
rx_gain_offset = cuhd_get_rx_gain(uhd);
}
}
// Plot and Printf // Plot and Printf
if ((nframes%10) == 0) { if ((nframes%10) == 0) {
printf("CFO: %+8.4f KHz, SFO: %+8.4f Khz, RSSI: %5.1f dBm, RSSI/ref-symbol: %+5.1f dBm, " printf("CFO: %+8.4f KHz, SFO: %+8.4f Khz, RSSI: %5.1f dBm, RSSI/ref-symbol: %+5.1f dBm, "
"RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %5.1f dB\r", "RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %5.1f dB\r",
srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000, srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000,
10*log10(rssi*1000) - cuhd_get_rx_gain(uhd), 10*log10(rssi*1000) - rx_gain_offset,
10*log10(rssi_utra*1000)- cuhd_get_rx_gain(uhd), 10*log10(rssi_utra*1000)- rx_gain_offset,
10*log10(rsrp*1000)- cuhd_get_rx_gain(uhd), 10*log10(rsrp*1000) - rx_gain_offset,
10*log10(rsrq), 10*log10(snr)); 10*log10(rsrq), 10*log10(snr));
if (srslte_verbose != SRSLTE_VERBOSE_NONE) { if (srslte_verbose != SRSLTE_VERBOSE_NONE) {
printf("\n"); printf("\n");

@ -53,6 +53,10 @@ SRSLTE_API int cuhd_stop_rx_stream(void *h);
SRSLTE_API void cuhd_flush_buffer(void *h); SRSLTE_API void cuhd_flush_buffer(void *h);
SRSLTE_API bool cuhd_has_rssi(void *h);
SRSLTE_API float cuhd_get_rssi(void *h);
SRSLTE_API bool cuhd_rx_wait_lo_locked(void *h); SRSLTE_API bool cuhd_rx_wait_lo_locked(void *h);
SRSLTE_API void cuhd_set_master_clock_rate(void *h, SRSLTE_API void cuhd_set_master_clock_rate(void *h,

@ -108,6 +108,27 @@ void cuhd_flush_buffer(void *h)
} while (n > 0); } while (n > 0);
} }
bool cuhd_has_rssi(void *h) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h);
std::vector < std::string > mb_sensors = handler->usrp->get_mboard_sensor_names();
std::vector < std::string > rx_sensors = handler->usrp->get_rx_sensor_names(0);
if (std::find(rx_sensors.begin(), rx_sensors.end(), "rssi") != rx_sensors.end()) {
return true;
} else {
return false;
}
}
float cuhd_get_rssi(void *h) {
cuhd_handler *handler = static_cast < cuhd_handler * >(h);
if (cuhd_has_rssi(h)) {
uhd::sensor_value_t value = handler->usrp->get_rx_sensor("rssi");
return value.to_real();
} else {
return 0;
}
}
int cuhd_start_rx_stream_nsamples(void *h, uint32_t nsamples) int cuhd_start_rx_stream_nsamples(void *h, uint32_t nsamples)
{ {
cuhd_handler *handler = static_cast < cuhd_handler * >(h); cuhd_handler *handler = static_cast < cuhd_handler * >(h);

Loading…
Cancel
Save