From e468a82bd93a07b61204e8f1291843e211b385c0 Mon Sep 17 00:00:00 2001 From: Swarnava Ghosh Date: Fri, 8 Sep 2023 22:20:36 -0400 Subject: [PATCH] added filler parameter, changed float to double --- ...agged_stream_fixed_length_padder.block.yml | 10 ++++---- .../tagged_stream_fixed_length_padder.h | 6 ++--- lib/tagged_stream_fixed_length_padder_impl.cc | 23 +++++++++---------- lib/tagged_stream_fixed_length_padder_impl.h | 13 +++++------ ...agged_stream_fixed_length_padder_python.cc | 5 ++-- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/grc/UTAT_HERON_tagged_stream_fixed_length_padder.block.yml b/grc/UTAT_HERON_tagged_stream_fixed_length_padder.block.yml index 4b4ca96..9d51a99 100644 --- a/grc/UTAT_HERON_tagged_stream_fixed_length_padder.block.yml +++ b/grc/UTAT_HERON_tagged_stream_fixed_length_padder.block.yml @@ -4,7 +4,7 @@ category: '[UTAT]' templates: imports: from gnuradio import UTAT_HERON - make: UTAT_HERON.tagged_stream_fixed_length_padder(${len_tag_key}, ${final_samples_per_symbol}, ${final_buffer_len}) + make: UTAT_HERON.tagged_stream_fixed_length_padder(${len_tag_key}, ${final_samples_per_symbol}, ${final_buffer_len}, ${filler}) # Make one 'parameters' list entry for every parameter you want settable from the GUI. # Keys include: @@ -23,10 +23,10 @@ parameters: - id: final_buffer_len label: Final buffer Length dtype: int -# - id: threshold -# label: Threshold -# dtype: float -# default: 1 +- id: filler + label: Filler + dtype: byte + default: 0x00 # Make one 'inputs' list entry per input and one 'outputs' list entry per output. # Keys include: diff --git a/include/gnuradio/UTAT_HERON/tagged_stream_fixed_length_padder.h b/include/gnuradio/UTAT_HERON/tagged_stream_fixed_length_padder.h index a77a493..7b09fea 100644 --- a/include/gnuradio/UTAT_HERON/tagged_stream_fixed_length_padder.h +++ b/include/gnuradio/UTAT_HERON/tagged_stream_fixed_length_padder.h @@ -36,9 +36,9 @@ class UTAT_HERON_API tagged_stream_fixed_length_padder */ static sptr make( const std::string& len_tag_key, - float final_samples_per_symbol, - int final_buffer_len - // float threshold + double final_samples_per_symbol, + int final_buffer_len, + uint8_t filler ); }; diff --git a/lib/tagged_stream_fixed_length_padder_impl.cc b/lib/tagged_stream_fixed_length_padder_impl.cc index b795e04..0452955 100644 --- a/lib/tagged_stream_fixed_length_padder_impl.cc +++ b/lib/tagged_stream_fixed_length_padder_impl.cc @@ -16,16 +16,16 @@ using output_type = uint8_t; tagged_stream_fixed_length_padder::sptr tagged_stream_fixed_length_padder::make( const std::string& len_tag_key, - float final_samples_per_symbol, - int final_buffer_len - // float threshold + double final_samples_per_symbol, + int final_buffer_len, + uint8_t filler ) { return gnuradio::make_block_sptr( len_tag_key, final_samples_per_symbol, - final_buffer_len - // threshold + final_buffer_len, + filler ); } @@ -35,9 +35,9 @@ tagged_stream_fixed_length_padder::sptr tagged_stream_fixed_length_padder::make( */ tagged_stream_fixed_length_padder_impl::tagged_stream_fixed_length_padder_impl( const std::string& len_tag_key, - float final_samples_per_symbol, - int final_buffer_len - // float threshold + double final_samples_per_symbol, + int final_buffer_len, + uint8_t filler ) : gr::tagged_stream_block( "tagged_stream_fixed_length_padder", @@ -46,8 +46,7 @@ tagged_stream_fixed_length_padder_impl::tagged_stream_fixed_length_padder_impl( len_tag_key), d_sps(final_samples_per_symbol), d_buffer_len(final_buffer_len), - // d_threshold(threshold), - // d_min_samps(std::ceil(d_buffer_len + d_threshold)), + d_filler(filler), d_samps_out(0) {} @@ -59,7 +58,7 @@ tagged_stream_fixed_length_padder_impl::~tagged_stream_fixed_length_padder_impl( int tagged_stream_fixed_length_padder_impl::calculate_output_stream_length( const gr_vector_int& ninput_items) { - int len = (float)(d_buffer_len - d_samps_out)/d_sps + 1; + int len = (double)(d_buffer_len - d_samps_out)/d_sps + 1; if(len < ninput_items[0]) throw std::runtime_error("Input needs to be smaller!"); return len; @@ -80,7 +79,7 @@ int tagged_stream_fixed_length_padder_impl::work(int noutput_items, produced = ninput_items[0]; while(d_samps_out <= d_buffer_len && produced < noutput_items){ - out[produced++] = 0x00; + out[produced++] = d_filler; d_samps_out += d_sps; } diff --git a/lib/tagged_stream_fixed_length_padder_impl.h b/lib/tagged_stream_fixed_length_padder_impl.h index 6a25f12..901fb74 100644 --- a/lib/tagged_stream_fixed_length_padder_impl.h +++ b/lib/tagged_stream_fixed_length_padder_impl.h @@ -17,11 +17,10 @@ class tagged_stream_fixed_length_padder_impl : public tagged_stream_fixed_length { private: // Nothing to declare in this block. - float d_sps; + double d_sps; int d_buffer_len; - // float d_threshold; - // int d_min_samps; - float d_samps_out; + uint8_t d_filler; + double d_samps_out; protected: int calculate_output_stream_length(const gr_vector_int& ninput_items); @@ -29,9 +28,9 @@ class tagged_stream_fixed_length_padder_impl : public tagged_stream_fixed_length public: tagged_stream_fixed_length_padder_impl( const std::string& len_tag_key, - float final_samples_per_symbol, - int final_buffer_len - // float threshold + double final_samples_per_symbol, + int final_buffer_len, + uint8_t filler ); ~tagged_stream_fixed_length_padder_impl(); diff --git a/python/UTAT_HERON/bindings/tagged_stream_fixed_length_padder_python.cc b/python/UTAT_HERON/bindings/tagged_stream_fixed_length_padder_python.cc index d10d56e..d19f460 100644 --- a/python/UTAT_HERON/bindings/tagged_stream_fixed_length_padder_python.cc +++ b/python/UTAT_HERON/bindings/tagged_stream_fixed_length_padder_python.cc @@ -14,7 +14,7 @@ /* BINDTOOL_GEN_AUTOMATIC(0) */ /* BINDTOOL_USE_PYGCCXML(0) */ /* BINDTOOL_HEADER_FILE(tagged_stream_fixed_length_padder.h) */ -/* BINDTOOL_HEADER_FILE_HASH(e8323f50cc6fbf2d718fb4d63b0947d6) */ +/* BINDTOOL_HEADER_FILE_HASH(496d118218ce70cd353a80d130b1035b) */ /***********************************************************************************/ #include @@ -43,7 +43,8 @@ void bind_tagged_stream_fixed_length_padder(py::module& m) .def(py::init(&tagged_stream_fixed_length_padder::make), py::arg("len_tag_key"), py::arg("final_samples_per_symbol"), - py::arg("final_buffer_len//floatthreshold"), + py::arg("final_buffer_len"), + py::arg("filler"), D(tagged_stream_fixed_length_padder, make))