diff options
author | Jacob Gilbert <jacob.gilbert@protonmail.com> | 2021-02-15 15:07:45 -0800 |
---|---|---|
committer | Martin Braun <martin@gnuradio.org> | 2021-02-25 04:09:18 -0800 |
commit | 044b4a3b49b67adfe53e0e88f9adf847a25fad61 (patch) | |
tree | 4d4e54c46eaddd6c2b63c7693996c307f477bf0e /gr-blocks/lib | |
parent | f42166bba7dd3f4df5bc164473fcfe0880d057ef (diff) |
gr-blocks: deprecate print_pdu port of message_debug block
Having two print ports on this block has confused a number of people,
most recently issue #4191, and combining them is straightforward and
should make this block easier to use. The print_pdu formatting is now
be applied on the print port if the message is a PDU.
Signed-off-by: Jacob Gilbert <jacob.gilbert@protonmail.com>
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r-- | gr-blocks/lib/message_debug_impl.cc | 55 | ||||
-rw-r--r-- | gr-blocks/lib/message_debug_impl.h | 5 |
2 files changed, 32 insertions, 28 deletions
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 |