diff --git a/lib/include/srslte/radio/radio.h b/lib/include/srslte/radio/radio.h index f30759c89..6a0ffb278 100644 --- a/lib/include/srslte/radio/radio.h +++ b/lib/include/srslte/radio/radio.h @@ -43,8 +43,7 @@ namespace srslte { class radio : public radio_interface_phy, public srslte::radio_base { public: - radio(srslte::log_filter* log_h); - radio(srslte::logger* logger_h); + radio(); ~radio(); int init(const rf_args_t& args_, phy_interface_radio* phy_) final; @@ -90,9 +89,7 @@ private: std::vector rf_info = {}; std::vector rx_offset_n = {}; rf_metrics_t rf_metrics = {}; - log_filter log_local = {}; - log_filter* log_h = nullptr; - srslte::logger* logger = nullptr; + srslog::basic_logger& logger = srslog::fetch_basic_logger("RF", false); phy_interface_radio* phy = nullptr; cf_t* zeros = nullptr; std::array dummy_buffers; diff --git a/lib/include/srslte/radio/radio_base.h b/lib/include/srslte/radio/radio_base.h index 9b5278f01..b88a38e78 100644 --- a/lib/include/srslte/radio/radio_base.h +++ b/lib/include/srslte/radio/radio_base.h @@ -29,7 +29,6 @@ class phy_interface_radio; class radio_base { public: - radio_base(srslte::logger* logger_ = nullptr) {} virtual ~radio_base() = default; virtual std::string get_type() = 0; diff --git a/lib/include/srslte/radio/radio_null.h b/lib/include/srslte/radio/radio_null.h index 762dff4cd..320f37b48 100644 --- a/lib/include/srslte/radio/radio_null.h +++ b/lib/include/srslte/radio/radio_null.h @@ -31,14 +31,13 @@ namespace srslte { class radio_null final : public radio_base, public radio_interface_phy { public: - explicit radio_null(srslte::logger* logger_); ~radio_null() final = default; std::string get_type() override { return "null"; } int init(const rf_args_t& args_, phy_interface_radio* phy_) override { - log->set_level(args.log_level); + logger.set_level(srslog::str_to_basic_level(args.log_level)); running = true; return SRSLTE_SUCCESS; @@ -58,61 +57,61 @@ public: bool is_continuous_tx() override { return false; } bool tx(rf_buffer_interface& buffer, const rf_timestamp_interface& tx_time) override { - log->info("%s\n", __PRETTY_FUNCTION__); + logger.info("%s", __PRETTY_FUNCTION__); return true; } - void tx_end() override { log->info("%s\n", __PRETTY_FUNCTION__); } + void tx_end() override { logger.info("%s", __PRETTY_FUNCTION__); } bool rx_now(rf_buffer_interface& buffer, rf_timestamp_interface& rxd_time) override { - log->info("%s\n", __PRETTY_FUNCTION__); + logger.info("%s", __PRETTY_FUNCTION__); return true; } - void set_rx_gain(const float& gain) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void set_rx_gain(const float& gain) override { logger.info("%s", __PRETTY_FUNCTION__); } - void set_rx_gain_th(const float& gain) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void set_rx_gain_th(const float& gain) override { logger.info("%s", __PRETTY_FUNCTION__); } float get_rx_gain() override { - log->info("%s\n", __PRETTY_FUNCTION__); + logger.info("%s", __PRETTY_FUNCTION__); return 0.0; } - void set_tx_gain(const float& gain) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void set_tx_gain(const float& gain) override { logger.info("%s", __PRETTY_FUNCTION__); } - void set_tx_freq(const uint32_t& channel_idx, const double& freq) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void set_tx_freq(const uint32_t& channel_idx, const double& freq) override { logger.info("%s", __PRETTY_FUNCTION__); } - void set_rx_freq(const uint32_t& channel_idx, const double& freq) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void set_rx_freq(const uint32_t& channel_idx, const double& freq) override { logger.info("%s", __PRETTY_FUNCTION__); } double get_freq_offset() override { - log->info("%s\n", __PRETTY_FUNCTION__); + logger.info("%s", __PRETTY_FUNCTION__); return 0.0; } - void set_tx_srate(const double& srate) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void set_tx_srate(const double& srate) override { logger.info("%s", __PRETTY_FUNCTION__); } - void set_rx_srate(const double& srate) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void set_rx_srate(const double& srate) override { logger.info("%s", __PRETTY_FUNCTION__); } - void set_channel_rx_offset(uint32_t ch, int32_t offset_samples) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void set_channel_rx_offset(uint32_t ch, int32_t offset_samples) override { logger.info("%s", __PRETTY_FUNCTION__); } srslte_rf_info_t* get_info() override { - log->info("%s\n", __PRETTY_FUNCTION__); + logger.info("%s", __PRETTY_FUNCTION__); return nullptr; } bool get_is_start_of_burst() override { return true; } - void release_freq(const uint32_t& carrier_idx) override { log->info("%s\n", __PRETTY_FUNCTION__); } + void release_freq(const uint32_t& carrier_idx) override { logger.info("%s", __PRETTY_FUNCTION__); } protected: rf_args_t args = {}; - srslte::log_ref log; - bool running = false; + srslog::basic_logger& logger = srslog::fetch_basic_logger("RF", false); + bool running = false; srslte::rf_metrics_t rf_metrics = {}; phy_interface_radio* phy = nullptr; diff --git a/lib/src/radio/CMakeLists.txt b/lib/src/radio/CMakeLists.txt index d175e5e99..9d2012ade 100644 --- a/lib/src/radio/CMakeLists.txt +++ b/lib/src/radio/CMakeLists.txt @@ -7,7 +7,7 @@ # if(RF_FOUND) - add_library(srslte_radio STATIC radio.cc radio_null.cc channel_mapping.cc) + add_library(srslte_radio STATIC radio.cc channel_mapping.cc) target_link_libraries(srslte_radio srslte_rf srslte_common) INSTALL(TARGETS srslte_radio DESTINATION ${LIBRARY_DIR}) endif(RF_FOUND) diff --git a/lib/src/radio/channel_mapping.cc b/lib/src/radio/channel_mapping.cc index 32acd88ff..fd0af7b46 100644 --- a/lib/src/radio/channel_mapping.cc +++ b/lib/src/radio/channel_mapping.cc @@ -27,7 +27,7 @@ bool channel_mapping::allocate_freq(const uint32_t& logical_ch, const float& fre std::lock_guard lock(mutex); if (allocated_channels.count(logical_ch)) { - ERROR("allocate_freq: Carrier logical_ch=%d already allocated to channel=%d\n", + ERROR("allocate_freq: Carrier logical_ch=%d already allocated to channel=%d", logical_ch, allocated_channels[logical_ch].carrier_idx); return false; @@ -41,7 +41,7 @@ bool channel_mapping::allocate_freq(const uint32_t& logical_ch, const float& fre return true; } } - ERROR("allocate_freq: No channels available for frequency=%.1f %s\n", freq, to_string().c_str()); + ERROR("allocate_freq: No channels available for frequency=%.1f %s", freq, to_string().c_str()); return false; } diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index 238ed882a..337affe29 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -19,7 +19,7 @@ namespace srslte { -radio::radio(srslte::log_filter* log_h_) : logger(nullptr), log_h(log_h_), zeros(nullptr) +radio::radio() : zeros(nullptr) { zeros = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX); srslte_vec_cf_zero(zeros, SRSLTE_SF_LEN_MAX); @@ -29,15 +29,6 @@ radio::radio(srslte::log_filter* log_h_) : logger(nullptr), log_h(log_h_), zeros } } -radio::radio(srslte::logger* logger_) : logger(logger_), log_h(nullptr), zeros(nullptr) -{ - zeros = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX); - srslte_vec_cf_zero(zeros, SRSLTE_SF_LEN_MAX); - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { - dummy_buffers[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX); - } -} - radio::~radio() { if (zeros) { @@ -65,24 +56,15 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) phy = phy_; // Init log - if (log_h == nullptr) { - if (logger != nullptr) { - log_local.init("RF ", logger); - log_local.set_level(args.log_level); - log_h = &log_local; - } else { - fprintf(stderr, "Must all radio constructor with either logger or log_filter\n"); - return SRSLTE_ERROR; - } - } + logger.set_level(srslog::str_to_basic_level(args.log_level)); if (args.nof_antennas > SRSLTE_MAX_PORTS) { - log_h->error("Maximum number of antennas exceeded (%d > %d)\n", args.nof_antennas, SRSLTE_MAX_PORTS); + logger.error("Maximum number of antennas exceeded (%d > %d)", args.nof_antennas, SRSLTE_MAX_PORTS); return SRSLTE_ERROR; } if (args.nof_carriers > SRSLTE_MAX_CARRIERS) { - log_h->error("Maximum number of carriers exceeded (%d > %d)\n", args.nof_carriers, SRSLTE_MAX_CARRIERS); + logger.error("Maximum number of carriers exceeded (%d > %d)", args.nof_carriers, SRSLTE_MAX_CARRIERS); return SRSLTE_ERROR; } @@ -134,7 +116,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) // Init and start Radios for (uint32_t device_idx = 0; device_idx < (uint32_t)device_args_list.size(); device_idx++) { if (not open_dev(device_idx, args.device_name, device_args_list[device_idx])) { - log_h->error("Error opening RF device %d\n", device_idx); + logger.error("Error opening RF device %d", device_idx); return SRSLTE_ERROR; } } @@ -179,11 +161,11 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) uint32_t rf_device_idx = phys_antenna_idx / nof_channels_x_dev; uint32_t rf_channel_idx = phys_antenna_idx % nof_channels_x_dev; - log_h->info( - "Setting individual tx_gain=%.1f on dev=%d ch=%d\n", args.tx_gain_ch[i], rf_device_idx, rf_channel_idx); + logger.info( + "Setting individual tx_gain=%.1f on dev=%d ch=%d", args.tx_gain_ch[i], rf_device_idx, rf_channel_idx); if (srslte_rf_set_tx_gain_ch(&rf_devices[rf_device_idx], rf_channel_idx, args.tx_gain_ch[i]) < 0) { - log_h->error( - "Setting channel tx_gain=%.1f on dev=%d ch=%d\n", args.tx_gain_ch[i], rf_device_idx, rf_channel_idx); + logger.error( + "Setting channel tx_gain=%.1f on dev=%d ch=%d", args.tx_gain_ch[i], rf_device_idx, rf_channel_idx); } } } @@ -199,11 +181,11 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) uint32_t rf_device_idx = phys_antenna_idx / nof_channels_x_dev; uint32_t rf_channel_idx = phys_antenna_idx % nof_channels_x_dev; - log_h->info( - "Setting individual rx_gain=%.1f on dev=%d ch=%d\n", args.rx_gain_ch[i], rf_device_idx, rf_channel_idx); + logger.info( + "Setting individual rx_gain=%.1f on dev=%d ch=%d", args.rx_gain_ch[i], rf_device_idx, rf_channel_idx); if (srslte_rf_set_rx_gain_ch(&rf_devices[rf_device_idx], rf_channel_idx, args.rx_gain_ch[i]) < 0) { - log_h->error( - "Setting channel rx_gain=%.1f on dev=%d ch=%d\n", args.rx_gain_ch[i], rf_device_idx, rf_channel_idx); + logger.error( + "Setting channel rx_gain=%.1f on dev=%d ch=%d", args.rx_gain_ch[i], rf_device_idx, rf_channel_idx); } } } @@ -284,7 +266,7 @@ bool radio::start_agc(bool tx_gain_same_rx) } for (srslte_rf_t& rf_device : rf_devices) { if (srslte_rf_start_gain_thread(&rf_device, tx_gain_same_rx)) { - ERROR("Error starting AGC Thread RF device\n"); + ERROR("Error starting AGC Thread RF device"); return false; } } @@ -354,7 +336,7 @@ bool radio::rx_dev(const uint32_t& device_idx, const rf_buffer_interface& buffer } if (not map_channels(rx_channel_mapping, device_idx, 0, buffer, radio_buffers)) { - log_h->error("Mapping logical channels to physical channels for transmission\n"); + logger.error("Mapping logical channels to physical channels for transmission"); return false; } @@ -442,7 +424,7 @@ bool radio::open_dev(const uint32_t& device_idx, const std::string& device_name, dev_args ? dev_args : "default"); if (srslte_rf_open_devname(rf_device, dev_name, dev_args, nof_channels_x_dev)) { - log_h->error("Error opening RF device\n"); + logger.error("Error opening RF device"); return false; } @@ -499,7 +481,7 @@ bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, cons nof_samples = nof_samples - past_nsamples; // Subtracts the number of trimmed samples // Prints discarded samples - log_h->debug("Detected RF overlap of %.1f us. Discarding %d samples. Power=%+.1f dBfs\n", + logger.debug("Detected RF overlap of %.1f us. Discarding %d samples. Power=%+.1f dBfs", srslte_timestamp_real(&ts_overlap) * 1.0e6, past_nsamples, srslte_convert_power_to_dB(srslte_vec_avg_power_cf(&buffer.get(0)[nof_samples], past_nsamples))); @@ -507,10 +489,10 @@ bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, cons } else if (past_nsamples < 0 and not is_start_of_burst) { // if the gap is bigger than TX_MAX_GAP_ZEROS, stop burst if (fabs(srslte_timestamp_real(&ts_overlap)) > tx_max_gap_zeros) { - log_h->info("Detected RF gap of %.1f us. Sending end-of-burst.\n", srslte_timestamp_real(&ts_overlap) * 1.0e6); + logger.info("Detected RF gap of %.1f us. Sending end-of-burst.", srslte_timestamp_real(&ts_overlap) * 1.0e6); tx_end(); } else { - log_h->debug("Detected RF gap of %.1f us. Tx'ing zeroes.\n", srslte_timestamp_real(&ts_overlap) * 1.0e6); + logger.debug("Detected RF gap of %.1f us. Tx'ing zeroes.", srslte_timestamp_real(&ts_overlap) * 1.0e6); // Otherwise, transmit zeros uint32_t gap_nsamples = abs(past_nsamples); while (gap_nsamples > 0) { @@ -550,7 +532,7 @@ bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, cons } if (not map_channels(tx_channel_mapping, device_idx, sample_offset, buffer, radio_buffers)) { - log_h->error("Mapping logical channels to physical channels for transmission\n"); + logger.error("Mapping logical channels to physical channels for transmission"); return false; } @@ -597,7 +579,7 @@ void radio::set_rx_freq(const uint32_t& carrier_idx, const double& freq) // Map carrier index to physical channel if (rx_channel_mapping.allocate_freq(carrier_idx, freq)) { channel_mapping::device_mapping_t device_mapping = rx_channel_mapping.get_device_mapping(carrier_idx); - log_h->info("Mapping RF channel %d (device=%d, channel=%d) to logical carrier %d on f_rx=%.1f MHz\n", + logger.info("Mapping RF channel %d (device=%d, channel=%d) to logical carrier %d on f_rx=%.1f MHz", device_mapping.carrier_idx, device_mapping.device_idx, device_mapping.channel_idx, @@ -611,16 +593,16 @@ void radio::set_rx_freq(const uint32_t& carrier_idx, const double& freq) srslte_rf_set_rx_freq(&rf_devices[dm.device_idx], dm.channel_idx, freq + freq_offset); } } else { - log_h->error("set_rx_freq: physical_channel_idx=%d for %d antennas exceeds maximum channels (%d)\n", + logger.error("set_rx_freq: physical_channel_idx=%d for %d antennas exceeds maximum channels (%d)", device_mapping.carrier_idx, nof_antennas, nof_channels); } } else { - log_h->info("RF Rx channel %d already on freq\n", device_mapping.carrier_idx); + logger.info("RF Rx channel %d already on freq", device_mapping.carrier_idx); } } else { - log_h->error("set_rx_freq: Could not allocate frequency %.1f MHz to carrier %d\n", freq / 1e6, carrier_idx); + logger.error("set_rx_freq: Could not allocate frequency %.1f MHz to carrier %d", freq / 1e6, carrier_idx); } } @@ -646,7 +628,6 @@ void radio::set_rx_gain_th(const float& gain) void radio::set_rx_srate(const double& srate) { - if (!is_initialized) { return; } @@ -714,7 +695,7 @@ void radio::set_tx_freq(const uint32_t& carrier_idx, const double& freq) // Map carrier index to physical channel if (tx_channel_mapping.allocate_freq(carrier_idx, freq)) { channel_mapping::device_mapping_t device_mapping = tx_channel_mapping.get_device_mapping(carrier_idx); - log_h->info("Mapping RF channel %d (device=%d, channel=%d) to logical carrier %d on f_tx=%.1f MHz\n", + logger.info("Mapping RF channel %d (device=%d, channel=%d) to logical carrier %d on f_tx=%.1f MHz", device_mapping.carrier_idx, device_mapping.device_idx, device_mapping.channel_idx, @@ -729,16 +710,16 @@ void radio::set_tx_freq(const uint32_t& carrier_idx, const double& freq) srslte_rf_set_tx_freq(&rf_devices[device_mapping.device_idx], device_mapping.channel_idx, freq + freq_offset); } } else { - log_h->error("set_tx_freq: physical_channel_idx=%d for %d antennas exceeds maximum channels (%d)\n", + logger.error("set_tx_freq: physical_channel_idx=%d for %d antennas exceeds maximum channels (%d)", device_mapping.carrier_idx, nof_antennas, nof_channels); } } else { - log_h->info("RF Tx channel %d already on freq\n", device_mapping.carrier_idx); + logger.info("RF Tx channel %d already on freq", device_mapping.carrier_idx); } } else { - log_h->error("set_tx_freq: Could not allocate frequency %.1f MHz to carrier %d\n", freq / 1e6, carrier_idx); + logger.error("set_tx_freq: Could not allocate frequency %.1f MHz to carrier %d", freq / 1e6, carrier_idx); } } @@ -770,11 +751,9 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) int nsamples = 0; /* Set time advance for each known device if in auto mode */ if (tx_adv_auto) { - /* This values have been calibrated using the prach_test_usrp tool in srsLTE */ if (device_name == "uhd_b200") { - double srate_khz = round(cur_tx_srate / 1e3); if (srate_khz == 1.92e3) { // 6 PRB @@ -847,11 +826,9 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) } } else if (device_name == "uhd_x300") { - // In X300 TX/RX offset is independent of sampling rate nsamples = 45; } else if (device_name == "bladerf") { - double srate_khz = round(cur_tx_srate / 1e3); if (srate_khz == 1.92e3) { nsamples = 16; @@ -943,27 +920,26 @@ void radio::handle_rf_msg(srslte_rf_error_t error) if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_OVERFLOW) { rf_metrics.rf_o++; rf_metrics.rf_error = true; - log_h->info("Overflow\n"); + logger.info("Overflow"); // inform PHY about overflow phy->radio_overflow(); } else if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_UNDERFLOW) { rf_metrics.rf_u++; rf_metrics.rf_error = true; - log_h->info("Underflow\n"); + logger.info("Underflow"); } else if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_LATE) { rf_metrics.rf_l++; rf_metrics.rf_error = true; - log_h->info("Late (detected in %s)\n", error.opt ? "rx call" : "asynchronous thread"); + logger.info("Late (detected in %s)", error.opt ? "rx call" : "asynchronous thread"); } else if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_RX) { - log_h->error("Fatal radio error occured.\n"); + logger.error("Fatal radio error occured."); phy->radio_failure(); } else if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_OTHER) { std::string str(error.msg); str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); str.erase(std::remove(str.begin(), str.end(), '\r'), str.end()); - str.push_back('\n'); - log_h->info("%s\n", str.c_str()); + logger.info("%s", str.c_str()); } } @@ -1028,7 +1004,7 @@ bool radio::config_rf_channels(const rf_args_t& args) // Parse DL band for this channel c.band.set(args.ch_rx_bands[i].min, args.ch_rx_bands[i].max); dl_rf_channels.push_back(c); - log_h->info("Configuring physical DL channel %d with band-pass filter (%.1f, %.1f)\n", + logger.info("Configuring physical DL channel %d with band-pass filter (%.1f, %.1f)", i, c.band.get_low(), c.band.get_high()); @@ -1036,7 +1012,7 @@ bool radio::config_rf_channels(const rf_args_t& args) // Parse UL band for this channel c.band.set(args.ch_tx_bands[i].min, args.ch_tx_bands[i].max); ul_rf_channels.push_back(c); - log_h->info("Configuring physical UL channel %d with band-pass filter (%.1f, %.1f)\n", + logger.info("Configuring physical UL channel %d with band-pass filter (%.1f, %.1f)", i, c.band.get_low(), c.band.get_high()); diff --git a/lib/src/radio/radio_null.cc b/lib/src/radio/radio_null.cc deleted file mode 100644 index 1205f29be..000000000 --- a/lib/src/radio/radio_null.cc +++ /dev/null @@ -1,20 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#include "srslte/radio/radio_null.h" -#include - -namespace srslte { - -radio_null::radio_null(srslte::logger* logger_) : log("RF"), radio_base(logger_) {} - -} // namespace srslte diff --git a/lib/src/radio/test/benchmark_radio.cc b/lib/src/radio/test/benchmark_radio.cc index 66385f5f8..1f0956ff7 100644 --- a/lib/src/radio/test/benchmark_radio.cc +++ b/lib/src/radio/test/benchmark_radio.cc @@ -35,7 +35,6 @@ using namespace srslte; static std::array radios_args = {}; static char radio_device[64]; -static log_filter log_h; static std::string file_pattern = "radio%d.dat"; static double freq = 2630e6; static uint32_t nof_radios = 1; @@ -207,7 +206,6 @@ static void* plot_thread_run(void* arg) static int init_plots(uint32_t frame_size) { - if (sem_init(&plot_sem, 0, 0)) { perror("sem_init"); exit(-1); @@ -218,7 +216,7 @@ static int init_plots(uint32_t frame_size) uint32_t plot_idx = r * nof_ports + p; fft_plot_buffer[plot_idx] = srslte_vec_cf_malloc(frame_size); if (!fft_plot_buffer[plot_idx]) { - ERROR("Error: Allocating buffer\n"); + ERROR("Error: Allocating buffer"); return SRSLTE_ERROR; } } @@ -226,12 +224,12 @@ static int init_plots(uint32_t frame_size) fft_plot_temp = srslte_vec_f_malloc(frame_size); if (!fft_plot_temp) { - ERROR("Error: Allocating buffer\n"); + ERROR("Error: Allocating buffer"); return SRSLTE_ERROR; } if (srslte_dft_plan_c(&dft_spectrum, frame_size, SRSLTE_DFT_FORWARD)) { - ERROR("Creating DFT spectrum plan\n"); + ERROR("Creating DFT spectrum plan"); return SRSLTE_ERROR; } @@ -293,7 +291,7 @@ static void* radio_thread_run(void* arg) /* Instanciate and allocate memory */ printf("Instantiating objects and allocating memory...\n"); for (uint32_t r = 0; r < nof_radios; r++) { - radio_h[r] = new radio(&log_h); + radio_h[r] = new radio; if (!radio_h[r]) { fprintf(stderr, "Error: Calling radio constructor\n"); goto clean_exit; @@ -308,7 +306,7 @@ static void* radio_thread_run(void* arg) for (uint32_t p = 0; p < nof_ports; p++) { buffers[r][p] = srslte_vec_cf_malloc(frame_size); if (!buffers[r][p]) { - ERROR("Error: Allocating buffer (%d,%d)\n", r, p); + ERROR("Error: Allocating buffer (%d,%d)", r, p); goto clean_exit; } } @@ -364,7 +362,7 @@ static void* radio_thread_run(void* arg) snprintf(filename, 256, file_pattern.c_str(), r); INFO("Opening filesink %s for radio %d", filename, r); if (srslte_filesink_init(&filesink[r], filename, SRSLTE_COMPLEX_FLOAT_BIN)) { - ERROR("Initiating filesink for radio %d\n", r); + ERROR("Initiating filesink for radio %d", r); goto clean_exit; } } @@ -374,11 +372,11 @@ static void* radio_thread_run(void* arg) if (measure_delay) { if (nof_radios > 1) { if (srslte_dft_plan_c(&dft_plan, frame_size, SRSLTE_DFT_FORWARD)) { - ERROR("Creating DFT plan\n"); + ERROR("Creating DFT plan"); goto clean_exit; } if (srslte_dft_plan_c(&idft_plan, frame_size, SRSLTE_DFT_BACKWARD)) { - ERROR("Creating IDFT plan\n"); + ERROR("Creating IDFT plan"); goto clean_exit; } } else { @@ -603,6 +601,8 @@ int main(int argc, char** argv) // Parse args parse_args(argc, argv); + srslog::init(); + if (pthread_create(&radio_thread, NULL, radio_thread_run, NULL)) { perror("pthread_create"); exit(-1); diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index b93970eec..4ffdc44b3 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -62,7 +62,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) return SRSLTE_ERROR; } - std::unique_ptr lte_radio = std::unique_ptr(new srslte::radio(logger)); + std::unique_ptr lte_radio = std::unique_ptr(new srslte::radio); if (!lte_radio) { srslte::console("Error creating radio multi instance.\n"); return SRSLTE_ERROR; @@ -103,7 +103,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) } else if (args.stack.type == "nr") { #ifdef HAVE_5GNR std::unique_ptr nr_stack(new srsenb::gnb_stack_nr(logger)); - std::unique_ptr nr_radio(new srslte::radio_null(logger)); + std::unique_ptr nr_radio(new srslte::radio_null); std::unique_ptr nr_phy(new srsenb::vnf_phy_nr); // Init layers diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index c4469c3d8..d277ee6e4 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -78,7 +78,7 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) return SRSLTE_ERROR; } - std::unique_ptr lte_radio = std::unique_ptr(new srslte::radio(old_logger)); + std::unique_ptr lte_radio = std::unique_ptr(new srslte::radio); if (!lte_radio) { srslte::console("Error creating radio multi instance.\n"); return SRSLTE_ERROR; @@ -128,7 +128,7 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) logger.info("Initializing NR stack"); #ifdef HAVE_5GNR std::unique_ptr nr_stack(new srsue::ue_stack_nr(old_logger)); - std::unique_ptr nr_radio(new srslte::radio_null(old_logger)); + std::unique_ptr nr_radio(new srslte::radio_null); std::unique_ptr nr_phy(new srsue::vnf_phy_nr); std::unique_ptr gw_ptr(new gw()); diff --git a/srsue/test/phy/scell_search_test.cc b/srsue/test/phy/scell_search_test.cc index 5fec081d5..1f4e680b1 100644 --- a/srsue/test/phy/scell_search_test.cc +++ b/srsue/test/phy/scell_search_test.cc @@ -480,11 +480,11 @@ int main(int argc, char** argv) if (earfcn_dl >= 0) { // Create radio log - radio_log = std::unique_ptr(new srslte::log_filter("Radio")); - radio_log->set_level(radio_log_level); + auto& radio_logger = srslog::fetch_basic_logger("RF", false); + radio_logger.set_level(srslog::str_to_basic_level(radio_log_level)); // Create radio - radio = std::unique_ptr(new srslte::radio(radio_log.get())); + radio = std::unique_ptr(new srslte::radio); // Init radio srslte::rf_args_t radio_args = {};