GNU Radio 3.6.5 C++ API

gr_tagged_stream_block Class Reference

Block that operates on PDUs in form of tagged streamsOverride work to provide the signal processing implementation. More...

#include <gr_tagged_stream_block.h>

Inheritance diagram for gr_tagged_stream_block:
gr_block gr_basic_block gr_msg_accepter gruel::msg_accepter digital_crc32_bb digital_ofdm_carrier_allocator_cvc digital_ofdm_cyclic_prefixer gr::blocks::repack_bits_bb gr::blocks::tagged_stream_mux gr::digital::ofdm_frame_equalizer_vcvc gr::digital::ofdm_serializer_vcc gr::digital::packet_headergenerator_bb

List of all members.

Public Member Functions

void forecast (int noutput_items, gr_vector_int &ninput_items_required)
 Don't override this.
int general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
virtual int work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)=0
 Just like gr_block::general_work, but makes sure the input is valid.

Protected Member Functions

 gr_tagged_stream_block (void)
 gr_tagged_stream_block (const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature, const std::string &length_tag_key)
virtual void parse_length_tags (const std::vector< std::vector< gr_tag_t > > &tags, gr_vector_int &n_input_items_reqd)
 Parse all tags on the first sample of a PDU, return the number of items per input and prune the length tags.
virtual int calculate_output_stream_length (const gr_vector_int &ninput_items)
 Calculate the number of output items.
virtual void update_length_tags (int n_produced, int n_ports)
 Set the new length tags on the output stream.

Protected Attributes

std::string d_length_tag_key_str

Detailed Description

Block that operates on PDUs in form of tagged streams

Override work to provide the signal processing implementation.


Constructor & Destructor Documentation

gr_tagged_stream_block::gr_tagged_stream_block ( void  ) [inline, protected]
gr_tagged_stream_block::gr_tagged_stream_block ( const std::string &  name,
gr_io_signature_sptr  input_signature,
gr_io_signature_sptr  output_signature,
const std::string &  length_tag_key 
) [protected]

Member Function Documentation

virtual int gr_tagged_stream_block::calculate_output_stream_length ( const gr_vector_int ninput_items) [protected, virtual]

Calculate the number of output items.

This is basically the inverse function to forecast(): Given a number of input items, it returns the maximum number of output items.

You most likely need to override this function, unless your block is a sync block or integer interpolator/decimator.

Reimplemented in gr::blocks::repack_bits_bb_impl, gr::blocks::tagged_stream_mux_impl, digital_crc32_bb, digital_ofdm_carrier_allocator_cvc, digital_ofdm_cyclic_prefixer, gr::digital::ofdm_serializer_vcc_impl, and gr::digital::packet_headergenerator_bb_impl.

void gr_tagged_stream_block::forecast ( int  noutput_items,
gr_vector_int ninput_items_required 
) [virtual]

Don't override this.

Reimplemented from gr_block.

int gr_tagged_stream_block::general_work ( int  noutput_items,
gr_vector_int ninput_items,
gr_vector_const_void_star input_items,
gr_vector_void_star output_items 
) [virtual]
  • Reads the number of input items from the tags using parse_length_tags()
  • Checks there's enough data on the input and output buffers
  • If not, inform the scheduler and do nothing
  • Calls work() with the exact number of items per PDU
  • Updates the tags using update_length_tags()

Reimplemented from gr_block.

virtual void gr_tagged_stream_block::parse_length_tags ( const std::vector< std::vector< gr_tag_t > > &  tags,
gr_vector_int n_input_items_reqd 
) [protected, virtual]

Parse all tags on the first sample of a PDU, return the number of items per input and prune the length tags.

In most cases, you don't need to override this, unless the number of items read is not directly coded in one single tag.

Default behaviour:

  • Go through all input ports
  • On every input port, search for the tag with the key specified in length_tag_key
  • Copy that value as an int to the corresponding position in n_input_items_reqd
  • Remove the length tag.
Parameters:
[in]tagsAll the tags found on the first item of every input port.
[out]n_input_items_reqdNumber of items which will be read from every input

Reimplemented in gr::digital::ofdm_frame_equalizer_vcvc_impl.

virtual void gr_tagged_stream_block::update_length_tags ( int  n_produced,
int  n_ports 
) [protected, virtual]

Set the new length tags on the output stream.

Default behaviour: Set a tag with key length_tag_key and the number of produced items on every output port.

For anything else, override this.

Parameters:
n_producedLength of the new PDU
n_portsNumber of output ports

Reimplemented in gr::digital::ofdm_serializer_vcc_impl.

virtual int gr_tagged_stream_block::work ( int  noutput_items,
gr_vector_int ninput_items,
gr_vector_const_void_star input_items,
gr_vector_void_star output_items 
) [pure virtual]

Just like gr_block::general_work, but makes sure the input is valid.

The user must override work to define the signal processing code. Check the documentation for general_work() to see what happens here.

Like gr_sync_block, this calls consume() for you (it consumes ninput_items[i] items from the i-th port).

A note on tag propagation: The PDU length tags are handled by other functions, but all other tags are handled just as in any other gr_block. So, most likely, you either set the tag propagation policy to TPP_DONT and handle the tag propagation manually, or you propagate tags through the scheduler and don't do anything here.

Parameters:
noutput_itemsThe size of the writable output buffer
ninput_itemsThe exact size of the items on every input for this particular PDU. These will be consumed if a length tag key is provided!
input_itemsSee gr_block
output_itemsSee gr_block

Implemented in gr::blocks::repack_bits_bb_impl, gr::blocks::tagged_stream_mux_impl, digital_crc32_bb, digital_ofdm_carrier_allocator_cvc, digital_ofdm_cyclic_prefixer, gr::digital::ofdm_frame_equalizer_vcvc_impl, gr::digital::ofdm_serializer_vcc_impl, and gr::digital::packet_headergenerator_bb_impl.


Member Data Documentation


The documentation for this class was generated from the following file: