aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Gilbert <mrjacobagilbert@gmail.com>2014-12-13 10:32:21 -0800
committerJacob Gilbert <mrjacobagilbert@gmail.com>2014-12-13 10:32:21 -0800
commite89aee1934011c51203d6b611b06afe90bfa8a62 (patch)
treec96f337d8aff1cf262b60d6ab7767296ea4d4b42
parent79d0909d0d59df7a77cd62edfbd63466a4aea5f7 (diff)
Updated message printer to accept a pmt string which will be prepended to any printed messages for situations where multiple print blocks are desired.
-rw-r--r--grc/misc_utils/gsm_message_printer.xml11
-rw-r--r--include/grgsm/misc_utils/message_printer.h2
-rw-r--r--lib/misc_utils/message_printer_impl.cc8
-rw-r--r--lib/misc_utils/message_printer_impl.h3
4 files changed, 18 insertions, 6 deletions
diff --git a/grc/misc_utils/gsm_message_printer.xml b/grc/misc_utils/gsm_message_printer.xml
index 8e0a68d..8b44b22 100644
--- a/grc/misc_utils/gsm_message_printer.xml
+++ b/grc/misc_utils/gsm_message_printer.xml
@@ -3,7 +3,16 @@
<name>Message printer</name>
<key>gsm_message_printer</key>
<import>import grgsm</import>
- <make>grgsm.message_printer()</make>
+ <import>import pmt</import>
+ <make>grgsm.message_printer(pmt.intern($prepend_string))</make>
+
+ <param>
+ <name>Prepend String</name>
+ <key>prepend_string</key>
+ <value></value>
+ <type>string</type>
+ <hide>part</hide>
+ </param>
<sink>
<name>msgs</name>
diff --git a/include/grgsm/misc_utils/message_printer.h b/include/grgsm/misc_utils/message_printer.h
index 3ed8bbd..b7f3293 100644
--- a/include/grgsm/misc_utils/message_printer.h
+++ b/include/grgsm/misc_utils/message_printer.h
@@ -48,7 +48,7 @@ namespace gr {
* class. gsm::message_printer::make is the public interface for
* creating new instances.
*/
- static sptr make();
+ static sptr make(pmt::pmt_t prepend_string);
};
} // namespace gsm
diff --git a/lib/misc_utils/message_printer_impl.cc b/lib/misc_utils/message_printer_impl.cc
index 48cd95b..d02e2fe 100644
--- a/lib/misc_utils/message_printer_impl.cc
+++ b/lib/misc_utils/message_printer_impl.cc
@@ -40,6 +40,7 @@ namespace gr {
gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header;
+ std::cout << d_prepend_string;
for(int ii=sizeof(gsmtap_hdr); ii<message_plus_header_len; ii++)
{
printf(" %02x", message_plus_header[ii]);
@@ -48,20 +49,21 @@ namespace gr {
}
message_printer::sptr
- message_printer::make()
+ message_printer::make(pmt::pmt_t prepend_string)
{
return gnuradio::get_initial_sptr
- (new message_printer_impl());
+ (new message_printer_impl(prepend_string));
}
/*
* The private constructor
*/
- message_printer_impl::message_printer_impl()
+ message_printer_impl::message_printer_impl(pmt::pmt_t prepend_string)
: gr::block("message_printer",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0))
{
+ d_prepend_string = prepend_string;
message_port_register_in(pmt::mp("msgs"));
set_msg_handler(pmt::mp("msgs"), boost::bind(&message_printer_impl::message_print, this, _1));
diff --git a/lib/misc_utils/message_printer_impl.h b/lib/misc_utils/message_printer_impl.h
index e2c8236..e82485e 100644
--- a/lib/misc_utils/message_printer_impl.h
+++ b/lib/misc_utils/message_printer_impl.h
@@ -32,8 +32,9 @@ namespace gr {
{
private:
void message_print(pmt::pmt_t msg);
+ pmt::pmt_t d_prepend_string;
public:
- message_printer_impl();
+ message_printer_impl(pmt::pmt_t prepend_string);
~message_printer_impl();
};