GNU Radio's SATNOGS Package
ax100_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) 2019, 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_DECODER_H
22 #define INCLUDED_SATNOGS_AX100_DECODER_H
23 
24 #include <satnogs/api.h>
25 #include <satnogs/decoder.h>
26 #include <satnogs/shift_reg.h>
27 #include <satnogs/crc.h>
28 #include <satnogs/whitening.h>
29 
30 namespace gr {
31 namespace satnogs {
32 
33 /*!
34  * \brief This decoder tries to cover all the supported framing and coding
35  * schemes of the AX100 product from GOMSpace. It also supports some variants
36  * that have appear in different missions, including excet the ASM and a
37  * repeated preamble
38  *
39  */
41 public:
42  static decoder_sptr
43  make(const std::vector<uint8_t> &preamble,
44  size_t preamble_threshold,
45  const std::vector<uint8_t> &sync,
46  size_t sync_threshold,
48  whitening::whitening_sptr descrambler,
49  bool enable_rs);
50 
51  ax100_decoder(const std::vector<uint8_t> &preamble,
52  size_t preamble_threshold,
53  const std::vector<uint8_t> &sync,
54  size_t sync_threshold,
55  crc::crc_t crc,
56  whitening::whitening_sptr descrambler,
57  bool enable_rs);
58  ~ax100_decoder();
59 
61  decode(const void *in, int len);
62 
63  void
64  reset();
65 
66  size_t
67  input_multiple() const;
68 
69 private:
70  /**
71  * Decoding FSM
72  */
73  typedef enum {
74  SEARCHING, //!< when searching for the start of the preamble
75  SEARCHING_SYNC, //!< We have preamble, search for sync
76  DECODING_FRAME_LEN, //!< Decoding the frame length
77  DECODING_PAYLOAD //!< Decoding the payload
78  } decoding_state_t;
79 
80  shift_reg d_preamble;
81  shift_reg d_preamble_shift_reg;
82  const size_t d_preamble_len;
83  const size_t d_preamble_thrsh;
84  shift_reg d_sync;
85  shift_reg d_sync_shift_reg;
86  const size_t d_sync_len;
87  const size_t d_sync_thrsh;
88  crc::crc_t d_crc;
89  whitening::whitening_sptr d_descrambler;
90  const bool d_rs;
91  decoding_state_t d_state;
92  size_t d_cnt;
93  size_t d_len;
94  size_t d_length_field_len;
95  uint8_t *d_pdu;
96 
97  int
98  search_preamble(const uint8_t *in, int len);
99 
100  int
101  search_sync(const uint8_t *in, int len);
102 
103  int
104  decode_frame_len(const uint8_t *in, int len);
105 
106  void
107  decode_payload(decoder_status_t &status, const uint8_t *in, int len);
108 
109  bool
110  check_crc();
111 };
112 
113 } // namespace satnogs
114 } // namespace gr
115 
116 #endif /* INCLUDED_SATNOGS_AX100_DECODER_H */
117 
Abstract class that provided the API for the c decoders.
Definition: decoder.h:69
Implements a bit shift register.
Definition: shift_reg.h:35
Definition: amsat_duv_decoder.h:29
enum gr::satnogs::crc::crc_type crc_t
class decoder_status decoder_status_t
Definition: decoder.h:55
This decoder tries to cover all the supported framing and coding schemes of the AX100 product from GO...
Definition: ax100_decoder.h:40
Definition: crc.h:33
#define SATNOGS_API
Definition: api.h:30