summaryrefslogtreecommitdiff
path: root/gr-blocks/lib/message_debug_impl.cc
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2019-08-07 21:45:12 +0200
committerMarcus Müller <marcus@hostalia.de>2019-08-09 23:04:28 +0200
commitf7bbf2c1d8d780294f3e016aff239ca35eb6516e (patch)
treee09ab6112e02b2215b2d59ac24d3d6ea2edac745 /gr-blocks/lib/message_debug_impl.cc
parent78431dc6941e3acc67c858277dfe4a0ed583643c (diff)
Tree: clang-format without the include sorting
Diffstat (limited to 'gr-blocks/lib/message_debug_impl.cc')
-rw-r--r--gr-blocks/lib/message_debug_impl.cc130
1 files changed, 58 insertions, 72 deletions
diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc
index 8bab788261..a8c84aa509 100644
--- a/gr-blocks/lib/message_debug_impl.cc
+++ b/gr-blocks/lib/message_debug_impl.cc
@@ -30,91 +30,77 @@
#include <iostream>
namespace gr {
- namespace blocks {
-
- message_debug::sptr
- message_debug::make()
- {
- return gnuradio::get_initial_sptr
- (new message_debug_impl());
- }
-
- void
- message_debug_impl::print(pmt::pmt_t msg)
- {
- std::cout << "******* MESSAGE DEBUG PRINT ********\n";
- pmt::print(msg);
- std::cout << "************************************\n";
- }
-
- 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)
- {
- pmt::pmt_t meta = pmt::car(pdu);
- pmt::pmt_t vector = pmt::cdr(pdu);
- std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n";
- pmt::print(meta);
- size_t len = pmt::blob_length(vector);
- std::cout << "pdu_length = " << len << std::endl;
- std::cout << "contents = " << std::endl;
- size_t offset(0);
- const uint8_t* d = (const uint8_t*) pmt::uniform_vector_elements(vector, offset);
- for(size_t i=0; i<len; i+=16){
+namespace blocks {
+
+message_debug::sptr message_debug::make()
+{
+ return gnuradio::get_initial_sptr(new message_debug_impl());
+}
+
+void message_debug_impl::print(pmt::pmt_t msg)
+{
+ std::cout << "******* MESSAGE DEBUG PRINT ********\n";
+ pmt::print(msg);
+ std::cout << "************************************\n";
+}
+
+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)
+{
+ pmt::pmt_t meta = pmt::car(pdu);
+ pmt::pmt_t vector = pmt::cdr(pdu);
+ std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n";
+ pmt::print(meta);
+ size_t len = pmt::blob_length(vector);
+ std::cout << "pdu_length = " << len << std::endl;
+ std::cout << "contents = " << std::endl;
+ size_t offset(0);
+ const uint8_t* d = (const uint8_t*)pmt::uniform_vector_elements(vector, offset);
+ for (size_t i = 0; i < len; i += 16) {
printf("%04x: ", ((unsigned int)i));
- for(size_t j=i; j<std::min(i+16,len); j++){
- printf("%02x ",d[j] );
+ for (size_t j = i; j < std::min(i + 16, len); j++) {
+ printf("%02x ", d[j]);
}
std::cout << std::endl;
- }
-
- std::cout << "***********************************\n";
}
- int
- message_debug_impl::num_messages()
- {
- return (int)d_messages.size();
- }
+ std::cout << "***********************************\n";
+}
- pmt::pmt_t
- message_debug_impl::get_message(int i)
- {
- gr::thread::scoped_lock guard(d_mutex);
+int message_debug_impl::num_messages() { return (int)d_messages.size(); }
- if((size_t)i >= d_messages.size()) {
- throw std::runtime_error("message_debug: index for message out of bounds.\n");
- }
+pmt::pmt_t message_debug_impl::get_message(int i)
+{
+ gr::thread::scoped_lock guard(d_mutex);
- return d_messages[i];
+ if ((size_t)i >= d_messages.size()) {
+ throw std::runtime_error("message_debug: index for message out of bounds.\n");
}
- message_debug_impl::message_debug_impl()
- : block("message_debug",
- io_signature::make(0, 0, 0),
- io_signature::make(0, 0, 0))
- {
- message_port_register_in(pmt::mp("print"));
- set_msg_handler(pmt::mp("print"), boost::bind(&message_debug_impl::print, this, _1));
+ return d_messages[i];
+}
- message_port_register_in(pmt::mp("store"));
- set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1));
+message_debug_impl::message_debug_impl()
+ : block("message_debug", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0))
+{
+ message_port_register_in(pmt::mp("print"));
+ set_msg_handler(pmt::mp("print"), boost::bind(&message_debug_impl::print, this, _1));
- message_port_register_in(pmt::mp("print_pdu"));
- set_msg_handler(pmt::mp("print_pdu"), boost::bind(&message_debug_impl::print_pdu, this, _1));
- }
+ message_port_register_in(pmt::mp("store"));
+ set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1));
- message_debug_impl::~message_debug_impl()
- {
- }
+ message_port_register_in(pmt::mp("print_pdu"));
+ set_msg_handler(pmt::mp("print_pdu"),
+ boost::bind(&message_debug_impl::print_pdu, this, _1));
+}
- } /* namespace blocks */
-} /* namespace gr */
+message_debug_impl::~message_debug_impl() {}
+} /* namespace blocks */
+} /* namespace gr */