diff options
author | Ruben Undheim <ruben.undheim@gmail.com> | 2017-05-19 17:47:48 +0000 |
---|---|---|
committer | Ruben Undheim <ruben.undheim@gmail.com> | 2017-05-19 18:03:27 +0000 |
commit | e3ef9bb387a17222fe390fac3b659199502e2efe (patch) | |
tree | 9e786f9219ea67382a7ddcd9bb04f7189a5420d7 /gr-blocks | |
parent | 484acc4eabdc19d8c72c8c0724bae76ad975d955 (diff) |
set_begin_tag now takes pmt::pmt instead of bool
Diffstat (limited to 'gr-blocks')
-rw-r--r-- | gr-blocks/grc/blocks_file_source.xml | 13 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/file_source.h | 2 | ||||
-rw-r--r-- | gr-blocks/lib/file_source_impl.cc | 10 | ||||
-rw-r--r-- | gr-blocks/lib/file_source_impl.h | 6 | ||||
-rw-r--r-- | gr-blocks/python/blocks/qa_file_source_sink.py | 5 |
5 files changed, 14 insertions, 22 deletions
diff --git a/gr-blocks/grc/blocks_file_source.xml b/gr-blocks/grc/blocks_file_source.xml index 22c5263171..1f09e95168 100644 --- a/gr-blocks/grc/blocks_file_source.xml +++ b/gr-blocks/grc/blocks_file_source.xml @@ -8,6 +8,7 @@ <name>File Source</name> <key>blocks_file_source</key> <import>from gnuradio import blocks</import> + <import>import pmt</import> <make>blocks.file_source($type.size*$vlen, $file, $repeat) self.$(id).set_begin_tag($begin_tag)</make> <callback>open($file, $repeat)</callback> @@ -72,16 +73,8 @@ self.$(id).set_begin_tag($begin_tag)</make> <param> <name>Add begin tag</name> <key>begin_tag</key> - <value>False</value> - <type>bool</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> + <value>pmt.PMT_NIL</value> + <type>raw</type> </param> <check>$vlen > 0</check> <source> diff --git a/gr-blocks/include/gnuradio/blocks/file_source.h b/gr-blocks/include/gnuradio/blocks/file_source.h index bba09ad502..c8138339fd 100644 --- a/gr-blocks/include/gnuradio/blocks/file_source.h +++ b/gr-blocks/include/gnuradio/blocks/file_source.h @@ -81,7 +81,7 @@ namespace gr { /*! * \brief Add a stream tag to the first sample of the file if true */ - virtual void set_begin_tag(bool val) = 0; + virtual void set_begin_tag(pmt::pmt_t val) = 0; }; } /* namespace blocks */ diff --git a/gr-blocks/lib/file_source_impl.cc b/gr-blocks/lib/file_source_impl.cc index 2f626d0897..9dfd30c016 100644 --- a/gr-blocks/lib/file_source_impl.cc +++ b/gr-blocks/lib/file_source_impl.cc @@ -65,7 +65,7 @@ namespace gr { io_signature::make(1, 1, itemsize)), d_itemsize(itemsize), d_fp(0), d_new_fp(0), d_repeat(repeat), d_updated(false), d_file_begin(true), d_repeat_cnt(0), - d_add_begin_tag(false) + d_add_begin_tag(pmt::PMT_NIL) { open(filename, repeat); do_update(); @@ -149,7 +149,7 @@ namespace gr { } void - file_source_impl::set_begin_tag(bool val) + file_source_impl::set_begin_tag(pmt::pmt_t val) { d_add_begin_tag = val; } @@ -171,8 +171,8 @@ namespace gr { while(size) { // Add stream tag whenever the file starts again - if (d_file_begin && d_add_begin_tag) { - add_item_tag(0, nitems_written(0) + noutput_items - size, BEGIN_KEY, pmt::from_long(d_repeat_cnt), _id); + if (d_file_begin && d_add_begin_tag != pmt::PMT_NIL) { + add_item_tag(0, nitems_written(0) + noutput_items - size, d_add_begin_tag, pmt::from_long(d_repeat_cnt), _id); d_file_begin = false; } @@ -197,7 +197,7 @@ namespace gr { fprintf(stderr, "[%s] fseek failed\n", __FILE__); exit(-1); } - if (d_add_begin_tag) { + if (d_add_begin_tag != pmt::PMT_NIL) { d_file_begin = true; d_repeat_cnt++; } diff --git a/gr-blocks/lib/file_source_impl.h b/gr-blocks/lib/file_source_impl.h index 3cde2bb11a..19f393fc1d 100644 --- a/gr-blocks/lib/file_source_impl.h +++ b/gr-blocks/lib/file_source_impl.h @@ -26,8 +26,6 @@ #include <gnuradio/blocks/file_source.h> #include <boost/thread/mutex.hpp> -static const pmt::pmt_t BEGIN_KEY = pmt::string_to_symbol("file_begin"); - namespace gr { namespace blocks { @@ -41,7 +39,7 @@ namespace gr { bool d_updated; bool d_file_begin; long d_repeat_cnt; - bool d_add_begin_tag; + pmt::pmt_t d_add_begin_tag; boost::mutex fp_mutex; pmt::pmt_t _id; @@ -60,7 +58,7 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - void set_begin_tag(bool val); + void set_begin_tag(pmt::pmt_t val); }; } /* namespace blocks */ diff --git a/gr-blocks/python/blocks/qa_file_source_sink.py b/gr-blocks/python/blocks/qa_file_source_sink.py index 081f58228f..32910cb4bc 100644 --- a/gr-blocks/python/blocks/qa_file_source_sink.py +++ b/gr-blocks/python/blocks/qa_file_source_sink.py @@ -23,6 +23,7 @@ from gnuradio import gr, gr_unittest, blocks import os import tempfile +import pmt class test_file_source_sink(gr_unittest.TestCase): @@ -115,7 +116,7 @@ class test_file_source_sink(gr_unittest.TestCase): snk.set_unbuffered(True) src2 = blocks.file_source(gr.sizeof_float, temp.name) - src2.set_begin_tag(True) + src2.set_begin_tag(pmt.string_to_symbol("file_begin")) self.tb.connect(src, snk) self.tb.run() @@ -141,7 +142,7 @@ class test_file_source_sink(gr_unittest.TestCase): snk.set_unbuffered(True) src2 = blocks.file_source(gr.sizeof_float, temp.name, True) - src2.set_begin_tag(True) + src2.set_begin_tag(pmt.string_to_symbol("file_begin")) hd = blocks.head(gr.sizeof_float, 2000) self.tb.connect(src, snk) |