-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7153189
commit 8c99b96
Showing
13 changed files
with
366 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
grc/UTAT_HERON_tagged_stream_fixed_length_padder.block.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
id: UTAT_HERON_tagged_stream_fixed_length_padder | ||
label: Tagged Stream Fixed Length Padder | ||
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 one 'parameters' list entry for every parameter you want settable from the GUI. | ||
# Keys include: | ||
# * id (makes the value accessible as keyname, e.g. in the make entry) | ||
# * label (label shown in the GUI) | ||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...) | ||
# * default | ||
parameters: | ||
- id: len_tag_key | ||
label: Length Tag Name | ||
dtype: string | ||
default: packet_len | ||
- id: final_samples_per_symbol | ||
label: Final Samples per Symbol | ||
dtype: float | ||
- id: final_buffer_len | ||
label: Final buffer Length | ||
dtype: int | ||
# - id: threshold | ||
# label: Threshold | ||
# dtype: float | ||
# default: 1 | ||
|
||
# Make one 'inputs' list entry per input and one 'outputs' list entry per output. | ||
# Keys include: | ||
# * label (an identifier for the GUI) | ||
# * domain (optional - stream or message. Default is stream) | ||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...) | ||
# * vlen (optional - data stream vector length. Default is 1) | ||
# * optional (optional - set to 1 for optional inputs. Default is 0) | ||
inputs: | ||
- label: in | ||
domain: stream | ||
dtype: byte | ||
|
||
outputs: | ||
- label: out | ||
domain: stream | ||
dtype: byte | ||
|
||
# 'file_format' specifies the version of the GRC yml format used in the file | ||
# and should usually not be changed. | ||
file_format: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
include/gnuradio/UTAT_HERON/tagged_stream_fixed_length_padder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2023 University of Toronto Aerospace Team. | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
#ifndef INCLUDED_UTAT_HERON_TAGGED_STREAM_FIXED_LENGTH_PADDER_H | ||
#define INCLUDED_UTAT_HERON_TAGGED_STREAM_FIXED_LENGTH_PADDER_H | ||
|
||
#include <gnuradio/UTAT_HERON/api.h> | ||
#include <gnuradio/tagged_stream_block.h> | ||
|
||
namespace gr { | ||
namespace UTAT_HERON { | ||
|
||
/*! | ||
* \brief <+description of block+> | ||
* \ingroup UTAT_HERON | ||
* | ||
*/ | ||
class UTAT_HERON_API tagged_stream_fixed_length_padder | ||
: virtual public gr::tagged_stream_block | ||
{ | ||
public: | ||
typedef std::shared_ptr<tagged_stream_fixed_length_padder> sptr; | ||
|
||
/*! | ||
* \brief Return a shared_ptr to a new instance of | ||
* UTAT_HERON::tagged_stream_fixed_length_padder. | ||
* | ||
* To avoid accidental use of raw pointers, | ||
* UTAT_HERON::tagged_stream_fixed_length_padder's constructor is in a private | ||
* implementation class. UTAT_HERON::tagged_stream_fixed_length_padder::make is the | ||
* public interface for creating new instances. | ||
*/ | ||
static sptr make( | ||
const std::string& len_tag_key, | ||
float final_samples_per_symbol, | ||
int final_buffer_len | ||
// float threshold | ||
); | ||
}; | ||
|
||
} // namespace UTAT_HERON | ||
} // namespace gr | ||
|
||
#endif /* INCLUDED_UTAT_HERON_TAGGED_STREAM_FIXED_LENGTH_PADDER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2023 University of Toronto Aerospace Team. | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
#include "tagged_stream_fixed_length_padder_impl.h" | ||
#include <gnuradio/io_signature.h> | ||
|
||
namespace gr { | ||
namespace UTAT_HERON { | ||
|
||
using input_type = uint8_t; | ||
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 | ||
) | ||
{ | ||
return gnuradio::make_block_sptr<tagged_stream_fixed_length_padder_impl>( | ||
len_tag_key, | ||
final_samples_per_symbol, | ||
final_buffer_len | ||
// threshold | ||
); | ||
} | ||
|
||
|
||
/* | ||
* The private constructor | ||
*/ | ||
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 | ||
) : | ||
gr::tagged_stream_block( | ||
"tagged_stream_fixed_length_padder", | ||
gr::io_signature::make(1,1,sizeof(input_type)), | ||
gr::io_signature::make(1,1,sizeof(output_type)), | ||
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_samps_out(0) | ||
{} | ||
|
||
/* | ||
* Our virtual destructor. | ||
*/ | ||
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 = static_cast<int>(std::ceil((d_min_samps - d_samps_out)/d_sps)); | ||
int len = d_buffer_len + 1*d_sps; | ||
if(len/d_sps < ninput_items[0]) | ||
throw std::runtime_error("Input needs to be smaller!"); | ||
return len; | ||
} | ||
|
||
int tagged_stream_fixed_length_padder_impl::work(int noutput_items, | ||
gr_vector_int& ninput_items, | ||
gr_vector_const_void_star& input_items, | ||
gr_vector_void_star& output_items) | ||
{ | ||
auto in = static_cast<const input_type*>(input_items[0]); | ||
auto out = static_cast<output_type*>(output_items[0]); | ||
|
||
int produced = 0; | ||
|
||
std::memcpy(out, in, ninput_items[0]*sizeof(input_type)); | ||
d_samps_out += ninput_items[0]*d_sps; | ||
produced = ninput_items[0]; | ||
|
||
while(d_samps_out < d_buffer_len && produced < noutput_items){ | ||
out[produced++] = 0xCC; | ||
d_samps_out += d_sps; | ||
} | ||
|
||
if(d_samps_out < d_buffer_len) | ||
throw std::runtime_error("Output needs to be larger!"); | ||
|
||
d_samps_out -= produced*d_sps; | ||
return produced; | ||
|
||
} | ||
|
||
} /* namespace UTAT_HERON */ | ||
} /* namespace gr */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2023 University of Toronto Aerospace Team. | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
#ifndef INCLUDED_UTAT_HERON_TAGGED_STREAM_FIXED_LENGTH_PADDER_IMPL_H | ||
#define INCLUDED_UTAT_HERON_TAGGED_STREAM_FIXED_LENGTH_PADDER_IMPL_H | ||
|
||
#include <gnuradio/UTAT_HERON/tagged_stream_fixed_length_padder.h> | ||
|
||
namespace gr { | ||
namespace UTAT_HERON { | ||
|
||
class tagged_stream_fixed_length_padder_impl : public tagged_stream_fixed_length_padder | ||
{ | ||
private: | ||
// Nothing to declare in this block. | ||
float d_sps; | ||
int d_buffer_len; | ||
// float d_threshold; | ||
// int d_min_samps; | ||
float 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 | ||
); | ||
~tagged_stream_fixed_length_padder_impl(); | ||
|
||
// Where all the action really happens | ||
int work(int noutput_items, | ||
gr_vector_int& ninput_items, | ||
gr_vector_const_void_star& input_items, | ||
gr_vector_void_star& output_items); | ||
}; | ||
|
||
} // namespace UTAT_HERON | ||
} // namespace gr | ||
|
||
#endif /* INCLUDED_UTAT_HERON_TAGGED_STREAM_FIXED_LENGTH_PADDER_IMPL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
python/UTAT_HERON/bindings/docstrings/tagged_stream_fixed_length_padder_pydoc_template.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2023 Free Software Foundation, Inc. | ||
* | ||
* This file is part of GNU Radio | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
*/ | ||
#include "pydoc_macros.h" | ||
#define D(...) DOC(gr, UTAT_HERON, __VA_ARGS__) | ||
/* | ||
This file contains placeholders for docstrings for the Python bindings. | ||
Do not edit! These were automatically extracted during the binding process | ||
and will be overwritten during the build process | ||
*/ | ||
|
||
|
||
static const char* __doc_gr_UTAT_HERON_tagged_stream_fixed_length_padder = R"doc()doc"; | ||
|
||
|
||
static const char* __doc_gr_UTAT_HERON_tagged_stream_fixed_length_padder_make = | ||
R"doc()doc"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
python/UTAT_HERON/bindings/tagged_stream_fixed_length_padder_python.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2023 Free Software Foundation, Inc. | ||
* | ||
* This file is part of GNU Radio | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
*/ | ||
|
||
/***********************************************************************************/ | ||
/* This file is automatically generated using bindtool and can be manually edited */ | ||
/* The following lines can be configured to regenerate this file during cmake */ | ||
/* If manual edits are made, the following tags should be modified accordingly. */ | ||
/* BINDTOOL_GEN_AUTOMATIC(0) */ | ||
/* BINDTOOL_USE_PYGCCXML(0) */ | ||
/* BINDTOOL_HEADER_FILE(tagged_stream_fixed_length_padder.h) */ | ||
/* BINDTOOL_HEADER_FILE_HASH(e8323f50cc6fbf2d718fb4d63b0947d6) */ | ||
/***********************************************************************************/ | ||
|
||
#include <pybind11/complex.h> | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
|
||
namespace py = pybind11; | ||
|
||
#include <gnuradio/UTAT_HERON/tagged_stream_fixed_length_padder.h> | ||
// pydoc.h is automatically generated in the build directory | ||
#include <tagged_stream_fixed_length_padder_pydoc.h> | ||
|
||
void bind_tagged_stream_fixed_length_padder(py::module& m) | ||
{ | ||
|
||
using tagged_stream_fixed_length_padder = | ||
gr::UTAT_HERON::tagged_stream_fixed_length_padder; | ||
|
||
|
||
py::class_<tagged_stream_fixed_length_padder, | ||
gr::block, | ||
gr::basic_block, | ||
std::shared_ptr<tagged_stream_fixed_length_padder>>( | ||
m, "tagged_stream_fixed_length_padder", D(tagged_stream_fixed_length_padder)) | ||
|
||
.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"), | ||
D(tagged_stream_fixed_length_padder, make)) | ||
|
||
|
||
; | ||
} |
Oops, something went wrong.