GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
async_encoder.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef INCLUDED_FEC_ASYNC_ENCODER_H
12 #define INCLUDED_FEC_ASYNC_ENCODER_H
13 
14 #include <gnuradio/block.h>
15 #include <gnuradio/fec/api.h>
17 #include <memory>
18 
19 namespace gr {
20 namespace fec {
21 
22 /*!
23  * \brief Creates the encoder block for use in GNU Radio
24  * flowgraphs with async message from a given FEC API object
25  * derived from the generic_encoder class.
26  * \ingroup error_coding_blk
27  *
28  * \details
29  *
30  * Encodes frames received as async messages or as a PDU over a
31  * message port. This encoder works off a full message as one
32  * frame or block to encode. The message length is used as the
33  * frame length. To support this, the encoder variable used will
34  * have had its frame_size set. This block treats that initial
35  * frame_size value as the maximum transmission unit (MTU) and
36  * will not process frames larger than that.
37  *
38  * This deployment works off messages and expects them to either
39  * be messages full of unpacked bits or PDU messages, which means
40  * full bytes of a frame from the higher layers, including things
41  * like headers, tails, CRC check bytes, etc. For handling PDUs,
42  * set the \p packed option of this deployment block to True. The
43  * block will then use the FEC API to properly unpack the bits
44  * from the PDU, pass it through the encoder, and repack them to
45  * output the PDUs for the next stage of processing.
46  *
47  * The packed PDU form of this deployment is designed to work well
48  * with other PDU-based blocks to operate within the processing
49  * flow of data packets or frames.
50  *
51  * Due to differences in how data is packed and processed, this
52  * block also offers the ability to change the direction of how
53  * bits are unpacked and packed, where reading or writing from the
54  * LSB or MSB. By default, the \p rev_unpack and \p rev_pack modes
55  * are set to True. Using this setup allows the async block to
56  * behave with PDUs in the same operation and format as the tagged
57  * stream encoders. That is, putting the same data into both the
58  * tagged stream encoder deployment and this with these default
59  * settings should produce the same data.
60  */
61 class FEC_API async_encoder : virtual public block
62 {
63 public:
64  typedef std::shared_ptr<async_encoder> sptr;
65 
66  /*!
67  * Build the PDU-based FEC encoder block from an FECAPI encoder object.
68  *
69  * \param my_encoder An FECAPI encoder object child of the generic_encoder class.
70  * \param packed True if working on packed bytes (like PDUs).
71  * \param rev_unpack Reverse the unpacking order from input bytes to bits.
72  * \param rev_pack Reverse the packing order from bits to output bytes.
73  * \param mtu The Maximum Transmission Unit (MTU) of the input
74  * frame that the block will be able to
75  * process. Specified in bytes and defaults to 1500.
76  */
77  static sptr make(generic_encoder::sptr my_encoder,
78  bool packed = false,
79  bool rev_unpack = true,
80  bool rev_pack = true,
81  int mtu = 1500);
82 
83  int general_work(int noutput_items,
84  gr_vector_int& ninput_items,
85  gr_vector_const_void_star& input_items,
86  gr_vector_void_star& output_items) override = 0;
87 };
88 
89 } /* namespace fec */
90 } /* namespace gr */
91 
92 #endif /* INCLUDED_FEC_ASYNC_ENCODER_H */
The abstract base class for all 'terminal' processing blocks.
Definition: gnuradio-runtime/include/gnuradio/block.h:63
Creates the encoder block for use in GNU Radio flowgraphs with async message from a given FEC API obj...
Definition: async_encoder.h:62
std::shared_ptr< async_encoder > sptr
Definition: async_encoder.h:64
static sptr make(generic_encoder::sptr my_encoder, bool packed=false, bool rev_unpack=true, bool rev_pack=true, int mtu=1500)
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override=0
compute output items from input items
std::shared_ptr< generic_encoder > sptr
Definition: generic_encoder.h:37
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29
std::vector< const void * > gr_vector_const_void_star
Definition: types.h:28
std::vector< void * > gr_vector_void_star
Definition: types.h:27
std::vector< int > gr_vector_int
Definition: types.h:23