diff --git a/lib/src/phy/rf/rf_zmq_imp.c b/lib/src/phy/rf/rf_zmq_imp.c index f27e28fc4..a61bed3bd 100644 --- a/lib/src/phy/rf/rf_zmq_imp.c +++ b/lib/src/phy/rf/rf_zmq_imp.c @@ -307,6 +307,9 @@ int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) parse_double(args, "tx_freq", i, &tx_freq); tx_opts.frequency_mhz = (uint32_t)(tx_freq / 1e6); + // tx_offset + parse_int32(args, "tx_offset", i, &tx_opts.sample_offset); + // fail_on_disconnect char tmp[RF_PARAM_LEN] = {}; parse_string(args, "fail_on_disconnect", i, tmp); diff --git a/lib/src/phy/rf/rf_zmq_imp_trx.h b/lib/src/phy/rf/rf_zmq_imp_trx.h index e4b48a6f7..eb4bed704 100644 --- a/lib/src/phy/rf/rf_zmq_imp_trx.h +++ b/lib/src/phy/rf/rf_zmq_imp_trx.h @@ -42,6 +42,7 @@ typedef struct { cf_t* zeros; void* temp_buffer_convert; uint32_t frequency_mhz; + int32_t sample_offset; } rf_zmq_tx_t; typedef struct { diff --git a/lib/src/phy/rf/rf_zmq_imp_tx.c b/lib/src/phy/rf/rf_zmq_imp_tx.c index 61b427e58..bd181a513 100644 --- a/lib/src/phy/rf/rf_zmq_imp_tx.c +++ b/lib/src/phy/rf/rf_zmq_imp_tx.c @@ -39,6 +39,7 @@ int rf_zmq_tx_open(rf_zmq_tx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock q->socket_type = opts.socket_type; q->sample_format = opts.sample_format; q->frequency_mhz = opts.frequency_mhz; + q->sample_offset = opts.sample_offset; rf_zmq_info(q->id, "Binding transmitter: %s\n", sock_args); @@ -179,6 +180,19 @@ int rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) pthread_mutex_lock(&q->mutex); + if (q->sample_offset > 0) { + _rf_zmq_tx_baseband(q, q->zeros, (uint32_t)q->sample_offset); + q->sample_offset = 0; + } else if (q->sample_offset < 0) { + n = SRSLTE_MIN(-q->sample_offset, nsamples); + buffer += n; + nsamples -= n; + q->sample_offset += n; + if (nsamples == 0) { + return n; + } + } + n = _rf_zmq_tx_baseband(q, buffer, nsamples); pthread_mutex_unlock(&q->mutex);