GNU Radio's SATNOGS Package
ax100_mode5.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_MODE5_H
22 #define INCLUDED_SATNOGS_AX100_MODE5_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 decode implements the AX100 mode 5 scheme
35  *
36  */
38 public:
39  static decoder_sptr
40  make(const std::vector<uint8_t> &preamble,
41  size_t preamble_threshold,
42  const std::vector<uint8_t> &sync,
43  size_t sync_threshold,
45  whitening::whitening_sptr descrambler,
46  bool enable_rs);
47 
48  ax100_mode5(const std::vector<uint8_t> &preamble,
49  size_t preamble_threshold,
50  const std::vector<uint8_t> &sync,
51  size_t sync_threshold,
52  crc::crc_t crc,
53  whitening::whitening_sptr descrambler,
54  bool enable_rs);
55  ~ax100_mode5();
56 
58  decode(const void *in, int len);
59 
60  void
61  reset();
62 
63  size_t
64  input_multiple() const;
65 
66 private:
67  /**
68  * Decoding FSM
69  */
70  typedef enum {
71  SEARCHING, //!< when searching for the start of the preamble
72  SEARCHING_SYNC, //!< We have preamble, search for sync
73  DECODING_FRAME_LEN, //!< Decoding the frame length
74  DECODING_PAYLOAD //!< Decoding the payload
75  } decoding_state_t;
76 
77  shift_reg d_preamble;
78  shift_reg d_preamble_shift_reg;
79  const size_t d_preamble_len;
80  const size_t d_preamble_thrsh;
81  shift_reg d_sync;
82  shift_reg d_sync_shift_reg;
83  const size_t d_sync_len;
84  const size_t d_sync_thrsh;
85  crc::crc_t d_crc;
86  whitening::whitening_sptr d_descrambler;
87  const bool d_rs;
88  decoding_state_t d_state;
89  size_t d_cnt;
90  size_t d_len;
91  size_t d_length_field_len;
92  uint8_t *d_pdu;
93  uint64_t d_frame_start;
94 
95  int
96  search_preamble(const uint8_t *in, int len);
97 
98  int
99  search_sync(const uint8_t *in, int len);
100 
101  int
102  decode_frame_len(const uint8_t *in, int len);
103 
104  void
105  decode_payload(decoder_status_t &status, const uint8_t *in, int len);
106 
107  bool
108  check_crc();
109 };
110 
111 } // namespace satnogs
112 } // namespace gr
113 
114 #endif /* INCLUDED_SATNOGS_AX100_MODE5_H */
115 
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
This decode implements the AX100 mode 5 scheme.
Definition: ax100_mode5.h:37
enum gr::satnogs::crc::crc_type crc_t
class decoder_status decoder_status_t
Definition: decoder.h:55
Definition: crc.h:33
#define SATNOGS_API
Definition: api.h:30