GNU Radio's SATNOGS Package
argos_ldr_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) 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_ARGOS_LDR_DECODER_H
22 #define INCLUDED_SATNOGS_ARGOS_LDR_DECODER_H
23 
24 #include <satnogs/api.h>
25 #include <satnogs/decoder.h>
26 
27 #include <deque>
28 
29 namespace gr {
30 namespace satnogs {
31 
32 /*!
33  * \brief ARGOS Low Data Rate HDLC decoder
34  *
35  * \ingroup satnogs
36  *
37  */
39 public:
40 
41  /**
42  * The decoder take as input a quadrature demodulated bit stream.
43  * Each byte should contains only one bit of information at the LSB.
44  *
45  * propagated
46  * @param max_frame_len the maximum allowed frame length
47  *
48  * @return a shared pointer of the decoder instance
49  */
50  static decoder::decoder_sptr
51  make(bool crc_check = true, size_t max_frame_len = 64);
52 
53  /**
54  /**
55  * The decoder take as input a quadrature demodulated bit stream.
56  * Each byte should contains only one bit of information at the LSB.
57  *
58  * propagated
59  * @param max_frame_len the maximum allowed frame length
60  *
61  * @return a shared pointer of the decoder instance
62  */
63  argos_ldr_decoder(bool crc_check = true, size_t max_frame_len = 64);
64 
65  ~argos_ldr_decoder();
66 
67  decoder_status_t
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  const bool d_crc_check;
79  const size_t d_max_frame_len;
80  decoding_state_t d_state;
81  uint32_t d_shift_reg;
82  uint8_t d_dec_b;
83  size_t d_received_bytes;
84  size_t d_decoded_bits;
85  uint8_t *d_frame_buffer;
86  std::deque<uint8_t> d_bitstream;
87  size_t d_start_idx;
88  uint64_t d_frame_start;
89  uint64_t d_sample_cnt;
90 
91  void
92  reset_state();
93  void
94  enter_sync_state();
95  void
96  enter_decoding_state();
97  bool
98  enter_frame_end(decoder_status_t &status);
99 
100  bool
101  _decode(decoder_status_t &status);
102 
103  inline void
104  decode_1b(uint8_t in);
105  bool
106  frame_check();
107 };
108 
109 } // namespace satnogs
110 } // namespace gr
111 
112 #endif /* INCLUDED_SATNOGS_ARGOS_LDR_DECODER_H */
113 
Abstract class that provided the API for the c decoders.
Definition: decoder.h:69
ARGOS Low Data Rate HDLC decoder.
Definition: argos_ldr_decoder.h:38
Definition: amsat_duv_decoder.h:29
#define SATNOGS_API
Definition: api.h:30