GNU Radio Manual and C++ API Reference  3.7.4
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_FEC_CCSDS_ENCODER_H
24 #define INCLUDED_FEC_CCSDS_ENCODER_H
25 
26 #include <gnuradio/fec/api.h>
27 #include <gnuradio/fec/encoder.h>
28 #include <gnuradio/fec/cc_common.h>
29 #include <map>
30 #include <string>
31 
32 namespace gr {
33  namespace fec {
34  namespace code {
35 
36  /*!
37  * \brief CCSDS Encoding class for convolutional encoding with
38  * rate 1/2, K=7, and polynomials [109, 79].
39  * \ingroup error_coding_blk
40  *
41  * \details
42  *
43  * Uses Phil Karn's (KA9Q) implementation of the CCSDS encoder
44  * for rate 1/2, K=7, and CC polynomial [109, 79]. These are
45  * non-adjustable in this encoder. For an adjustable CC encoder
46  * where we can set the rate, constraint length, and polynomial,
47  * see gr::fec::code::cc_encoder.
48  *
49  * The encoder is set up wtih a number of bits per frame in the
50  * constructor. When not being used in a tagged stream mode,
51  * this encoder will only process frames of the length provided
52  * here. If used in a tagged stream block, this setting becomes
53  * the maximum allowable frame size that the block may process.
54  *
55  * The \p mode is a cc_mode_t that specifies how the convolutional
56  * encoder will behave and under what conditions.
57  *
58  * \li 'CC_STREAMING': mode expects an uninterrupted flow of
59  * samples into the encoder, and the output stream is
60  * continually encoded.
61  *
62  * \li 'CC_TERMINATED': is a mode designed for packet-based
63  * systems. This mode adds rate*(k-1) bits to the output as a
64  * way to help flush the decoder.
65  *
66  * \li 'CC_TAILBITING': is another packet-based method. Instead of
67  * adding bits onto the end of the packet, this mode will
68  * continue the code between the payloads of packets by
69  * pre-initializing the state of the new packet based on the
70  * state of the last packet for (k-1) bits.
71  *
72  * \li 'CC_TRUNCATED': a truncated code always resets the registers
73  * to the \p start_state between frames.
74  *
75  * A common convolutional encoder uses K=7, Rate=1/2,
76  * Polynomials=[109, 79]. This is the Voyager code from NASA:
77  * \li 109: b(1101101) --> 1 + x + x^3 + x^4 + x^6
78  * \li 79: b(1001111) --> 1 + x^3 + x^4 + x^5 + x^6
79  */
80  class FEC_API ccsds_encoder : virtual public generic_encoder
81  {
82  public:
83 
84  /*!
85  * Build the CCSDS (rate=1/2, K=7, polys=[109,79]
86  * convolutional code FECAPI object.
87  *
88  * \param frame_size Number of bits per frame. If using in the
89  * tagged stream style, this is the maximum allowable
90  * number of bits per frame.
91  * \param start_state Initialization state of the shift register.
92  * \param mode cc_mode_t mode of the encoding.
93  */
94  static generic_encoder::sptr make
95  (int frame_size, int start_state = 0,
96  cc_mode_t mode=CC_STREAMING);
97 
98  /*!
99  * Sets the uncoded frame size to \p frame_size. If \p
100  * frame_size is greater than the value given to the
101  * constructor, the frame size will be capped by that initial
102  * value and this function will return false. Otherwise, it
103  * returns true.
104  */
105  virtual bool set_frame_size(unsigned int frame_size) = 0;
106 
107  /*!
108  * Returns the coding rate of this encoder.
109  */
110  virtual double rate() = 0;
111  };
112 
113  } /* namespace code */
114  } /* namespace fec */
115 } /* namespace gr */
116 
117 #endif /* INCLUDED_FEC_CCSDS_ENCODER_H */
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
enum _cc_mode_t cc_mode_t
Definition: generic_encoder.h:34
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:30
Definition: cc_common.h:27
CCSDS Encoding class for convolutional encoding with rate 1/2, K=7, and polynomials [109...
Definition: ccsds_encoder.h:80