Skip to content

Commit 1251329

Browse files
committed
gr-limesuiteng: direct debug messages into separate logger
1 parent 0d7178d commit 1251329

7 files changed

Lines changed: 53 additions & 54 deletions

File tree

plugins/gr-limesuiteng/lib/sdrdevice_block_base.cc

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ sdrdevice_block_base::sdrdevice_block_base(lime::TRXDir dir,
4343
double sampleRate,
4444
int rf_oversampling,
4545
gr::logger_ptr logger,
46-
gr::logger_ptr debug_baselogger)
46+
gr::logger_ptr debug_logger)
4747
: chipIndex(chipIndex),
4848
direction(dir),
4949
autoAntenna(true),
5050
canWork(false),
51-
baselogger(logger)
51+
baselogger(logger),
52+
debuglogger(debug_logger)
5253
{
5354
devManager = sdrdevice_manager::GetSingleton();
5455
assert(devManager);
@@ -91,20 +92,20 @@ sdrdevice_block_base::sdrdevice_block_base(lime::TRXDir dir,
9192

9293
sdrdevice_block_base::~sdrdevice_block_base()
9394
{
94-
GR_LOG_DEBUG(baselogger, __func__);
95+
GR_LOG_DEBUG(debuglogger, __func__);
9596
ReleaseResources();
9697
}
9798

9899
void sdrdevice_block_base::ReleaseResources()
99100
{
100-
GR_LOG_DEBUG(baselogger, __func__);
101+
GR_LOG_DEBUG(debuglogger, __func__);
101102
devContext.reset();
102103
devManager.reset();
103104
}
104105

105106
bool sdrdevice_block_base::start()
106107
{
107-
GR_LOG_DEBUG(baselogger, __func__);
108+
GR_LOG_DEBUG(debuglogger, __func__);
108109
assert(devContext);
109110

110111
lime::SDRConfig& config = devContext->deviceConfig;
@@ -123,26 +124,25 @@ bool sdrdevice_block_base::start()
123124
return true;
124125
}
125126

126-
GR_LOG_DEBUG(baselogger, "SDRDevice Configure()");
127+
GR_LOG_DEBUG(debuglogger, "SDRDevice Configure()");
127128
config.skipDefaults = !devContext->customBaseConfigFilepath.empty();
128129
if (config.skipDefaults &&
129130
devContext->device->LoadConfig(chipIndex, devContext->customBaseConfigFilepath) !=
130131
OpStatus::Success) {
131132
const std::string msg = fmt::format("Failed to load configuration file {:s}",
132133
devContext->customBaseConfigFilepath);
133-
GR_LOG_ERROR(baselogger, msg);
134+
GR_LOG_CRIT(baselogger, msg);
134135
throw std::runtime_error(msg);
135136
}
136137

137138
if (devContext->device->Configure(config, chipIndex) != OpStatus::Success) {
138139
const std::string msg = fmt::format("Failed to configure device. {:s}",
139140
lime::GetLastErrorMessageCString());
140-
GR_LOG_ERROR(baselogger, msg);
141+
GR_LOG_CRIT(baselogger, msg);
141142
throw std::runtime_error(msg);
142143
return false;
143144
}
144145

145-
GR_LOG_DEBUG(baselogger, "RFStream Create()");
146146
devContext->stream =
147147
devContext->device->StreamCreate(devContext->streamCfg, chipIndex);
148148
if (!devContext->stream)
@@ -151,24 +151,24 @@ bool sdrdevice_block_base::start()
151151
// Start the actual streaming in work(), otherwise multiple devices won't be started
152152
// at the same time
153153
OpStatus status = devContext->stream->StageStart();
154-
GR_LOG_INFO(baselogger, "Device configured and ready.");
154+
GR_LOG_DEBUG(debuglogger, "Device configured and ready.");
155155
canWork = true;
156156
return true;
157157
}
158158

159159
void sdrdevice_block_base::StartRFStreaming()
160160
{
161161
if (devContext->stream->Start() != OpStatus::Success) {
162-
GR_LOG_ERROR(baselogger, "RFStream Start() Failed");
162+
GR_LOG_ERROR(debuglogger, "RFStream Start() Failed");
163163
} else {
164-
GR_LOG_INFO(baselogger, "RFStream Start()");
164+
GR_LOG_DEBUG(debuglogger, "RFStream Start()");
165165
}
166166
}
167167

168168
bool sdrdevice_block_base::stop()
169169
{
170170
assert(devContext);
171-
GR_LOG_DEBUG(baselogger, __func__);
171+
GR_LOG_DEBUG(debuglogger, __func__);
172172
if (direction == TRXDir::Tx)
173173
devContext->sinkBlockCounter--;
174174
else
@@ -178,7 +178,7 @@ bool sdrdevice_block_base::stop()
178178
(devContext->sourceBlockCounter == 0 && devContext->sinkBlockCounter == 0);
179179

180180
if (doStop && devContext->stream) {
181-
GR_LOG_DEBUG(baselogger, "RFStream Stop");
181+
GR_LOG_DEBUG(debuglogger, "RFStream Stop");
182182
devContext->stream->Stop();
183183
devContext->stream->Teardown();
184184
devContext->stream.reset();
@@ -204,10 +204,9 @@ double sdrdevice_block_base::set_lo_frequency(double frequencyHz)
204204
if (!devContext)
205205
return frequencyHz;
206206

207-
GR_LOG_INFO(baselogger, fmt::format("{:s} {:f}", __func__, frequencyHz));
208-
209207
for (const int ch : devContext->streamCfg.channels.at(direction)) {
210208
if (devContext->stream) {
209+
GR_LOG_DEBUG(debuglogger, fmt::format("{:s} {:f}", __func__, frequencyHz));
211210
devContext->device->SetFrequency(chipIndex, direction, ch, frequencyHz);
212211
} else {
213212
if (direction == TRXDir::Tx)
@@ -227,9 +226,9 @@ double sdrdevice_block_base::set_lpf_bandwidth(double bandwidthHz)
227226
if (!devContext)
228227
return bandwidthHz;
229228

230-
GR_LOG_INFO(baselogger, fmt::format("{:s} {:f}", __func__, bandwidthHz));
231229
for (const int ch : devContext->streamCfg.channels.at(direction)) {
232230
if (devContext->stream) {
231+
GR_LOG_DEBUG(debuglogger, fmt::format("{:s} {:f}", __func__, bandwidthHz));
233232
devContext->device->SetLowPassFilter(chipIndex, direction, ch, bandwidthHz);
234233
} else {
235234
if (direction == TRXDir::Tx)
@@ -247,13 +246,13 @@ double sdrdevice_block_base::set_gfir_bandwidth(double bandwidthHz)
247246
return bandwidthHz;
248247

249248
const bool enableFilter = bandwidthHz > 0;
250-
GR_LOG_INFO(baselogger,
251-
fmt::format("{:s} {:f} {:s}",
252-
__func__,
253-
bandwidthHz,
254-
enableFilter ? "enabled" : "disabled"));
255249
for (const int ch : devContext->streamCfg.channels.at(direction)) {
256250
if (devContext->stream) {
251+
GR_LOG_DEBUG(debuglogger,
252+
fmt::format("{:s} {:f} {:s}",
253+
__func__,
254+
bandwidthHz,
255+
enableFilter ? "enabled" : "disabled"));
257256
ChannelConfig::Direction::GFIRFilter filter;
258257
filter.enabled = enableFilter;
259258
filter.bandwidth = bandwidthHz;
@@ -299,7 +298,6 @@ bool sdrdevice_block_base::set_antenna(const std::string& antenna_name)
299298
if (!devContext)
300299
return false;
301300

302-
GR_LOG_INFO(baselogger, fmt::format("{:s} {:s}", __func__, antenna_name));
303301
const auto& antennas =
304302
devContext->device->GetDescriptor().rfSOC.at(chipIndex).pathNames.at(direction);
305303
auto antennaFind = antennas.begin();
@@ -310,6 +308,7 @@ bool sdrdevice_block_base::set_antenna(const std::string& antenna_name)
310308
double freq;
311309
int ch = devContext->streamCfg.channels.at(direction).front();
312310
if (devContext->stream) {
311+
GR_LOG_DEBUG(debuglogger, fmt::format("{:s} {:s}", __func__, antenna_name));
313312
freq = devContext->device->GetFrequency(chipIndex, direction, ch);
314313
} else {
315314
if (direction == TRXDir::Tx)
@@ -322,7 +321,8 @@ bool sdrdevice_block_base::set_antenna(const std::string& antenna_name)
322321
antennas,
323322
devContext->device->GetDescriptor().rfSOC.at(chipIndex).antennaRange.at(
324323
direction));
325-
GR_LOG_INFO(baselogger, fmt::format("auto selected antenna: {:s}", bestAntenna));
324+
GR_LOG_DEBUG(debuglogger,
325+
fmt::format("auto selected antenna: {:s}", bestAntenna));
326326
antennaFind = std::find(antennas.begin(), antennas.end(), bestAntenna);
327327
} else
328328
antennaFind = std::find(antennas.begin(), antennas.end(), antenna_name);
@@ -332,7 +332,7 @@ bool sdrdevice_block_base::set_antenna(const std::string& antenna_name)
332332
ss << "Antenna " << antenna_name << " not found. Available:" << std::endl;
333333
for (const auto& iter : antennas)
334334
ss << "\t\"" << iter << "\"" << std::endl;
335-
GR_LOG_ERROR(baselogger, ss.str());
335+
GR_LOG_ERROR(debuglogger, ss.str());
336336
return false;
337337
}
338338

@@ -362,29 +362,23 @@ double sdrdevice_block_base::set_gain(lime::eGainTypes type, double gain_value)
362362

363363
const std::string gainName = lime::ToString(type);
364364

365-
GR_LOG_INFO(baselogger,
366-
fmt::format("{:s} {:s} {:f}", __func__, gainName, gain_value));
367365
const RFSOCDescriptor& desc = devContext->device->GetDescriptor().rfSOC.at(chipIndex);
368366

369367
lime::Range gain_range = desc.gainRange.at(direction).at(type);
370-
GR_LOG_INFO(baselogger,
371-
fmt::format("{:s} {:s} gain range: {:f}:{:f}",
372-
__func__,
373-
gainName,
374-
gain_range.min,
375-
gain_range.max));
376368
if (gain_value > gain_range.max) {
377369
gain_value = gain_range.max;
378-
GR_LOG_WARN(baselogger,
370+
GR_LOG_WARN(debuglogger,
379371
fmt::format("{:s} clip gain to {:f}", __func__, gain_value));
380372
} else if (gain_value < gain_range.min) {
381373
gain_value = gain_range.min;
382-
GR_LOG_WARN(baselogger,
374+
GR_LOG_WARN(debuglogger,
383375
fmt::format("{:s} clip gain to {:f}", __func__, gain_value));
384376
}
385377

386378
for (const int ch : devContext->streamCfg.channels.at(direction)) {
387379
if (devContext->stream) {
380+
GR_LOG_DEBUG(debuglogger,
381+
fmt::format("{:s} {:s} {:f}", __func__, gainName, gain_value));
388382
devContext->device->SetGain(chipIndex, direction, ch, type, gain_value);
389383
} else {
390384
if (direction == TRXDir::Tx)
@@ -401,12 +395,13 @@ double sdrdevice_block_base::set_nco_frequency(double frequency_offset_Hz)
401395
if (!devContext)
402396
return frequency_offset_Hz;
403397

404-
GR_LOG_INFO(baselogger, fmt::format("{:s} {:f}", __func__, frequency_offset_Hz));
405398
if (!devContext)
406399
return frequency_offset_Hz;
407400

408401
for (const int ch : devContext->streamCfg.channels.at(direction)) {
409402
if (devContext->stream) {
403+
GR_LOG_DEBUG(debuglogger,
404+
fmt::format("{:s} {:f}", __func__, frequency_offset_Hz));
410405
devContext->device->SetNCOFrequency(
411406
chipIndex, direction, ch, 0, frequency_offset_Hz);
412407
} else {

plugins/gr-limesuiteng/lib/sdrdevice_block_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class sdrdevice_block_base
5959

6060

6161
gr::logger_ptr baselogger;
62+
gr::logger_ptr debuglogger;
6263
};
6364

6465
} // namespace limesuiteng

plugins/gr-limesuiteng/lib/sdrdevice_manager.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ static void gr_loghandler(const lime::LogLevel level, const char* message)
4141
GR_LOG_INFO(logger, message);
4242
break;
4343

44+
case lime::LogLevel::Verbose:
4445
case lime::LogLevel::Debug:
45-
GR_LOG_DEBUG(logger, message);
46+
GR_LOG_DEBUG(debug_logger, message);
4647
break;
4748

4849
default:
@@ -78,9 +79,9 @@ static bool FuzzyHandleMatch(const DeviceHandle& handle, const std::string_view
7879
std::shared_ptr<sdrdevice_manager> sdrdevice_manager::GetSingleton()
7980
{
8081
if (!g_deviceManager) {
81-
g_deviceManager = std::make_shared<sdrdevice_manager>();
8282
if (!logger)
8383
gr::configure_default_loggers(logger, debug_logger, "LimeSuiteNG");
84+
g_deviceManager = std::make_shared<sdrdevice_manager>();
8485
lime::registerLogHandler(gr_loghandler);
8586

8687
logger->info(fmt::format("version: {:s} build {:s}",
@@ -90,9 +91,9 @@ std::shared_ptr<sdrdevice_manager> sdrdevice_manager::GetSingleton()
9091
return g_deviceManager;
9192
}
9293

93-
sdrdevice_manager::sdrdevice_manager() : _logger("SDRDeviceManager")
94+
sdrdevice_manager::sdrdevice_manager()
9495
{
95-
_logger.debug("sdrdevice_manager created");
96+
debug_logger->debug("sdrdevice_manager created");
9697
enumeratedHandles = lime::DeviceRegistry::enumerate();
9798
if (enumeratedHandles.empty()) {
9899
throw std::runtime_error(
@@ -102,7 +103,7 @@ sdrdevice_manager::sdrdevice_manager() : _logger("SDRDeviceManager")
102103

103104
sdrdevice_manager::~sdrdevice_manager()
104105
{
105-
_logger.debug("sdrdevice_manager destroyed");
106+
debug_logger->debug("sdrdevice_manager destroyed");
106107
for (auto& ctx : m_contexts) {
107108
ctx->stream.reset();
108109
lime::DeviceRegistry::freeDevice(ctx->device.release());
@@ -131,7 +132,7 @@ bool sdrdevice_manager::GetDeviceFullHandle(const std::string_view hintArguments
131132
}
132133

133134
if (filteredHandles.empty()) {
134-
_logger.error("No devices match the handle");
135+
logger->error("No devices match the handle");
135136
return false;
136137
}
137138

@@ -140,7 +141,7 @@ bool sdrdevice_manager::GetDeviceFullHandle(const std::string_view hintArguments
140141
ss << "Ambiguous device argument, matches:\n";
141142
for (const auto& h : filteredHandles)
142143
ss << '\t' << h.Serialize() << std::endl;
143-
_logger.error(ss.str());
144+
logger->error(ss.str());
144145
return false;
145146
}
146147

@@ -162,15 +163,15 @@ sdrdevice_manager::GetDeviceContextByHandle(const std::string& deviceHandleHint)
162163

163164
std::shared_ptr<sdrdevice_context>& ctx =
164165
m_contexts.emplace_back(std::make_shared<sdrdevice_context>());
165-
_logger.info(fmt::format("Connecting device: \"{:s}\"", handle.Serialize()));
166+
logger->info(fmt::format("Connecting device: \"{:s}\"", handle.Serialize()));
166167
ctx->handle = handle;
167168
ctx->device = std::unique_ptr<SDRDevice>(DeviceRegistry::makeDevice(handle));
168169

169170
ctx->device->SetMessageLogCallback(gr_loghandler_string);
170171

171172
if (!ctx->device) {
172173
m_contexts.pop_back();
173-
_logger.error(fmt::format("Unable to use device: \"{:s}\"", handle.Serialize()));
174+
logger->error(fmt::format("Unable to use device: \"{:s}\"", handle.Serialize()));
174175
return nullptr;
175176
}
176177
return ctx;

plugins/gr-limesuiteng/lib/sdrdevice_manager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class sdrdevice_manager
5656

5757
std::list<std::shared_ptr<sdrdevice_context>> m_contexts;
5858
std::vector<lime::DeviceHandle> enumeratedHandles;
59-
gr::logger _logger;
6059
};
6160

6261
} // namespace limesuiteng

plugins/gr-limesuiteng/lib/sdrdevice_sink_impl.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ sdrdevice_sink_impl::sdrdevice_sink_impl(const std::string& alias,
8181
sampleRate,
8282
rf_oversampling,
8383
d_logger,
84-
d_logger)
84+
d_debug_logger)
8585
{
8686
// GNU radio can start feeding Sink Work() with 1 sample chunks, somehow that makes
8787
// the gnu radio boost thread to die. Setting the output granularity seems to
8888
// workaround that.
8989
set_output_multiple(256);
9090
}
9191

92-
sdrdevice_sink_impl::~sdrdevice_sink_impl() { GR_LOG_DEBUG(d_logger, __func__); }
92+
sdrdevice_sink_impl::~sdrdevice_sink_impl() { GR_LOG_DEBUG(d_debug_logger, __func__); }
9393

9494
bool sdrdevice_sink_impl::start() { return sdrdevice_block_base::start(); }
9595

@@ -100,7 +100,7 @@ int sdrdevice_sink_impl::work(int noutput_items,
100100
gr_vector_void_star& output_items)
101101
{
102102
if (!canWork) {
103-
GR_LOG_INFO(baselogger, "WORK_DONE");
103+
GR_LOG_DEBUG(d_debug_logger, "WORK_DONE");
104104
return gr::block::work_return_t::WORK_DONE;
105105
}
106106

plugins/gr-limesuiteng/lib/sdrdevice_source_impl.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ sdrdevice_source_impl::sdrdevice_source_impl(const std::string& alias,
8181
sampleRate,
8282
rf_oversampling,
8383
d_logger,
84-
d_logger)
84+
d_debug_logger)
8585
{
8686
}
8787

88-
sdrdevice_source_impl::~sdrdevice_source_impl() { GR_LOG_DEBUG(d_logger, __func__); }
88+
sdrdevice_source_impl::~sdrdevice_source_impl()
89+
{
90+
GR_LOG_DEBUG(d_debug_logger, __func__);
91+
}
8992

9093
bool sdrdevice_source_impl::start() { return sdrdevice_block_base::start(); }
9194

@@ -96,7 +99,7 @@ int sdrdevice_source_impl::work(int noutput_items,
9699
gr_vector_void_star& output_items)
97100
{
98101
if (!canWork) {
99-
GR_LOG_INFO(baselogger, "WORK_DONE");
102+
GR_LOG_DEBUG(d_debug_logger, "WORK_DONE");
100103
return gr::block::work_return_t::WORK_DONE;
101104
}
102105

src/boards/LMS7002M_SDRDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ OpStatus LMS7002M_SDRDevice::SetLowPassFilter(uint8_t moduleIndex, TRXDir trx, u
300300
if (status != OpStatus::Success)
301301
return status;
302302

303-
lime::info(ToString(trx) + " LPF configured"s);
303+
lime::debug(ToString(trx) + " LPF configured"s);
304304
return OpStatus::Success;
305305
}
306306

@@ -1156,7 +1156,7 @@ OpStatus LMS7002M_SDRDevice::LMS7002M_SetSampleRate(double f_Hz, uint8_t rxDecim
11561156
return lime::ReportError(
11571157
OpStatus::NotSupported, "Rx decimation(2^%i) > Tx interpolation(2^%i) currently not supported", hbd_ovr, hbi_ovr);
11581158
}
1159-
lime::info("Sampling rate set(%.3f MHz): CGEN:%.3f MHz, Decim: 2^%i, Interp: 2^%i",
1159+
lime::debug("Sampling rate set(%.3f MHz): CGEN:%.3f MHz, Decim: 2^%i, Interp: 2^%i",
11601160
f_Hz / 1e6,
11611161
cgenFreq / 1e6,
11621162
1 + hbd_ovr,

0 commit comments

Comments
 (0)