Skip to content

Commit

Permalink
added filler parameter, changed float to double
Browse files Browse the repository at this point in the history
  • Loading branch information
swarnavaghosh04 committed Sep 9, 2023
1 parent 59952aa commit e468a82
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
10 changes: 5 additions & 5 deletions grc/UTAT_HERON_tagged_stream_fixed_length_padder.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
};

Expand Down
23 changes: 11 additions & 12 deletions lib/tagged_stream_fixed_length_padder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<tagged_stream_fixed_length_padder_impl>(
len_tag_key,
final_samples_per_symbol,
final_buffer_len
// threshold
final_buffer_len,
filler
);
}

Expand All @@ -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",
Expand All @@ -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)
{}

Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
13 changes: 6 additions & 7 deletions lib/tagged_stream_fixed_length_padder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@ 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);

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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pybind11/complex.h>
Expand Down Expand Up @@ -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))


Expand Down

0 comments on commit e468a82

Please sign in to comment.