|
|
|
@ -44,6 +44,7 @@ typedef struct {
|
|
|
|
|
SoapySDRStream *rxStream;
|
|
|
|
|
SoapySDRStream *txStream;
|
|
|
|
|
bool tx_stream_active;
|
|
|
|
|
bool rx_stream_active;
|
|
|
|
|
} rf_soapy_handler_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -116,10 +117,11 @@ void rf_soapy_set_rx_cal(void *h, srslte_rf_cal_t *cal)
|
|
|
|
|
int rf_soapy_start_rx_stream(void *h)
|
|
|
|
|
{
|
|
|
|
|
rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h;
|
|
|
|
|
|
|
|
|
|
if(handler->rx_stream_active == false){
|
|
|
|
|
if(SoapySDRDevice_activateStream(handler->device, handler->rxStream, 0, 0, 0) != 0)
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
|
|
|
|
|
handler->rx_stream_active = true;
|
|
|
|
|
}
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -127,11 +129,11 @@ int rf_soapy_start_rx_stream(void *h)
|
|
|
|
|
int rf_soapy_start_tx_stream(void *h)
|
|
|
|
|
{
|
|
|
|
|
rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h;
|
|
|
|
|
if(handler->tx_stream_active == false){
|
|
|
|
|
if(SoapySDRDevice_activateStream(handler->device, handler->txStream, 0, 0, 0) != 0)
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
|
|
|
|
|
handler->tx_stream_active = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -142,6 +144,7 @@ int rf_soapy_stop_rx_stream(void *h)
|
|
|
|
|
if (SoapySDRDevice_deactivateStream(handler->device, handler->rxStream, 0, 0) != 0)
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
|
|
|
|
|
handler->rx_stream_active = false;
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -152,6 +155,8 @@ int rf_soapy_stop_tx_stream(void *h)
|
|
|
|
|
if(SoapySDRDevice_deactivateStream(handler->device, handler->txStream, 0, 0) != 0)
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handler->tx_stream_active = false;
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -214,15 +219,25 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas)
|
|
|
|
|
*h = handler;
|
|
|
|
|
handler->device = sdr;
|
|
|
|
|
handler->tx_stream_active = false;
|
|
|
|
|
handler->rx_stream_active = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(SoapySDRDevice_getNumChannels(handler->device,SOAPY_SDR_RX) > 0){
|
|
|
|
|
printf("setting up RX stream\n");
|
|
|
|
|
if(SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) {
|
|
|
|
|
printf("setupStream fail: %s\n", SoapySDRDevice_lastError());
|
|
|
|
|
printf("Rx setupStream fail: %s\n", SoapySDRDevice_lastError());
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(SoapySDRDevice_getNumChannels(handler->device,SOAPY_SDR_TX) > 0){
|
|
|
|
|
printf("setting up TX stream\n");
|
|
|
|
|
if (SoapySDRDevice_setupStream(handler->device, &(handler->txStream), SOAPY_SDR_TX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) {
|
|
|
|
|
printf("setupStream fail: %s\n", SoapySDRDevice_lastError());
|
|
|
|
|
printf("Tx setupStream fail: %s\n", SoapySDRDevice_lastError());
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -362,10 +377,7 @@ int rf_soapy_recv_with_time_multi(void *h,
|
|
|
|
|
double *frac_secs)
|
|
|
|
|
{
|
|
|
|
|
rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h;
|
|
|
|
|
//void *buffs[] = {buff}; //array of buffers
|
|
|
|
|
|
|
|
|
|
int flags; //flags set by receive operation
|
|
|
|
|
|
|
|
|
|
int num_channels = 1; // temp
|
|
|
|
|
|
|
|
|
|
int trials = 0;
|
|
|
|
@ -375,16 +387,14 @@ int rf_soapy_recv_with_time_multi(void *h,
|
|
|
|
|
do {
|
|
|
|
|
size_t rx_samples = nsamples;
|
|
|
|
|
|
|
|
|
|
if (rx_samples > nsamples - n)
|
|
|
|
|
{
|
|
|
|
|
if (rx_samples > nsamples - n){
|
|
|
|
|
rx_samples = nsamples - n;
|
|
|
|
|
}
|
|
|
|
|
void *buffs_ptr[4];
|
|
|
|
|
for (int i=0; i<num_channels; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int i=0; i<num_channels; i++){
|
|
|
|
|
cf_t *data_c = (cf_t*) data[i];
|
|
|
|
|
buffs_ptr[i] = &data_c[n];
|
|
|
|
|
} //(void*)(&data)
|
|
|
|
|
}
|
|
|
|
|
ret = SoapySDRDevice_readStream(handler->device, handler->rxStream, buffs_ptr , rx_samples, &flags, &timeNs, 1000000);
|
|
|
|
|
if(ret < 0) {
|
|
|
|
|
// continue when getting overflows
|
|
|
|
@ -448,8 +458,7 @@ int rf_soapy_send_timed(void *h,
|
|
|
|
|
cf_t *data_c = (cf_t*) data;
|
|
|
|
|
do{
|
|
|
|
|
size_t tx_samples = nsamples;
|
|
|
|
|
if (tx_samples > nsamples - n)
|
|
|
|
|
{
|
|
|
|
|
if (tx_samples > nsamples - n) {
|
|
|
|
|
tx_samples = nsamples - n;
|
|
|
|
|
}
|
|
|
|
|
void *buff = (void*) &data_c[n];
|
|
|
|
@ -457,16 +466,14 @@ int rf_soapy_send_timed(void *h,
|
|
|
|
|
ret = SoapySDRDevice_writeStream(handler->device, handler->txStream, buffs_ptr, tx_samples, &flags, timeNs, 10000);
|
|
|
|
|
if(ret < 0)
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
|
|
|
|
|
n += ret;
|
|
|
|
|
trials++;
|
|
|
|
|
}while (n < nsamples && trials < 100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ret != nsamples)
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|