diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2015-01-22 15:28:09 -0800 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2015-01-22 15:28:09 -0800 |
commit | 620817ede54bbb89bff449fccfc999c1e6e7887b (patch) | |
tree | 3b7d7fcdcf32ed289de92e7618fb677dda0fcbd9 /gr-blocks | |
parent | f20c56b7ff15655c56aede3a9d982a424c053778 (diff) | |
parent | 481292779472c8ed93dcbfd5a9c957da2e1bbd07 (diff) |
Merge remote-tracking branch 'fengzhe/repack_bits_update'
Diffstat (limited to 'gr-blocks')
-rw-r--r-- | gr-blocks/grc/blocks_repack_bits_bb.xml | 2 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/repack_bits_bb.h | 1 | ||||
-rw-r--r-- | gr-blocks/lib/repack_bits_bb_impl.cc | 10 | ||||
-rw-r--r-- | gr-blocks/lib/repack_bits_bb_impl.h | 6 |
4 files changed, 15 insertions, 4 deletions
diff --git a/gr-blocks/grc/blocks_repack_bits_bb.xml b/gr-blocks/grc/blocks_repack_bits_bb.xml index 7931132540..3554e30f11 100644 --- a/gr-blocks/grc/blocks_repack_bits_bb.xml +++ b/gr-blocks/grc/blocks_repack_bits_bb.xml @@ -3,7 +3,7 @@ <key>blocks_repack_bits_bb</key> <import>from gnuradio import blocks</import> <make>blocks.repack_bits_bb($k, $l, $len_tag_key, $align_output, $endianness)</make> - + <callback>set_k_and_l($k,$l)</callback> <param> <name>Bits per input byte</name> <key>k</key> diff --git a/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h b/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h index 83bd771e0b..7bf53ab09c 100644 --- a/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h +++ b/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h @@ -80,6 +80,7 @@ namespace gr { */ static sptr make(int k, int l=8, const std::string &tsb_tag_key="", bool align_output=false, endianness_t endianness=GR_LSB_FIRST); + virtual void set_k_and_l(int k, int l) =0;//callback function for bits per input byte k and bits per output byte l. }; } // namespace blocks diff --git a/gr-blocks/lib/repack_bits_bb_impl.cc b/gr-blocks/lib/repack_bits_bb_impl.cc index de61bf414f..947a3c23ce 100644 --- a/gr-blocks/lib/repack_bits_bb_impl.cc +++ b/gr-blocks/lib/repack_bits_bb_impl.cc @@ -58,6 +58,15 @@ namespace gr { set_relative_rate((double) d_k / d_l); } + void + repack_bits_bb_impl::set_k_and_l(int k, int l) + { + gr::thread::scoped_lock guard(d_setlock); + d_k = k; + d_l = l; + set_relative_rate((double) d_k / d_l); + } + repack_bits_bb_impl::~repack_bits_bb_impl() { } @@ -79,6 +88,7 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + gr::thread::scoped_lock guard(d_setlock); const unsigned char *in = (const unsigned char *) input_items[0]; unsigned char *out = (unsigned char *) output_items[0]; int bytes_to_write = noutput_items; diff --git a/gr-blocks/lib/repack_bits_bb_impl.h b/gr-blocks/lib/repack_bits_bb_impl.h index 8c57c74c23..8dfb0600a6 100644 --- a/gr-blocks/lib/repack_bits_bb_impl.h +++ b/gr-blocks/lib/repack_bits_bb_impl.h @@ -31,8 +31,8 @@ namespace gr { class repack_bits_bb_impl : public repack_bits_bb { private: - const int d_k; //! Bits on input stream - const int d_l; //! Bits on output stream + int d_k; //! Bits on input stream + int d_l; //! Bits on output stream const bool d_packet_mode; int d_in_index; // Current bit of input byte int d_out_index; // Current bit of output byte @@ -46,7 +46,7 @@ namespace gr { repack_bits_bb_impl(int k, int l, const std::string &len_tag_key, bool align_output, endianness_t endianness=GR_LSB_FIRST); ~repack_bits_bb_impl(); - + void set_k_and_l(int k, int l);//callback function for bits per input byte k and bits per output byte l int work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, |