diff --git a/lib/include/srslte/phy/rf/rf.h b/lib/include/srslte/phy/rf/rf.h index 42b2a691d..50ced76d9 100644 --- a/lib/include/srslte/phy/rf/rf.h +++ b/lib/include/srslte/phy/rf/rf.h @@ -99,12 +99,6 @@ SRSLTE_API int srslte_rf_open_devname_multi(srslte_rf_t *h, char *args, uint32_t nof_rx_antennas); -SRSLTE_API int srslte_rf_open_devname_multi2(srslte_rf_t *rf, - char *devname, - char *args, - uint32_t nof_tx_antennas, - uint32_t nof_rx_antennas); - SRSLTE_API const char *srslte_rf_name(srslte_rf_t *h); SRSLTE_API int srslte_rf_start_gain_thread(srslte_rf_t *rf, @@ -221,6 +215,15 @@ SRSLTE_API int srslte_rf_send_timed2(srslte_rf_t *h, bool is_start_of_burst, bool is_end_of_burst); +SRSLTE_API int srslte_rf_send_timed_multi(srslte_rf_t *rf, + void *data[4], + int nsamples, + time_t secs, + double frac_secs, + bool blocking, + bool is_start_of_burst, + bool is_end_of_burst); + SRSLTE_API int srslte_rf_send_multi(srslte_rf_t *rf, void *data[4], int nsamples, diff --git a/lib/src/phy/rf/rf_blade_imp.c b/lib/src/phy/rf/rf_blade_imp.c index c48a2ad5b..d8996925f 100644 --- a/lib/src/phy/rf/rf_blade_imp.c +++ b/lib/src/phy/rf/rf_blade_imp.c @@ -178,7 +178,7 @@ float rf_blade_get_rssi(void *h) return 0; } -int rf_blade_open_multi(char *args, void **h, uint32_t nof_tx_antennas, uint32_t nof_rx_antennas) +int rf_blade_open_multi(char *args, void **h, uint32_t nof_channels) { return rf_blade_open(args, h); } diff --git a/lib/src/phy/rf/rf_blade_imp.h b/lib/src/phy/rf/rf_blade_imp.h index 2876a5404..fbaeab1df 100644 --- a/lib/src/phy/rf/rf_blade_imp.h +++ b/lib/src/phy/rf/rf_blade_imp.h @@ -34,7 +34,7 @@ SRSLTE_API int rf_blade_open(char *args, void **handler); SRSLTE_API int rf_blade_open_multi(char *args, - void **handler, uint32_t nof_tx_antennas, uint32_t nof_rx_antennas); + void **handler, uint32_t nof_channels); SRSLTE_API char* rf_blade_devname(void *h); diff --git a/lib/src/phy/rf/rf_dev.h b/lib/src/phy/rf/rf_dev.h index 4e3f2681b..00f157b6b 100644 --- a/lib/src/phy/rf/rf_dev.h +++ b/lib/src/phy/rf/rf_dev.h @@ -38,7 +38,7 @@ typedef struct { void (*srslte_rf_suppress_stdout)(void *h); void (*srslte_rf_register_error_handler)(void *h, srslte_rf_error_handler_t error_handler); int (*srslte_rf_open)(char *args, void **h); - int (*srslte_rf_open_multi)(char *args, void **h, uint32_t nof_tx_antennas, uint32_t nof_rx_antennas); + int (*srslte_rf_open_multi)(char *args, void **h, uint32_t nof_channels); int (*srslte_rf_close)(void *h); void (*srslte_rf_set_master_clock_rate)(void *h, double rate); bool (*srslte_rf_is_master_clock_dynamic)(void *h); diff --git a/lib/src/phy/rf/rf_imp.c b/lib/src/phy/rf/rf_imp.c index 0ae771043..cb22b301b 100644 --- a/lib/src/phy/rf/rf_imp.c +++ b/lib/src/phy/rf/rf_imp.c @@ -102,11 +102,7 @@ int srslte_rf_open_devname(srslte_rf_t *rf, char *devname, char *args) { return srslte_rf_open_devname_multi(rf, devname, args, 1); } -int srslte_rf_open_devname_multi(srslte_rf_t *rf, char *devname, char *args, uint32_t nof_rx_antennas) { - return srslte_rf_open_devname_multi2(rf, devname, args, 1, nof_rx_antennas); -} - -int srslte_rf_open_devname_multi2(srslte_rf_t *rf, char *devname, char *args, uint32_t nof_tx_antennas, uint32_t nof_rx_antennas) { +int srslte_rf_open_devname_multi(srslte_rf_t *rf, char *devname, char *args, uint32_t nof_channels) { /* Try to open the device if name is provided */ if (devname) { if (devname[0] != '\0') { @@ -114,7 +110,7 @@ int srslte_rf_open_devname_multi2(srslte_rf_t *rf, char *devname, char *args, ui while(available_devices[i] != NULL) { if (!strcmp(available_devices[i]->name, devname)) { rf->dev = available_devices[i]; - return available_devices[i]->srslte_rf_open_multi(args, &rf->handler, nof_tx_antennas, nof_rx_antennas); + return available_devices[i]->srslte_rf_open_multi(args, &rf->handler, nof_channels); } i++; } @@ -125,7 +121,7 @@ int srslte_rf_open_devname_multi2(srslte_rf_t *rf, char *devname, char *args, ui /* If in auto mode or provided device not found, try to open in order of apperance in available_devices[] array */ int i=0; while(available_devices[i] != NULL) { - if (!available_devices[i]->srslte_rf_open_multi(args, &rf->handler, nof_tx_antennas, nof_rx_antennas)) { + if (!available_devices[i]->srslte_rf_open_multi(args, &rf->handler, nof_channels)) { rf->dev = available_devices[i]; return 0; } @@ -198,11 +194,6 @@ int srslte_rf_open_multi(srslte_rf_t *h, char *args, uint32_t nof_rx_antennas) return srslte_rf_open_devname_multi(h, NULL, args, nof_rx_antennas); } -int srslte_rf_open_multi2(srslte_rf_t *h, char *args, uint32_t nof_tx_antennas, uint32_t nof_rx_antennas) -{ - return srslte_rf_open_devname_multi2(h, NULL, args, nof_tx_antennas, nof_rx_antennas); -} - int srslte_rf_close(srslte_rf_t *rf) { return ((rf_dev_t*) rf->dev)->srslte_rf_close(rf->handler); @@ -310,6 +301,20 @@ int srslte_rf_send_timed3(srslte_rf_t *rf, has_time_spec, blocking, is_start_of_burst, is_end_of_burst); } +int srslte_rf_send_timed_multi(srslte_rf_t *rf, + void *data[4], + int nsamples, + time_t secs, + double frac_secs, + bool blocking, + bool is_start_of_burst, + bool is_end_of_burst) +{ + + return ((rf_dev_t*) rf->dev)->srslte_rf_send_timed_multi(rf->handler, data, nsamples, secs, frac_secs, + true, blocking, is_start_of_burst, is_end_of_burst); +} + int srslte_rf_send_multi(srslte_rf_t *rf, void *data[4], int nsamples, @@ -318,8 +323,7 @@ int srslte_rf_send_multi(srslte_rf_t *rf, bool is_end_of_burst) { - return ((rf_dev_t*) rf->dev)->srslte_rf_send_timed_multi(rf->handler, data, nsamples, 0, 0, - false, blocking, is_start_of_burst, is_end_of_burst); + return srslte_rf_send_timed_multi(rf, data, nsamples, 0, 0, blocking, is_start_of_burst, is_end_of_burst); } int srslte_rf_send(srslte_rf_t *rf, void *data, uint32_t nsamples, bool blocking) diff --git a/lib/src/phy/rf/rf_uhd_imp.c b/lib/src/phy/rf/rf_uhd_imp.c index e0f3ac573..8819b706c 100644 --- a/lib/src/phy/rf/rf_uhd_imp.c +++ b/lib/src/phy/rf/rf_uhd_imp.c @@ -286,10 +286,10 @@ float rf_uhd_get_rssi(void *h) { int rf_uhd_open(char *args, void **h) { - return rf_uhd_open_multi(args, h, 1, 1); + return rf_uhd_open_multi(args, h, 1); } -int rf_uhd_open_multi(char *args, void **h, uint32_t nof_tx_antennas, uint32_t nof_rx_antennas) +int rf_uhd_open_multi(char *args, void **h, uint32_t nof_channels) { if (h) { *h = NULL; @@ -395,11 +395,11 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_tx_antennas, uint32_t n .otw_format = "sc16", .args = "", .channel_list = channel, - .n_channels = (nof_tx_antennas > nof_rx_antennas)?nof_tx_antennas:nof_rx_antennas, + .n_channels = nof_channels, }; - handler->nof_rx_channels = nof_rx_antennas; - handler->nof_tx_channels = nof_tx_antennas; + handler->nof_rx_channels = nof_channels; + handler->nof_tx_channels = nof_channels; /* Initialize rx and tx stremers */ uhd_rx_streamer_make(&handler->rx_stream); error = uhd_usrp_get_rx_stream(handler->usrp, &stream_args, handler->rx_stream); @@ -664,7 +664,7 @@ int rf_uhd_send_timed_multi(void *h, rf_uhd_handler_t* handler = (rf_uhd_handler_t*) h; /* Resets the USRP time FIXME: this might cause problems for burst transmissions */ - if (is_start_of_burst && handler->nof_tx_channels > 1) { + if (!has_time_spec && is_start_of_burst && handler->nof_tx_channels > 1) { uhd_usrp_set_time_now(handler->usrp, 0, 0, 0); uhd_tx_metadata_set_time_spec(&handler->tx_md, 0, 0.1); } diff --git a/lib/src/phy/rf/rf_uhd_imp.h b/lib/src/phy/rf/rf_uhd_imp.h index 6c0ab7dc7..2be799333 100644 --- a/lib/src/phy/rf/rf_uhd_imp.h +++ b/lib/src/phy/rf/rf_uhd_imp.h @@ -39,8 +39,7 @@ SRSLTE_API int rf_uhd_open(char *args, SRSLTE_API int rf_uhd_open_multi(char *args, void **handler, - uint32_t nof_tx_antennas, - uint32_t nof_rx_antennas); + uint32_t nof_channels); SRSLTE_API char* rf_uhd_devname(void *h); diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index bc74660b0..f508dc046 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -169,6 +169,8 @@ bool radio::has_rssi() bool radio::tx(void* buffer, uint32_t nof_samples, srslte_timestamp_t tx_time) { + void *iq_samples[4] = {(void *) zeros, (void *) zeros, (void *) zeros, (void *) zeros}; + if (!tx_adv_negative) { srslte_timestamp_sub(&tx_time, 0, tx_adv_sec); } else { @@ -177,11 +179,11 @@ bool radio::tx(void* buffer, uint32_t nof_samples, srslte_timestamp_t tx_time) if (is_start_of_burst) { if (burst_preamble_samples != 0) { - srslte_timestamp_t tx_time_pad; + srslte_timestamp_t tx_time_pad; srslte_timestamp_copy(&tx_time_pad, &tx_time); srslte_timestamp_sub(&tx_time_pad, 0, burst_preamble_time_rounded); save_trace(1, &tx_time_pad); - srslte_rf_send_timed2(&rf_device, zeros, burst_preamble_samples, tx_time_pad.full_secs, tx_time_pad.frac_secs, true, false); + srslte_rf_send_timed_multi(&rf_device, iq_samples, burst_preamble_samples, tx_time_pad.full_secs, tx_time_pad.frac_secs, true, true, false); is_start_of_burst = false; } } @@ -191,7 +193,8 @@ bool radio::tx(void* buffer, uint32_t nof_samples, srslte_timestamp_t tx_time) srslte_timestamp_add(&end_of_burst_time, 0, (double) nof_samples/cur_tx_srate); save_trace(0, &tx_time); - int ret = srslte_rf_send_timed2(&rf_device, buffer, nof_samples+offset, tx_time.full_secs, tx_time.frac_secs, is_start_of_burst, false); + iq_samples[0] = buffer; + int ret = srslte_rf_send_timed_multi(&rf_device, (void**) iq_samples, nof_samples+offset, tx_time.full_secs, tx_time.frac_secs, true, is_start_of_burst, false); offset = 0; is_start_of_burst = false; if (ret > 0) {