diff options
author | Tim O'Shea <tim.oshea753@gmail.com> | 2013-06-04 11:05:46 -0400 |
---|---|---|
committer | Tim O'Shea <tim.oshea753@gmail.com> | 2013-06-05 14:19:56 -0400 |
commit | 5e3fd0144cd3dde787985601416f798a37ebae86 (patch) | |
tree | 23481348960d9cd6471c5021c7a4e9a0e59d909e | |
parent | a4d6048f64bc89f4a01cea8a3d736c1f2c76e1d8 (diff) |
blocks: add parameter to change length stream tag key used in pdu_to_tagged_stream and tagged_stream_to_pdu
-rw-r--r-- | gr-blocks/grc/blocks_pdu_to_tagged_stream.xml | 8 | ||||
-rw-r--r-- | gr-blocks/grc/blocks_tagged_stream_to_pdu.xml | 30 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h | 2 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h | 2 | ||||
-rw-r--r-- | gr-blocks/lib/pdu_to_tagged_stream_impl.cc | 11 | ||||
-rw-r--r-- | gr-blocks/lib/pdu_to_tagged_stream_impl.h | 3 | ||||
-rw-r--r-- | gr-blocks/lib/tagged_stream_to_pdu_impl.cc | 6 | ||||
-rw-r--r-- | gr-blocks/lib/tagged_stream_to_pdu_impl.h | 2 |
8 files changed, 39 insertions, 25 deletions
diff --git a/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml b/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml index 2a7de84759..0835a2adee 100644 --- a/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml +++ b/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml @@ -8,7 +8,7 @@ <name>PDU to Tagged Stream</name> <key>blocks_pdu_to_tagged_stream</key> <import>from gnuradio import blocks</import> - <make>blocks.pdu_to_tagged_stream($type.tv)</make> + <make>blocks.pdu_to_tagged_stream($type.tv, $tag)</make> <param> <name>Item Type</name> <key>type</key> @@ -29,6 +29,12 @@ <opt>tv:blocks.float_t</opt> </option> </param> + <param> + <name>Length tag name</name> + <key>tag</key> + <value>packet_len</value> + <type>string</type> + </param> <sink> <name>pdus</name> <type>message</type> diff --git a/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml b/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml index 6dd7b9be30..f85b47fb19 100644 --- a/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml +++ b/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml @@ -5,10 +5,10 @@ ################################################### --> <block> - <name>Tagged Stream to PDU</name> - <key>blocks_tagged_stream_to_pdu</key> - <import>from gnuradio import blocks</import> - <make>blocks.tagged_stream_to_pdu($type.tv)</make> + <name>Tagged Stream to PDU</name> + <key>blocks_tagged_stream_to_pdu</key> + <import>from gnuradio import blocks</import> + <make>blocks.tagged_stream_to_pdu($type.tv, $tag)</make> <param> <name>Item Type</name> <key>type</key> @@ -29,12 +29,18 @@ <opt>tv:blocks.float_t</opt> </option> </param> - <sink> - <name>in</name> - <type>$type</type> - </sink> - <source> - <name>pdus</name> - <type>message</type> - </source> + <param> + <name>Length tag name</name> + <key>tag</key> + <value>packet_len</value> + <type>string</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>pdus</name> + <type>message</type> + </source> </block> diff --git a/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h b/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h index 758d7412db..2aea2e9e99 100644 --- a/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h +++ b/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h @@ -44,7 +44,7 @@ namespace gr { * \brief Construct a pdu_to_tagged_stream block * \param type PDU type of pdu::vector_type */ - static sptr make(pdu::vector_type type); + static sptr make(pdu::vector_type type, const std::string& lengthtagname="packet_len"); }; } /* namespace blocks */ diff --git a/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h b/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h index 9b0f24a535..e032f41fb5 100644 --- a/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h +++ b/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h @@ -44,7 +44,7 @@ namespace gr { * \brief Construct a tagged_stream_to_pdu block * \param type PDU type of pdu::vector_type */ - static sptr make(pdu::vector_type type); + static sptr make(pdu::vector_type type, const std::string& lengthtagname="packet_len"); }; } /* namespace blocks */ diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc index f81d324547..504e69937a 100644 --- a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc +++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc @@ -32,17 +32,18 @@ namespace gr { namespace blocks { pdu_to_tagged_stream::sptr - pdu_to_tagged_stream::make(pdu::vector_type type) + pdu_to_tagged_stream::make(pdu::vector_type type, const std::string& lengthtagname) { - return gnuradio::get_initial_sptr(new pdu_to_tagged_stream_impl(type)); + return gnuradio::get_initial_sptr(new pdu_to_tagged_stream_impl(type, lengthtagname)); } - pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type) + pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type, const std::string& lengthtagname) : sync_block("pdu_to_tagged_stream", io_signature::make(0, 0, 0), io_signature::make(1, 1, pdu::itemsize(type))), d_itemsize(pdu::itemsize(type)), - d_type(type) + d_type(type), + d_tag(pmt::mp(lengthtagname)) { message_port_register_in(PDU_PORT_ID); } @@ -84,7 +85,7 @@ namespace gr { uint64_t offset = nitems_written(0) + nout; // add a tag for pdu length - add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::from_long(pmt::length(vect)), pmt::mp(alias())); + add_item_tag(0, offset, d_tag, pmt::from_long(pmt::length(vect)), pmt::mp(alias())); // if we recieved metadata add it as tags if (!pmt::eq(meta, pmt::PMT_NIL) ) { diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.h b/gr-blocks/lib/pdu_to_tagged_stream_impl.h index 8b3d13c921..eb0514ecb9 100644 --- a/gr-blocks/lib/pdu_to_tagged_stream_impl.h +++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.h @@ -33,9 +33,10 @@ namespace gr { size_t d_itemsize; pdu::vector_type d_type; std::vector<uint8_t> d_remain; + pmt::pmt_t d_tag; public: - pdu_to_tagged_stream_impl(pdu::vector_type type); + pdu_to_tagged_stream_impl(pdu::vector_type type, const std::string& lengthtagname="packet_len"); int work(int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc index b452470efa..3d6bcc4335 100644 --- a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc +++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc @@ -32,12 +32,12 @@ namespace gr { namespace blocks { tagged_stream_to_pdu::sptr - tagged_stream_to_pdu::make(pdu::vector_type type) + tagged_stream_to_pdu::make(pdu::vector_type type, const std::string& lengthtagname) { - return gnuradio::get_initial_sptr(new tagged_stream_to_pdu_impl(type)); + return gnuradio::get_initial_sptr(new tagged_stream_to_pdu_impl(type, lengthtagname)); } - tagged_stream_to_pdu_impl::tagged_stream_to_pdu_impl(pdu::vector_type type) + tagged_stream_to_pdu_impl::tagged_stream_to_pdu_impl(pdu::vector_type type, const std::string& lengthtagname) : sync_block("tagged_stream_to_pdu", io_signature::make(1, 1, pdu::itemsize(type)), io_signature::make(0, 0, 0)), diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.h b/gr-blocks/lib/tagged_stream_to_pdu_impl.h index 4e9568a1c5..259393dbff 100644 --- a/gr-blocks/lib/tagged_stream_to_pdu_impl.h +++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.h @@ -43,7 +43,7 @@ namespace gr { std::vector<tag_t> d_tags; public: - tagged_stream_to_pdu_impl(pdu::vector_type type); + tagged_stream_to_pdu_impl(pdu::vector_type type, const std::string& lengthtagname); int work(int noutput_items, gr_vector_const_void_star &input_items, |