From 28ef713160bdf73fc003f85899a26c3331ce5a1a Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 2 May 2018 18:33:53 +0200 Subject: [PATCH] AGC does not get stuck in high gain if low signal. AGC is now default. --- lib/src/phy/rf/rf_imp.c | 19 ++++++++++--------- srsue/ue.conf.example | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/src/phy/rf/rf_imp.c b/lib/src/phy/rf/rf_imp.c index 1de66e066..c3d8d9516 100644 --- a/lib/src/phy/rf/rf_imp.c +++ b/lib/src/phy/rf/rf_imp.c @@ -41,13 +41,13 @@ int rf_get_available_devices(char **devnames, int max_strlen) { double srslte_rf_set_rx_gain_th(srslte_rf_t *rf, double gain) { - if (gain > rf->new_rx_gain + 2 || gain < rf->new_rx_gain - 2) { + if (gain > rf->cur_rx_gain + 2 || gain < rf->cur_rx_gain - 2){ pthread_mutex_lock(&rf->mutex); rf->new_rx_gain = gain; pthread_cond_signal(&rf->cond); pthread_mutex_unlock(&rf->mutex); } - return gain; + return rf->cur_rx_gain; } void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t *rf, double offset) { @@ -65,8 +65,9 @@ static void* thread_gain_fcn(void *h) { pthread_cond_wait(&rf->cond, &rf->mutex); } if (rf->new_rx_gain != rf->cur_rx_gain) { - rf->cur_rx_gain = rf->new_rx_gain; - srslte_rf_set_rx_gain(h, rf->cur_rx_gain); + srslte_rf_set_rx_gain(h, rf->new_rx_gain); + rf->cur_rx_gain = srslte_rf_get_rx_gain(h); + rf->new_rx_gain = rf->cur_rx_gain; } if (rf->tx_gain_same_rx) { printf("setting also tx\n"); @@ -80,17 +81,17 @@ static void* thread_gain_fcn(void *h) { /* Create auxiliary thread and mutexes for AGC */ int srslte_rf_start_gain_thread(srslte_rf_t *rf, bool tx_gain_same_rx) { - rf->tx_gain_same_rx = tx_gain_same_rx; - rf->tx_rx_gain_offset = 0.0; + rf->tx_gain_same_rx = tx_gain_same_rx; + rf->tx_rx_gain_offset = 0.0; if (pthread_mutex_init(&rf->mutex, NULL)) { - return -1; + return -1; } if (pthread_cond_init(&rf->cond, NULL)) { - return -1; + return -1; } if (pthread_create(&rf->thread_gain, NULL, thread_gain_fcn, rf)) { perror("pthread_create"); - return -1; + return -1; } return 0; } diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 7224cf8e3..9e244bad6 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -28,7 +28,7 @@ dl_earfcn = 3400 freq_offset = 0 tx_gain = 80 -rx_gain = 40 +#rx_gain = 40 #nof_rx_ant = 1 #device_name = auto