ZMQ: Fixed for more stability

This commit is contained in:
Xavier Arteaga 2019-09-20 18:28:03 +02:00 committed by Xavier Arteaga
parent 125f1e7282
commit 191e8d6520
2 changed files with 36 additions and 17 deletions

View File

@ -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");
}

View File

@ -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;
}
}
}