summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-blocks/include/gnuradio/blocks/message_debug.h12
-rw-r--r--gr-blocks/lib/message_debug_impl.cc55
-rw-r--r--gr-blocks/lib/message_debug_impl.h5
-rw-r--r--gr-blocks/python/blocks/bindings/message_debug_python.cc4
4 files changed, 40 insertions, 36 deletions
diff --git a/gr-blocks/include/gnuradio/blocks/message_debug.h b/gr-blocks/include/gnuradio/blocks/message_debug.h
index d2cfc59f24..14ded692f4 100644
--- a/gr-blocks/include/gnuradio/blocks/message_debug.h
+++ b/gr-blocks/include/gnuradio/blocks/message_debug.h
@@ -27,14 +27,13 @@ namespace blocks {
* The message debug block is used to capture and print or store
* messages as they are received. Any block that generates a
* message may connect that message port to one or more of the
- * three message input ports of this debug block. The message
+ * two message input ports of this debug block. The message
* ports are:
*
* \li print: prints the message directly to standard out.
* \li store: stores the message in an internal vector. May be
* access using the get_message function.
- * \li print_pdu: specifically designed to handle formatted PDUs
- * (see pdu.h).
+ * \li print_pdu: DEPRECATED! use print() for all printing
*/
class BLOCKS_API message_debug : virtual public block
{
@@ -43,9 +42,10 @@ public:
typedef std::shared_ptr<message_debug> sptr;
/*!
- * \brief Build the message debug block. It takes no parameters
- * and has three message ports: print, store, and
- * print_pdu.
+ * \brief Build the message debug block. It takes a single parameter that can be used
+ * to disable PDU vector printing and has two message ports: print and store.
+ *
+ * \param en_uvec Enable PDU Vector Printing.
*/
static sptr make(bool en_uvec = true);
diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc
index 557bbfd106..0dd2c834de 100644
--- a/gr-blocks/lib/message_debug_impl.cc
+++ b/gr-blocks/lib/message_debug_impl.cc
@@ -46,34 +46,13 @@ void message_debug_impl::print(pmt::pmt_t msg)
{
std::stringstream sout;
- sout << "******* MESSAGE DEBUG PRINT ********" << std::endl
- << pmt::write_string(msg) << std::endl
- << "************************************" << std::endl;
- std::cout << sout.str();
-}
-
-void message_debug_impl::store(pmt::pmt_t msg)
-{
- gr::thread::scoped_lock guard(d_mutex);
- d_messages.push_back(msg);
-}
-
-void message_debug_impl::print_pdu(pmt::pmt_t pdu)
-{
- if (!pmt::is_pdu(pdu)) {
- GR_LOG_WARN(d_logger, "Non PDU type message received. Dropping.");
- return;
- }
-
- std::stringstream sout;
+ if (pmt::is_pdu(msg)) {
+ pmt::pmt_t meta = pmt::car(msg);
+ pmt::pmt_t vector = pmt::cdr(msg);
- pmt::pmt_t meta = pmt::car(pdu);
- pmt::pmt_t vector = pmt::cdr(pdu);
+ sout << "***** VERBOSE PDU DEBUG PRINT ******" << std::endl
+ << pmt::write_string(meta) << std::endl;
- sout << "***** VERBOSE PDU DEBUG PRINT ******" << std::endl
- << pmt::write_string(meta) << std::endl;
-
- if (pmt::is_uniform_vector(vector)) {
size_t len = pmt::blob_length(vector);
if (d_en_uvec) {
sout << "pdu length = " << len << " bytes" << std::endl
@@ -93,14 +72,36 @@ void message_debug_impl::print_pdu(pmt::pmt_t pdu)
} else {
sout << "pdu length = " << len << " bytes (printing disabled)" << std::endl;
}
+
} else {
- sout << "Message CDR is not a uniform vector..." << std::endl;
+ sout << "******* MESSAGE DEBUG PRINT ********" << std::endl
+ << pmt::write_string(msg) << std::endl;
}
sout << "************************************" << std::endl;
std::cout << sout.str();
}
+void message_debug_impl::store(pmt::pmt_t msg)
+{
+ gr::thread::scoped_lock guard(d_mutex);
+ d_messages.push_back(msg);
+}
+
+// ! DEPRECATED as of 3.10 use print() for all printing!
+void message_debug_impl::print_pdu(pmt::pmt_t pdu)
+{
+ if (pmt::is_pdu(pdu)) {
+ GR_LOG_INFO(d_logger,
+ "The `print_pdu` port is deprecated and will be removed; forwarding "
+ "to `print`.");
+ this->print(pdu);
+ } else {
+ GR_LOG_INFO(d_logger, "The `print_pdu` port is deprecated and will be removed.");
+ GR_LOG_WARN(d_logger, "Non PDU type message received. Dropping.");
+ }
+}
+
int message_debug_impl::num_messages() { return (int)d_messages.size(); }
pmt::pmt_t message_debug_impl::get_message(int i)
diff --git a/gr-blocks/lib/message_debug_impl.h b/gr-blocks/lib/message_debug_impl.h
index c9fc65391c..b7eba50160 100644
--- a/gr-blocks/lib/message_debug_impl.h
+++ b/gr-blocks/lib/message_debug_impl.h
@@ -30,7 +30,8 @@ private:
* This port receives messages from the scheduler's message
* handling mechanism and prints it to stdout. This message
* handler function is only meant to be used by the scheduler to
- * handle messages posted to port 'print'.
+ * handle messages posted to port 'print'. If the message is a
+ * PDU, special formatting will be applied.
*
* \param msg A pmt message passed from the scheduler's message handling.
*/
@@ -39,6 +40,8 @@ private:
/*!
* \brief PDU formatted messages received in this port are printed to stdout.
*
+ * DEPRECATED as of 3.10 use print() for all printing!
+ *
* This port receives messages from the scheduler's message
* handling mechanism and prints it to stdout. This message
* handler function is only meant to be used by the scheduler to
diff --git a/gr-blocks/python/blocks/bindings/message_debug_python.cc b/gr-blocks/python/blocks/bindings/message_debug_python.cc
index 600fe23588..a351c8c968 100644
--- a/gr-blocks/python/blocks/bindings/message_debug_python.cc
+++ b/gr-blocks/python/blocks/bindings/message_debug_python.cc
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 Free Software Foundation, Inc.
+ * Copyright 2021 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(message_debug.h) */
-/* BINDTOOL_HEADER_FILE_HASH(5768fa881c26e7018f934e8997ac36de) */
+/* BINDTOOL_HEADER_FILE_HASH(27c3ba26dd33d2ecd535857d5ea26ed8) */
/***********************************************************************************/
#include <pybind11/complex.h>