From 2117aa93e22358792f26ebd2ab0db87625bb0d7e Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 10 Nov 2021 11:15:09 +0100 Subject: [PATCH] slot_worker: add compile time option to write baseband signal to file --- srsenb/src/phy/nr/slot_worker.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/srsenb/src/phy/nr/slot_worker.cc b/srsenb/src/phy/nr/slot_worker.cc index b2389f0c2..fd67f4537 100644 --- a/srsenb/src/phy/nr/slot_worker.cc +++ b/srsenb/src/phy/nr/slot_worker.cc @@ -14,6 +14,13 @@ #include "srsran/common/buffer_pool.h" #include "srsran/common/common.h" +#define DEBUG_WRITE_FILE + +#ifdef DEBUG_WRITE_FILE +FILE* f; +static uint32_t num_slots = 0; +#endif + namespace srsenb { namespace nr { slot_worker::slot_worker(srsran::phy_common_interface& common_, @@ -86,6 +93,12 @@ bool slot_worker::init(const args_t& args) return false; } +#ifdef DEBUG_WRITE_FILE + const char* filename = "nr_baseband.dat"; + printf("Opening %s to dump baseband\n", filename); + f = fopen(filename, "w"); +#endif + return true; } @@ -407,6 +420,18 @@ void slot_worker::work_imp() } common.worker_end(context, true, tx_rf_buffer); + +#ifdef DEBUG_WRITE_FILE + fwrite(tx_rf_buffer.get(0), tx_rf_buffer.get_nof_samples() * sizeof(cf_t), 1, f); +#endif + +#ifdef DEBUG_WRITE_FILE + if (num_slots == 30) { + fclose(f); + exit(-1); + } + num_slots++; +#endif } bool slot_worker::set_common_cfg(const srsran_carrier_nr_t& carrier,