summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2020-04-11 01:05:51 +0200
committerMarcus Müller <marcus@hostalia.de>2020-04-13 15:55:41 +0200
commite52e4b1eb1a6d8e769b41d3f45f105f39b67b14c (patch)
tree7e7b62274d12819d966ce8534584f7e667b2de98
parent95178211eb87d6bf40d51210cf501e6e840863fe (diff)
dtv: replace stderr logging by calls to GR's logging facilties
This is but a first step; a lot of code in gr-dtv is very much libc in C++, thus we'll have a lot of printf's to deal with in the future.
-rw-r--r--gr-dtv/lib/atsc/atsc_fs_checker_impl.cc13
-rw-r--r--gr-dtv/lib/atsc/atsc_fs_checker_impl.h3
-rw-r--r--gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc38
-rw-r--r--gr-dtv/lib/dvbt/dvbt_reference_signals_impl.h3
4 files changed, 28 insertions, 29 deletions
diff --git a/gr-dtv/lib/atsc/atsc_fs_checker_impl.cc b/gr-dtv/lib/atsc/atsc_fs_checker_impl.cc
index 838b60cb73..2295bd783c 100644
--- a/gr-dtv/lib/atsc/atsc_fs_checker_impl.cc
+++ b/gr-dtv/lib/atsc/atsc_fs_checker_impl.cc
@@ -18,6 +18,7 @@
#include "atsc_types.h"
#include "gnuradio/dtv/atsc_consts.h"
#include <gnuradio/io_signature.h>
+#include <string>
#define ATSC_SEGMENTS_PER_DATA_FIELD 313
@@ -37,6 +38,7 @@ atsc_fs_checker_impl::atsc_fs_checker_impl()
io_signature::make(1, 1, sizeof(atsc_soft_data_segment)),
io_signature::make(1, 1, sizeof(atsc_soft_data_segment)))
{
+ gr::configure_default_loggers(d_logger, d_debug_logger, "dtv_atsc_fs_checker");
reset();
}
@@ -69,7 +71,8 @@ int atsc_fs_checker_impl::general_work(int noutput_items,
for (int j = 0; j < LENGTH_511 && errors < PN511_ERROR_LIMIT; j++)
errors += (in[i].data[j + OFFSET_511] >= 0) ^ atsc_pn511[j];
- // std::cout << errors << std::endl;
+ GR_LOG_DEBUG(d_debug_logger,
+ std::string("second PN63 error count = ") + std::to_string(errors));
if (errors < PN511_ERROR_LIMIT) { // 511 pattern is good.
// determine if this is field 1 or field 2
@@ -79,17 +82,17 @@ int atsc_fs_checker_impl::general_work(int noutput_items,
// we should have either field 1 (== PN63) or field 2 (== ~PN63)
if (errors <= PN63_ERROR_LIMIT) {
- // std::cout << "Found FIELD_SYNC_1" << std::endl;
+ GR_LOG_DEBUG(d_debug_logger, "Found FIELD_SYNC_1")
d_field_num = 1; // We are in field number 1 now
d_segment_num = -1; // This is the first segment
} else if (errors >= (LENGTH_2ND_63 - PN63_ERROR_LIMIT)) {
- // std::cout << "Found FIELD_SYNC_2" << std::endl;
+ GR_LOG_DEBUG(d_debug_logger, "Found FIELD_SYNC_2")
d_field_num = 2; // We are in field number 2 now
d_segment_num = -1; // This is the first segment
} else {
// should be extremely rare.
- std::cerr << "!!! atsc_fs_checker: PN63 error count = " << errors
- << std::endl;
+ GR_LOG_WARN(d_logger,
+ std::string("PN63 error count = ") + std::to_string(errors));
}
}
diff --git a/gr-dtv/lib/atsc/atsc_fs_checker_impl.h b/gr-dtv/lib/atsc/atsc_fs_checker_impl.h
index 34899990a3..30f2a892a1 100644
--- a/gr-dtv/lib/atsc/atsc_fs_checker_impl.h
+++ b/gr-dtv/lib/atsc/atsc_fs_checker_impl.h
@@ -13,6 +13,7 @@
#include "atsc_syminfo_impl.h"
#include <gnuradio/dtv/atsc_fs_checker.h>
+#include <gnuradio/logger.h>
namespace gr {
namespace dtv {
@@ -27,6 +28,8 @@ private:
unsigned char d_bit_sr[SRSIZE]; // binary decision shift register
int d_field_num;
int d_segment_num;
+ gr::logger_ptr d_logger;
+ gr::logger_ptr d_debug_logger;
static constexpr int OFFSET_511 = 4; // offset to second PN 63 pattern
static constexpr int LENGTH_511 = 511; // length of PN 63 pattern
diff --git a/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc b/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc
index 14dfc03afc..73db55bb0f 100644
--- a/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc
+++ b/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc
@@ -102,6 +102,8 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
d_prev_mod_symbol_index(0),
d_mod_symbol_index(0)
{
+
+ gr::configure_default_loggers(d_logger, d_debug_logger, "dvbt_pilot_gen");
// Determine parameters from config file
d_Kmin = config.d_Kmin;
d_Kmax = config.d_Kmax;
@@ -139,7 +141,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// allocate PRBS buffer
d_wk = new (std::nothrow) char[d_Kmax - d_Kmin + 1];
if (d_wk == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_wk." << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_wk.");
throw std::bad_alloc();
}
// Generate wk sequence
@@ -148,9 +150,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// allocate buffer for scattered pilots
d_spilot_carriers_val = new (std::nothrow) gr_complex[d_Kmax - d_Kmin + 1];
if (d_spilot_carriers_val == NULL) {
- std::cerr
- << "Reference Signals, cannot allocate memory for d_spilot_carriers_val."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_spilot_carriers_val.");
delete[] d_wk;
throw std::bad_alloc();
}
@@ -158,8 +158,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// allocate buffer for channel gains (for each useful carrier)
d_channel_gain = new (std::nothrow) gr_complex[d_Kmax - d_Kmin + 1];
if (d_channel_gain == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_channel_gain."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_channel_gain.");
delete[] d_spilot_carriers_val;
delete[] d_wk;
throw std::bad_alloc();
@@ -168,8 +167,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// Allocate buffer for continual pilots phase diffs
d_known_phase_diff = new (std::nothrow) float[d_cpilot_carriers_size - 1];
if (d_known_phase_diff == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_known_phase_diff."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_known_phase_diff.");
delete[] d_channel_gain;
delete[] d_spilot_carriers_val;
delete[] d_wk;
@@ -184,8 +182,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
d_cpilot_phase_diff = new (std::nothrow) float[d_cpilot_carriers_size - 1];
if (d_cpilot_phase_diff == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_cpilot_phase_diff."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_cpilot_phase_diff.");
delete[] d_known_phase_diff;
delete[] d_channel_gain;
delete[] d_spilot_carriers_val;
@@ -196,8 +193,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// Allocate buffer for derotated input symbol
d_derot_in = new (std::nothrow) gr_complex[d_fft_length];
if (d_derot_in == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_derot_in."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_derot_in.");
delete[] d_cpilot_phase_diff;
delete[] d_known_phase_diff;
delete[] d_channel_gain;
@@ -209,8 +205,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// allocate buffer for first tps symbol constellation
d_tps_carriers_val = new (std::nothrow) gr_complex[d_tps_carriers_size];
if (d_tps_carriers_val == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_tps_carriers_val."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_tps_carriers_val.");
delete[] d_derot_in;
delete[] d_cpilot_phase_diff;
delete[] d_known_phase_diff;
@@ -223,8 +218,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// allocate tps data buffer
d_tps_data = new (std::nothrow) unsigned char[d_symbols_per_frame];
if (d_tps_data == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_tps_data."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_tps_data.");
delete[] d_tps_carriers_val;
delete[] d_derot_in;
delete[] d_cpilot_phase_diff;
@@ -237,8 +231,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
d_prev_tps_symbol = new (std::nothrow) gr_complex[d_tps_carriers_size];
if (d_prev_tps_symbol == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_prev_tps_symbol."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_prev_tps_symbol.");
delete[] d_tps_data;
delete[] d_tps_carriers_val;
delete[] d_derot_in;
@@ -253,8 +246,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
d_tps_symbol = new (std::nothrow) gr_complex[d_tps_carriers_size];
if (d_tps_symbol == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_tps_symbol."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_tps_symbol.");
delete[] d_prev_tps_symbol;
delete[] d_tps_data;
delete[] d_tps_carriers_val;
@@ -282,8 +274,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// Allocate buffer for channel estimation carriers
d_chanestim_carriers = new (std::nothrow) int[d_Kmax - d_Kmin + 1];
if (d_chanestim_carriers == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_chanestim_carriers."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_chanestim_carriers.");
delete[] d_tps_symbol;
delete[] d_prev_tps_symbol;
delete[] d_tps_data;
@@ -300,8 +291,7 @@ dvbt_pilot_gen::dvbt_pilot_gen(const dvbt_configure& c)
// Allocate buffer for payload carriers
d_payload_carriers = new (std::nothrow) int[d_Kmax - d_Kmin + 1];
if (d_payload_carriers == NULL) {
- std::cerr << "Reference Signals, cannot allocate memory for d_payload_carriers."
- << std::endl;
+ GR_LOG_ERROR(d_logger, "cannot allocate memory for d_payload_carriers.");
delete[] d_chanestim_carriers;
delete[] d_tps_symbol;
delete[] d_prev_tps_symbol;
diff --git a/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.h b/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.h
index 2f8ef4215a..8db618f1c5 100644
--- a/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.h
+++ b/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.h
@@ -12,6 +12,7 @@
#include "dvbt_configure.h"
#include <gnuradio/dtv/dvbt_reference_signals.h>
#include <gnuradio/fft/fft.h>
+#include <gnuradio/logger.h>
#include <deque>
#include <vector>
@@ -194,6 +195,8 @@ private:
void process_payload_data(const gr_complex* in, gr_complex* out);
public:
+ gr::logger_ptr d_logger;
+ gr::logger_ptr d_debug_logger;
dvbt_pilot_gen(const dvbt_configure& config);
~dvbt_pilot_gen();