Open notsleep196 opened 1 year ago
Hi, thanks for reporting this.
You are right. fixedlen_tagger
doesn't propagate tags from the input to the output. The code to do that is simply missing. Additionally, fixedlen_tagger
(which is a Python block, and hence not so efficient) was mostly deprecated in May this year in favour of the fixedlen_to_pdu
block (which is a C++ block and much more efficient). I see that I forgot to mark the GRC block as deprecated, so maybe I should do that.
fixedlen_to_pdu
is somewhat different to fixedlen_tagger
. Its output are PDUs rather than a tagged stream. This made more sense, because gr-satellites always converts the tagged stream to PDUs, and so it used Tagged Stream to PDU always after fixedlen_tagger
. Since it's more difficult to properly format a tagged stream output, it makes more sense to have a block which outputs PDUs directly.
fixedlen_to_pdu
doesn't propagate tags from input to output either. We could add code so that the tags get added to the PDU, but currently there is no need for this in gr-satellites.
I see that the flowgraph you have could likely be achieved by using gr-satellites Sync and Create Packed PDU block. But perhaps this is just an example to demonstrate the problem rather than your final goal.
In any case, if you do need to use fixedlen_tagger
in your application and want to implement tag propagation yourself, I'm happy to review the code and get it merged upstream. At the moment, there is not much interest in having tag propagation in these blocks, so it's probably not something that I'll implement myself.
Hello and thank you for reply! I think i can close this issue, because your answer is exhaustive.
Thanks. I actually prefer to leave this issue open, since it describes a possible enhancement that someone might want to implement in the future.
Hello! I faced the issue with tags propagation in "Fixed Length Packet Tagger" block. I tried to push to flowgraph some additional info via tags (using PDU) and saw that this tags are mixed or missed after "Fixed Length Packet Tagger". So i made easier flowgraphs to demonstrate this.
My TopBlock looks like this: gr_satellites_bug_hier looks like this: As you can see from TopBlock main idea is to decode data with different "syncwords" in one flowgraph.
I swapped PadSource with simple custom MessagePublisher to push messages to flowgraph. The final python file of TopBlock:
TopBlock
```python import os import sys import pmt from gnuradio import blocks from gnuradio import digital from gnuradio import gr from gnuradio.filter import firdes from gnuradio.fft import window import signal from argparse import ArgumentParser from gnuradio.eng_arg import eng_float, intx from gnuradio import eng_notation from gnuradio import gr, pdu from gr_satellites_bug_hier import gr_satellites_bug_hier # grc-generated hier_block class MessagePublisher(gr.sync_block): def __init__(self): gr.sync_block.__init__( self, name="Publisher", in_sig=None, out_sig=None ) self.message_port_register_out(pmt.intern('out')) class gr_satellites_bug(gr.top_block): def __init__(self): gr.top_block.__init__(self, "gr-satellites_bug_TopBlock", catch_exceptions=True) ################################################## # Variables ################################################## self.syncword_small_packet = syncword_small_packet = "0111000110011101100000111100100101010011010000100010110111111010" self.syncword_long_packet = syncword_long_packet = "0010010011001000110101101001110000000110000101110111100010101111" self.mtu_small_packet = mtu_small_packet = 32 self.mtu_long_packet = mtu_long_packet = 64 self.message_publisher = MessagePublisher() self.iter = 1 ################################################## # Blocks ################################################## self.pdu_pdu_to_tagged_stream_0 = pdu.pdu_to_tagged_stream(gr.types.byte_t, 'length') self.gr_satellites_bug_hier_0_0 = gr_satellites_bug_hier( mtu=mtu_small_packet, syncword=syncword_small_packet, ) self.gr_satellites_bug_hier_0 = gr_satellites_bug_hier( mtu=mtu_long_packet, syncword=syncword_long_packet, ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf([-1,1], 1) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.blocks_message_debug_1 = blocks.message_debug(True) self.blocks_message_debug_0_0 = blocks.message_debug(True) self.blocks_message_debug_0 = blocks.message_debug(True) ################################################## # Connections ################################################## self.msg_connect((self.gr_satellites_bug_hier_0, 'out'), (self.blocks_message_debug_1, 'print')) self.msg_connect((self.gr_satellites_bug_hier_0_0, 'out'), (self.blocks_message_debug_0_0, 'print')) self.msg_connect((self.message_publisher, 'out'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.message_publisher, 'out'), (self.pdu_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_satellites_bug_hier_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_satellites_bug_hier_0_0, 0)) self.connect((self.pdu_pdu_to_tagged_stream_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) def get_syncword_small_packet(self): return self.syncword_small_packet def set_syncword_small_packet(self, syncword_small_packet): self.syncword_small_packet = syncword_small_packet self.gr_satellites_bug_hier_0_0.set_syncword(self.syncword_small_packet) def get_syncword_long_packet(self): return self.syncword_long_packet def set_syncword_long_packet(self, syncword_long_packet): self.syncword_long_packet = syncword_long_packet self.gr_satellites_bug_hier_0.set_syncword(self.syncword_long_packet) def get_mtu_small_packet(self): return self.mtu_small_packet def set_mtu_small_packet(self, mtu_small_packet): self.mtu_small_packet = mtu_small_packet self.gr_satellites_bug_hier_0_0.set_mtu(self.mtu_small_packet) def get_mtu_long_packet(self): return self.mtu_long_packet def set_mtu_long_packet(self, mtu_long_packet): self.mtu_long_packet = mtu_long_packet self.gr_satellites_bug_hier_0.set_mtu(self.mtu_long_packet) def decode(self, frame_to_decode: bytes): print("Decode method called") packet_content_as_integers = [int(b) for b in frame_to_decode] for i in range(256): packet_content_as_integers.append(0) #Add 256 zero bytes to avoid unfilling of buffers of flowgraph sometimes example_tag_dict = pmt.to_pmt({'example_tag': self.iter}) self.iter+=1 print("Created dictionary for ids") msg_send = pmt.cons(example_tag_dict, pmt.init_u8vector(len(packet_content_as_integers), packet_content_as_integers)) self.message_publisher.message_port_pub(pmt.intern('out'), msg_send) ```Hier block stays autogenerated by GNURadio. Script to run flowgraph:
Script to run flowgraph
```python import pmt from gnuradio import gr import time from typing import List import threading from gr_satellites_bug import gr_satellites_bug def test_decode(): decoder = gr_satellites_bug() decoder_thread = threading.Thread(target=decoder.start) decoder_thread.start() # time for startup time.sleep(0.5) raw_data_to_decode_small_packet = b'\x71\x9d\x83\xc9\x53\x42\x2d\xfa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' raw_data_to_decode_long_packet = b'\x24\xc8\xd6\x9c\x06\x17\x78\xaf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' decoder.decode(raw_data_to_decode_long_packet) time.sleep(5) decoder.decode(raw_data_to_decode_small_packet) time.sleep(5) decoder.decode(raw_data_to_decode_long_packet) time.sleep(5) decoder.decode(raw_data_to_decode_small_packet) time.sleep(5) decoder_thread.join() if __name__ == "__main__": test_decode() ```I'm pushing messages with special "example_tag" that increases with every decode() method call. Result:
Result output
As i can see from Tag Debug info, tags in "inactive" (e.g. "syncword" not detected) part of flowgraph are buffered in "Fixed Length Packet Tagger" block. When pushing to TopBlock frames with different "syncword" block works unexpectedly, mixing and, sometimes, missing all additional tags.
Environment: GNU Radio: 3.10.1.1 gr-satellites: 5.0.0 python: 3.10.6