Skip to content

Commit

Permalink
added defualts, fixed test fail
Browse files Browse the repository at this point in the history
  • Loading branch information
swarnavaghosh04 committed Aug 29, 2023
1 parent e6edef4 commit 5f0edaf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/gnuradio/UTAT_HERON/tagged_stream_tail_tagger.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UTAT_HERON_API tagged_stream_tail_tagger : virtual public gr::block
* class. UTAT_HERON::tagged_stream_tail_tagger::make is the public interface for
* creating new instances.
*/
static sptr make(const std::string& length_tag_key, const std::string& tail_tag_key);
static sptr make(const std::string& length_tag_key = "packet_len", const std::string& tail_tag_key = "trailer");
};

} // namespace UTAT_HERON
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_tail_tagger.h) */
/* BINDTOOL_HEADER_FILE_HASH(a544000c6ef5c511ea9a95c65ec60c94) */
/* BINDTOOL_HEADER_FILE_HASH(1a18d8b8942924c053aa80b1485453d3) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand All @@ -40,8 +40,8 @@ void bind_tagged_stream_tail_tagger(py::module& m)
m, "tagged_stream_tail_tagger", D(tagged_stream_tail_tagger))

.def(py::init(&tagged_stream_tail_tagger::make),
py::arg("length_tag_key"),
py::arg("tail_tag_key"),
py::arg("length_tag_key") = "packet_len",
py::arg("tail_tag_key") = "trailer",
D(tagged_stream_tail_tagger, make))


Expand Down
13 changes: 7 additions & 6 deletions python/UTAT_HERON/qa_tagged_stream_tail_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,26 @@ def tearDown(self):
self.tb = None

def test_instance(self):
instance = tagged_stream_tail_tagger('packet_len')
instance = tagged_stream_tail_tagger('packet_len', 'trailer')

def test_001_basic(self):

input = (complex(1,1), complex(2,2), complex(3,3))
expected_output = [complex(1,1), complex(2,2), complex(3,3), complex()]

source = blocks.vector_source_c(input, False, 1, [])
source = blocks.vector_source_c(input, True, 1, [])
tag_packet = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, 3, 'packet_len')
instance = tagged_stream_tail_tagger('packet_len')
instance = tagged_stream_tail_tagger('packet_len', 'trailer')
head = blocks.head(gr.sizeof_gr_complex, 4)
sink = blocks.vector_sink_c(1, 4)

self.tb.connect(source, tag_packet)
self.tb.connect(tag_packet, instance)
self.tb.connect(instance, sink)
self.tb.connect(instance, head)
self.tb.connect(head, sink)
self.tb.run()
output = sink.data()
self.assertEqual(output[:4], expected_output[:4])
# check data
self.assertEqual(output, expected_output)


if __name__ == '__main__':
Expand Down

0 comments on commit 5f0edaf

Please sign in to comment.