diff --git a/lib/include/srslte/radio/radio.h b/lib/include/srslte/radio/radio.h index 26775777b..5137bd13b 100644 --- a/lib/include/srslte/radio/radio.h +++ b/lib/include/srslte/radio/radio.h @@ -34,150 +34,152 @@ #define SRSLTE_RADIO_H typedef struct { - float tx_corr_dc_gain; - float tx_corr_dc_phase; - float tx_corr_iq_i; - float tx_corr_iq_q; - float rx_corr_dc_gain; - float rx_corr_dc_phase; - float rx_corr_iq_i; - float rx_corr_iq_q; -}rf_cal_t; - + float tx_corr_dc_gain; + float tx_corr_dc_phase; + float tx_corr_iq_i; + float tx_corr_iq_q; + float rx_corr_dc_gain; + float rx_corr_dc_phase; + float rx_corr_iq_i; + float rx_corr_iq_q; +} rf_cal_t; namespace srslte { - + /* Interface to the RF frontend. */ - class radio - { - public: - radio() : tr_local_time(1024*10), tr_usrp_time(1024*10), tr_tx_time(1024*10), tr_is_eob(1024*10) { - bzero(&rf_device, sizeof(srslte_rf_t)); - bzero(&end_of_burst_time, sizeof(srslte_timestamp_t)); - bzero(zeros, burst_preamble_max_samples*sizeof(cf_t)); - - burst_preamble_sec = 0; - is_start_of_burst = false; - burst_preamble_samples = 0; - burst_preamble_time_rounded = 0; - - cur_tx_srate = 0; - tx_adv_sec = 0; - tx_adv_nsamples = 0; - tx_adv_auto = false; - tx_adv_negative = false; - tx_freq = 0; - rx_freq = 0; - trace_enabled = false; - tti = 0; - agc_enabled = false; - radio_is_streaming = false; - is_initialized = false; - }; - - bool init(char *args = NULL, char *devname = NULL, uint32_t nof_channels = 1); - void stop(); - void reset(); - bool start_agc(bool tx_gain_same_rx); - - void set_burst_preamble(double preamble_us); - void set_tx_adv(int nsamples); - void set_tx_adv_neg(bool tx_adv_is_neg); - - void set_manual_calibration(rf_cal_t *calibration); - - void get_time(srslte_timestamp_t *now); - bool tx_single(void *buffer, uint32_t nof_samples, srslte_timestamp_t tx_time); - bool tx(void *buffer[SRSLTE_MAX_PORTS], uint32_t nof_samples, srslte_timestamp_t tx_time); - void tx_end(); - bool rx_now(void *buffer[SRSLTE_MAX_PORTS], uint32_t nof_samples, srslte_timestamp_t *rxd_time); - bool rx_at(void *buffer, uint32_t nof_samples, srslte_timestamp_t rx_time); +class radio { + public: + radio() : tr_local_time(1024 * 10), tr_usrp_time(1024 * 10), tr_tx_time(1024 * 10), tr_is_eob(1024 * 10) { + bzero(&rf_device, sizeof(srslte_rf_t)); + bzero(&end_of_burst_time, sizeof(srslte_timestamp_t)); + bzero(zeros, burst_preamble_max_samples * sizeof(cf_t)); - void set_tx_gain(float gain); - void set_rx_gain(float gain); - void set_tx_rx_gain_offset(float offset); - double set_rx_gain_th(float gain); + burst_preamble_sec = 0; + is_start_of_burst = false; + burst_preamble_samples = 0; + burst_preamble_time_rounded = 0; - void set_freq_offset(double freq); - void set_tx_freq(double freq); - void set_rx_freq(double freq); + cur_tx_srate = 0; + tx_adv_sec = 0; + tx_adv_nsamples = 0; + tx_adv_auto = false; + tx_adv_negative = false; + tx_freq = 0; + rx_freq = 0; + trace_enabled = false; + tti = 0; + agc_enabled = false; + radio_is_streaming = false; + is_initialized = false; + continuous_tx = false; + }; - double get_freq_offset(); - double get_tx_freq(); - double get_rx_freq(); + bool init(char *args = NULL, char *devname = NULL, uint32_t nof_channels = 1); + void stop(); + void reset(); + bool start_agc(bool tx_gain_same_rx); - void set_master_clock_rate(double rate); - void set_tx_srate(double srate); - void set_rx_srate(double srate); + void set_burst_preamble(double preamble_us); + void set_tx_adv(int nsamples); + void set_tx_adv_neg(bool tx_adv_is_neg); - float get_tx_gain(); - float get_rx_gain(); - - float get_max_tx_power(); - float set_tx_power(float power); - float get_rssi(); - bool has_rssi(); - - void start_trace(); - void write_trace(std::string filename); + void set_manual_calibration(rf_cal_t *calibration); - void set_tti(uint32_t tti); + bool is_continuous_tx(); + void set_continuous_tx(bool enable); - bool is_first_of_burst(); + void get_time(srslte_timestamp_t *now); + bool tx_single(void *buffer, uint32_t nof_samples, srslte_timestamp_t tx_time); + bool tx(void *buffer[SRSLTE_MAX_PORTS], uint32_t nof_samples, srslte_timestamp_t tx_time); + void tx_end(); + bool rx_now(void *buffer[SRSLTE_MAX_PORTS], uint32_t nof_samples, srslte_timestamp_t *rxd_time); + bool rx_at(void *buffer, uint32_t nof_samples, srslte_timestamp_t rx_time); - bool is_init(); + void set_tx_gain(float gain); + void set_rx_gain(float gain); + void set_tx_rx_gain_offset(float offset); + double set_rx_gain_th(float gain); - void register_error_handler(srslte_rf_error_handler_t h); - - protected: - - void save_trace(uint32_t is_eob, srslte_timestamp_t *usrp_time); - - srslte_rf_t rf_device; - - - const static uint32_t burst_preamble_max_samples = 30720000; // 30.72 MHz is maximum frequency - double burst_preamble_sec;// Start of burst preamble time (off->on RF transition time) - srslte_timestamp_t end_of_burst_time; - bool is_start_of_burst; - uint32_t burst_preamble_samples; - double burst_preamble_time_rounded; // preamble time rounded to sample time - cf_t zeros[burst_preamble_max_samples]; - double cur_tx_srate; + void set_freq_offset(double freq); + void set_tx_freq(double freq); + void set_rx_freq(double freq); - double tx_adv_sec; // Transmission time advance to compensate for antenna->timestamp delay - int tx_adv_nsamples; // Transmision time advance in number of samples - - // Define default values for known radios - bool tx_adv_auto; - bool tx_adv_negative; - const static double uhd_default_burst_preamble_sec = 600*1e-6; - const static double uhd_default_tx_adv_samples = 98; - const static double uhd_default_tx_adv_offset_sec = 4*1e-6; - - const static double blade_default_burst_preamble_sec = 0.0; - const static double blade_default_tx_adv_samples = 27; - const static double blade_default_tx_adv_offset_sec = 1e-6; + double get_freq_offset(); + double get_tx_freq(); + double get_rx_freq(); - double tx_freq, rx_freq, freq_offset; - - trace tr_local_time; - trace tr_usrp_time; - trace tr_tx_time; - trace tr_is_eob; - bool trace_enabled; - uint32_t tti; - bool agc_enabled; + void set_master_clock_rate(double rate); + void set_tx_srate(double srate); + void set_rx_srate(double srate); - bool is_initialized = true;; - bool radio_is_streaming; + float get_tx_gain(); + float get_rx_gain(); - uint32_t saved_nof_channels; - char saved_args[128]; - char saved_devname[128]; + float get_max_tx_power(); + float set_tx_power(float power); + float get_rssi(); + bool has_rssi(); - }; + void start_trace(); + void write_trace(std::string filename); + + void set_tti(uint32_t tti); + + bool is_first_of_burst(); + + bool is_init(); + + void register_error_handler(srslte_rf_error_handler_t h); + + protected: + + void save_trace(uint32_t is_eob, srslte_timestamp_t *usrp_time); + + srslte_rf_t rf_device; + + const static uint32_t burst_preamble_max_samples = 30720000; // 30.72 MHz is maximum frequency + double burst_preamble_sec;// Start of burst preamble time (off->on RF transition time) + srslte_timestamp_t end_of_burst_time; + bool is_start_of_burst; + uint32_t burst_preamble_samples; + double burst_preamble_time_rounded; // preamble time rounded to sample time + cf_t zeros[burst_preamble_max_samples]; + double cur_tx_srate; + + double tx_adv_sec; // Transmission time advance to compensate for antenna->timestamp delay + int tx_adv_nsamples; // Transmision time advance in number of samples + + // Define default values for known radios + bool tx_adv_auto; + bool tx_adv_negative; + const static double uhd_default_burst_preamble_sec = 600 * 1e-6; + const static double uhd_default_tx_adv_samples = 98; + const static double uhd_default_tx_adv_offset_sec = 4 * 1e-6; + + const static double blade_default_burst_preamble_sec = 0.0; + const static double blade_default_tx_adv_samples = 27; + const static double blade_default_tx_adv_offset_sec = 1e-6; + + double tx_freq, rx_freq, freq_offset; + + trace tr_local_time; + trace tr_usrp_time; + trace tr_tx_time; + trace tr_is_eob; + bool trace_enabled; + uint32_t tti; + bool agc_enabled; + + bool continuous_tx; + bool is_initialized; + bool radio_is_streaming; + + uint32_t saved_nof_channels; + char saved_args[128]; + char saved_devname[128]; + +}; } #endif // SRSLTE_RADIO_H diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index 3be26e6b3..7b53f7405 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -50,12 +50,14 @@ bool radio::init(char *args, char *devname, uint32_t nof_channels) // Suppress radio stdout srslte_rf_suppress_stdout(&rf_device); - - tx_adv_auto = true; + + continuous_tx = false; + tx_adv_auto = true; // Set default preamble length each known device // We distinguish by device family, maybe we should calibrate per device if (strstr(srslte_rf_name(&rf_device), "uhd")) { burst_preamble_sec = uhd_default_burst_preamble_sec; + continuous_tx = true; } else if (strstr(srslte_rf_name(&rf_device), "bladerf")) { burst_preamble_sec = blade_default_burst_preamble_sec; } else { @@ -111,6 +113,14 @@ void radio::set_burst_preamble(double preamble_us) burst_preamble_sec = (double) preamble_us/1e6; } +void radio::set_continuous_tx(bool enable) { + continuous_tx = enable; +} + +bool radio::is_continuous_tx() { + return continuous_tx; +} + void radio::set_tx_adv(int nsamples) { tx_adv_auto = false; diff --git a/srsue/hdr/phy/phch_common.h b/srsue/hdr/phy/phch_common.h index 4d2536f53..b036f3869 100644 --- a/srsue/hdr/phy/phch_common.h +++ b/srsue/hdr/phy/phch_common.h @@ -27,9 +27,6 @@ #ifndef SRSUE_PHCH_COMMON_H #define SRSUE_PHCH_COMMON_H -#define TX_MODE_CONTINUOUS 1 - - #include #include #include diff --git a/srsue/hdr/ue_base.h b/srsue/hdr/ue_base.h index 547aefee8..63bb19533 100644 --- a/srsue/hdr/ue_base.h +++ b/srsue/hdr/ue_base.h @@ -64,6 +64,7 @@ typedef struct { std::string device_args; std::string time_adv_nsamples; std::string burst_preamble; + std::string continuous_tx; }rf_args_t; typedef struct { diff --git a/srsue/src/main.cc b/srsue/src/main.cc index f155c0a98..d8469f3ae 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -77,6 +77,7 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { ("rf.time_adv_nsamples", bpo::value(&args->rf.time_adv_nsamples)->default_value("auto"), "Transmission time advance") ("rf.burst_preamble_us", bpo::value(&args->rf.burst_preamble)->default_value("auto"), "Transmission time advance") + ("rf.continuous_tx", bpo::value(&args->rf.continuous_tx)->default_value("auto"), "Transmit samples continuously to the radio or on bursts (auto/yes/no). Default is auto (yes for UHD, no for rest)") ("rrc.feature_group", bpo::value(&args->rrc.feature_group)->default_value(0xe6041c00), "Hex value of the featureGroupIndicators field in the" "UECapabilityInformation message. Default 0xe6041c00") diff --git a/srsue/src/phy/phch_common.cc b/srsue/src/phy/phch_common.cc index 1129e7c6e..120f2ee51 100644 --- a/srsue/src/phy/phch_common.cc +++ b/srsue/src/phy/phch_common.cc @@ -248,7 +248,7 @@ void phch_common::worker_end(uint32_t tti, bool tx_enable, radio_h->tx_single(buffer, nof_samples, tx_time); is_first_of_burst = false; } else { - if (TX_MODE_CONTINUOUS) { + if (radio_h->is_continuous_tx()) { if (!is_first_of_burst) { radio_h->tx_single(zeros, nof_samples, tx_time); } diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 8c10f9a51..b8db55e5e 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -160,7 +160,10 @@ bool ue::init(all_args_t *args_) if (args->rf.burst_preamble.compare("auto")) { radio.set_burst_preamble(atof(args->rf.burst_preamble.c_str())); } - + if (args->rf.continuous_tx.compare("auto")) { + radio.set_continuous_tx(args->rf.continuous_tx.compare("yes")?false:true); + } + radio.set_manual_calibration(&args->rf_cal); // Set PHY options diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 531381431..7224cf8e3 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -20,7 +20,9 @@ # from antenna to timestamp insertion. # Default "auto". B210 USRP: 100 samples, bladeRF: 27. # burst_preamble_us: Preamble length to transmit before start of burst. -# Default "auto". B210 USRP: 400 us, bladeRF: 0 us. +# Default "auto". B210 USRP: 400 us, bladeRF: 0 us. +# continuous_tx: Transmit samples continuously to the radio or on bursts (auto/yes/no). +# Default is auto (yes for UHD, no for rest) ##################################################################### [rf] dl_earfcn = 3400 @@ -33,6 +35,7 @@ rx_gain = 40 #device_args = auto #time_adv_nsamples = auto #burst_preamble_us = auto +#continuous_tx = auto #####################################################################