GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
ccsds_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_CCSDS_ENCODER_H
12 #define INCLUDED_FEC_CCSDS_ENCODER_H
13 
14 #include <gnuradio/fec/api.h>
15 #include <gnuradio/fec/cc_common.h>
16 #include <gnuradio/fec/encoder.h>
17 #include <map>
18 #include <string>
19 
20 namespace gr {
21 namespace fec {
22 namespace code {
23 
24 /*!
25  * \brief CCSDS Encoding class for convolutional encoding with
26  * rate 1/2, K=7, and polynomials [109, 79].
27  * \ingroup error_coding_blk
28  *
29  * \details
30  *
31  * Uses Phil Karn's (KA9Q) implementation of the CCSDS encoder
32  * for rate 1/2, K=7, and CC polynomial [109, 79]. These are
33  * non-adjustable in this encoder. For an adjustable CC encoder
34  * where we can set the rate, constraint length, and polynomial,
35  * see gr::fec::code::cc_encoder.
36  *
37  * The encoder is set up with a number of bits per frame in the
38  * constructor. When not being used in a tagged stream mode,
39  * this encoder will only process frames of the length provided
40  * here. If used in a tagged stream block, this setting becomes
41  * the maximum allowable frame size that the block may process.
42  *
43  * The \p mode is a cc_mode_t that specifies how the convolutional
44  * encoder will behave and under what conditions.
45  *
46  * \li 'CC_STREAMING': mode expects an uninterrupted flow of
47  * samples into the encoder, and the output stream is
48  * continually encoded.
49  *
50  * \li 'CC_TERMINATED': is a mode designed for packet-based
51  * systems. This mode adds rate*(k-1) bits to the output as a
52  * way to help flush the decoder.
53  *
54  * \li 'CC_TAILBITING': is another packet-based method. Instead of
55  * adding bits onto the end of the packet, this mode will
56  * continue the code between the payloads of packets by
57  * pre-initializing the state of the new packet based on the
58  * state of the last packet for (k-1) bits.
59  *
60  * \li 'CC_TRUNCATED': a truncated code always resets the registers
61  * to the \p start_state between frames.
62  *
63  * A common convolutional encoder uses K=7, Rate=1/2,
64  * Polynomials=[109, 79]. This is the Voyager code from NASA:
65  * \li 109: b(1101101) --> 1 + x + x^3 + x^4 + x^6
66  * \li 79: b(1001111) --> 1 + x^3 + x^4 + x^5 + x^6
67  */
68 class FEC_API ccsds_encoder : virtual public generic_encoder
69 {
70 public:
71  /*!
72  * Build the CCSDS (rate=1/2, K=7, polys=[109,79]
73  * convolutional code FECAPI object.
74  *
75  * \param frame_size Number of bits per frame. If using in the
76  * tagged stream style, this is the maximum allowable
77  * number of bits per frame.
78  * \param start_state Initialization state of the shift register.
79  * \param mode cc_mode_t mode of the encoding.
80  */
82  make(int frame_size, int start_state = 0, cc_mode_t mode = CC_STREAMING);
83 
84  /*!
85  * Sets the uncoded frame size to \p frame_size. If \p
86  * frame_size is greater than the value given to the
87  * constructor, the frame size will be capped by that initial
88  * value and this function will return false. Otherwise, it
89  * returns true.
90  */
91  bool set_frame_size(unsigned int frame_size) override = 0;
92 
93  /*!
94  * Returns the coding rate of this encoder.
95  */
96  double rate() override = 0;
97 };
98 
99 } /* namespace code */
100 } /* namespace fec */
101 } /* namespace gr */
102 
103 #endif /* INCLUDED_FEC_CCSDS_ENCODER_H */
enum _cc_mode_t cc_mode_t
@ CC_STREAMING
Definition: cc_common.h:17
CCSDS Encoding class for convolutional encoding with rate 1/2, K=7, and polynomials [109,...
Definition: ccsds_encoder.h:69
double rate() override=0
static generic_encoder::sptr make(int frame_size, int start_state=0, cc_mode_t mode=CC_STREAMING)
bool set_frame_size(unsigned int frame_size) override=0
Definition: generic_encoder.h:23
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