GNU Radio's SATNOGS Package
ccsds_rs_decoder.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
4 *
5 * Copyright (C) 2022, 2024 Libre Space Foundation <http://libre.space/>
6 *
7 * This program 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 of the License, or
10 * (at your option) any later version.
11 *
12 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef CCSDS_RS_DECODER_H
22#define CCSDS_RS_DECODER_H
23
24#include <gnuradio/fec/decoder.h>
27#include <string>
28
29namespace gr {
30namespace satnogs {
31namespace code {
32
33class SATNOGS_API ccsds_rs_decoder : virtual public fec::generic_decoder
34{
35public:
36 static fec::generic_decoder::sptr make(ccsds_rs_encoder::ecc e,
38
40
41 void generic_work(void* inbuffer, void* outbuffer) override;
42
43 /*!
44 * Returns the rate of the code. For every r input bits, there
45 * is 1 output bit, so the rate is 1/r. Used for setting things
46 * like the encoder block's relative rate.
47 *
48 * This function MUST be reimplemented by the child class.
49 */
50 double rate() override;
51
52 /*!
53 * Returns the input size in items that the decoder object uses
54 * to decode a full frame. Often, this number is the number of
55 * bits per frame if the input format is unpacked. If the block
56 * expects packed bytes, then this value should be the number of
57 * bytes (number of bits / 8) per input frame.
58 *
59 * The child class MUST implement this function.
60 */
61 int get_input_size() override;
62
63 /*!
64 * Returns the output size in items that the decoder object
65 * produces after decoding a full frame. Often, this number is
66 * the number of bits in the outputted frame if the input format
67 * is unpacked. If the block produces packed bytes, then this
68 * value should be the number of bytes (number of bits / 8) per
69 * frame produced. This value is generally something like
70 * get_input_size()/R for a 1/R rate code.
71 *
72 * The child class MUST implement this function.
73 */
74 int get_output_size() override;
75
76 /*!
77 * Sets the size of an input item, as in the size of a char or
78 * float item.
79 *
80 * The child class SHOULD implement this function. If not
81 * reimplemented, it returns sizeof(float) as the decoders
82 * typically expect floating point input types.
83 */
84 int get_input_item_size() override;
85
86 /*!
87 * Sets the size of an output item, as in the size of a char or
88 * float item.
89 *
90 * The child class SHOULD implement this function. If not
91 * reimplemented, it returns sizeof(char) as the decoders
92 * typically expect to produce bits or bytes.
93 */
94 int get_output_item_size() override;
95
96 /*!
97 * Set up a conversion type required to setup the data properly
98 * for this decoder. The decoder itself will not implement the
99 * conversion and expects an external wrapper (e.g.,
100 * fec.extended_decoder) to read this value and "do the right
101 * thing" to format the data.
102 *
103 * The default behavior is 'none', which means no conversion is
104 * required. Whatever the get_input_item_size() value returns,
105 * the input is expected to conform directly to this.
106 *
107 * This may also return 'uchar', which indicates that the
108 * wrapper should convert the standard float samples to unsigned
109 * characters, either hard sliced or 8-bit soft symbols. See
110 * gr::fec::code::cc_decoder as an example decoder that uses
111 * this conversion format.
112 *
113 * If 'packed_bits', the block expects the inputs to be packed
114 * hard bits. Each input item is a unsigned char where each of
115 * the 8-bits is a hard bit value.
116 *
117 * The child class SHOULD implement this function. If not
118 * reimplemented, it returns "none".
119 */
120 const char* get_input_conversion() override;
121
122 /*!
123 * Set up a conversion type required to understand the output
124 * style of this decoder. Generally, follow-on processing
125 * expects unpacked bits, so we specify the conversion type here
126 * to indicate what the wrapper (e.g., fec.extended_decoder)
127 * should do to convert the output samples from the decoder into
128 * unpacked bits.
129 *
130 * The default behavior is 'none', which means no conversion is
131 * required. This should mean that the output data is produced
132 * from this decoder as unpacked bit.
133 *
134 * If 'unpack', the block produces packed bytes that should be
135 * unpacked by the wrapper. See gr::fec::code::ccsds_decoder as
136 * an example of a decoder that produces packed bytes.
137 *
138 * The child class SHOULD implement this function. If not
139 * reimplemented, it returns "none".
140 */
141 const char* get_output_conversion() override;
142
143 /*!
144 * Updates the size of a decoded frame.
145 *
146 * The child class MUST implement this function and interpret
147 * how the \p frame_size information affects the block's
148 * behavior. It should also provide bounds checks.
149 */
150 bool set_frame_size(unsigned int frame_size) override;
151
152private:
153 const ccsds_rs_encoder::ecc m_ecc;
155 const size_t m_rs_parity;
156 const size_t m_max_in_frame_len;
157 const size_t m_max_out_frame_len;
158 size_t m_frame_len;
159};
160
161
162} // namespace code
163} // namespace satnogs
164} // namespace gr
165
166#endif // CCSDS_RS_DECODER_H
#define SATNOGS_API
Definition: api.h:19
Definition: ccsds_rs_decoder.h:34
const char * get_output_conversion() override
void generic_work(void *inbuffer, void *outbuffer) override
bool set_frame_size(unsigned int frame_size) override
ccsds_rs_decoder(ccsds_rs_encoder::ecc e, ccsds_rs_encoder::interleaving_depth depth)
const char * get_input_conversion() override
static fec::generic_decoder::sptr make(ccsds_rs_encoder::ecc e, ccsds_rs_encoder::interleaving_depth depth)
ecc
Error correction capabilities.
Definition: ccsds_rs_encoder.h:40
interleaving_depth
Interleaving depth.
Definition: ccsds_rs_encoder.h:46
Definition: amsat_duv_decoder.h:29