diff --git a/lib/src/phy/rf/rf_zmq_imp.c b/lib/src/phy/rf/rf_zmq_imp.c index d262e67f1..fed61de0e 100644 --- a/lib/src/phy/rf/rf_zmq_imp.c +++ b/lib/src/phy/rf/rf_zmq_imp.c @@ -534,13 +534,14 @@ int rf_zmq_recv_with_time_multi( rf_zmq_info(handler->id, " - next rx time: %d + %.3f\n", ts_rx.full_secs, ts_rx.frac_secs); rf_zmq_info(handler->id, " - next tx time: %d + %.3f\n", ts_tx.full_secs, ts_tx.frac_secs); + // Leave time for the Tx to transmit + usleep((1000000 * nsamples) / handler->base_srate); + // check for tx gap if we're also transmitting on this radio if (handler->transmitter.running) { rf_zmq_tx_align(&handler->transmitter, handler->next_rx_ts + nsamples_baserate); } - usleep((1000000 * nsamples) / handler->base_srate); - // copy from rx buffer as many samples as requested into provided buffer cf_t* ptr = (handler->decim_factor != 1) ? handler->buffer_decimation : data[0]; int32_t count = 0; @@ -582,6 +583,10 @@ int rf_zmq_recv_with_time_multi( nsamples); } + // Set gain + float scale = powf(10.0f, handler->rx_gain / 20); + srslte_vec_sc_prod_cfc(data[0], scale, data[0], nsamples); + // update rx time update_ts(handler, &handler->next_rx_ts, nsamples_baserate, "rx"); } diff --git a/lib/src/phy/rf/rf_zmq_imp_tx.c b/lib/src/phy/rf/rf_zmq_imp_tx.c index 6b1360dca..ad38d2e7e 100644 --- a/lib/src/phy/rf/rf_zmq_imp_tx.c +++ b/lib/src/phy/rf/rf_zmq_imp_tx.c @@ -97,22 +97,9 @@ clean_exit: return ret; } -int rf_zmq_tx_align(rf_zmq_tx_t* q, uint64_t ts) -{ - int64_t nsamples = (int64_t)ts - (int64_t)q->nsamples; - - if (nsamples > 0) { - rf_zmq_info(q->id, " - Detected Tx gap of %d samples.\n", nsamples); - rf_zmq_tx_baseband(q, q->zeros, (uint32_t)nsamples); - } - - return (int)nsamples; -} - -int rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) +static int _rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) { int n = SRSLTE_ERROR; - pthread_mutex_lock(&q->mutex); while (n < 0 && q->running) { // Receive Transmit request @@ -156,6 +143,33 @@ int rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) n = nsamples; clean_exit: + return n; +} + +int rf_zmq_tx_align(rf_zmq_tx_t* q, uint64_t ts) +{ + pthread_mutex_lock(&q->mutex); + + int64_t nsamples = (int64_t)ts - (int64_t)q->nsamples; + + if (nsamples > 0) { + rf_zmq_info(q->id, " - Detected Tx gap of %d samples.\n", nsamples); + _rf_zmq_tx_baseband(q, q->zeros, (uint32_t)nsamples); + } + + pthread_mutex_unlock(&q->mutex); + + return (int)nsamples; +} + +int rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) +{ + int n; + + pthread_mutex_lock(&q->mutex); + + n = _rf_zmq_tx_baseband(q, buffer, nsamples); + pthread_mutex_unlock(&q->mutex); return n; @@ -173,4 +187,4 @@ void rf_zmq_tx_close(rf_zmq_tx_t* q) zmq_close(q->sock); q->sock = NULL; } -} \ No newline at end of file +}