GNU Radio's SATNOGS Package
ax100_mode6.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) 2020, 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 INCLUDED_SATNOGS_AX100_MODE6_H
22 #define INCLUDED_SATNOGS_AX100_MODE6_H
23 
24 #include <satnogs/api.h>
25 #include <satnogs/decoder.h>
26 #include <gnuradio/digital/lfsr.h>
27 #include <satnogs/crc.h>
28 #include <satnogs/whitening.h>
29 
30 #include <deque>
31 
32 namespace gr {
33 namespace satnogs {
34 
35 /*!
36  * \brief AX.100 mode 6 decoder
37  *
38  * Mode 6 Decoder for the AX100 modem of GomSpace.
39  *
40  * In this particular mode, the modem encapsulates the payload inside an
41  * AX.25 frame. The payload is appended with a Castagnoli CRC32, scrambled with
42  * a CCSDS scrambler and encoded using the CCSDS compliant Reed Solomon.
43  *
44  * This non-sense framing scheme is used mainly for getting data
45  * from legacy ham stations receiving and reporting AX.25 frames.
46  *
47  * The implementation drops any kind of AX.25 information and does not check
48  * the 16-bit CRC, allowing the Reed Solomon to correct any error bits.
49  *
50  * \ingroup satnogs
51  *
52  */
54 public:
55 
56 
57  static decoder::decoder_sptr
59  whitening::whitening_sptr descrambler = whitening::make_ccsds(),
60  bool ax25_descramble = true);
61 
62  ax100_mode6(crc::crc_t crc, whitening::whitening_sptr descrambler,
63  bool ax25_descramble);
64 
65  ~ax100_mode6();
66 
68  decode(const void *in, int len);
69 
70  void
71  reset();
72 private:
73 
74  typedef enum {
75  NO_SYNC, IN_SYNC, DECODING
76  } decoding_state_t;
77 
78  /**
79  * If this flag is set, the decoder operates in promiscuous mode and
80  * forwards all successfully decoded frames
81  */
82  const crc::crc_t d_crc;
83  const bool d_ax25_descramble;
84  const size_t d_max_frame_len;
85  whitening::whitening_sptr d_descrambler;
86  decoding_state_t d_state;
87  uint32_t d_shift_reg;
88  uint8_t d_dec_b;
89  uint8_t d_prev_bit_nrzi;
90  size_t d_received_bytes;
91  size_t d_decoded_bits;
92  digital::lfsr d_lfsr;
93  uint8_t *d_frame_buffer;
94  std::deque<uint8_t> d_bitstream;
95  size_t d_start_idx;
96  uint64_t d_frame_start;
97  uint64_t d_sample_cnt;
98 
99  void
100  reset_state();
101  void
102  enter_sync_state();
103  void
104  enter_decoding_state();
105  bool
106  enter_frame_end(decoder_status_t &status);
107 
108  bool
109  _decode(decoder_status_t &status);
110 
111  inline void
112  decode_1b(uint8_t in);
113 };
114 
115 } // namespace satnogs
116 } // namespace gr
117 
118 #endif /* INCLUDED_SATNOGS_AX100_MODE6_H */
119 
Abstract class that provided the API for the c decoders.
Definition: decoder.h:69
Definition: amsat_duv_decoder.h:29
enum gr::satnogs::crc::crc_type crc_t
class decoder_status decoder_status_t
Definition: decoder.h:55
static whitening_sptr make_ccsds(bool msb=false)
AX.100 mode 6 decoder.
Definition: ax100_mode6.h:53
Definition: crc.h:33
Definition: crc.h:42
#define SATNOGS_API
Definition: api.h:30