GNU Radio's SATNOGS Package
frame_acquisition_impl.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) 2018, Libre Space Foundation <http://librespacefoundation.org/>
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_FRAME_ACQUISITION_IMPL_H
22 #define INCLUDED_SATNOGS_FRAME_ACQUISITION_IMPL_H
23 
24 #include <satnogs/shift_reg.h>
26 
27 namespace gr {
28 namespace satnogs {
29 
31 
32 public:
34  const std::vector<uint8_t> &preamble,
35  size_t preamble_threshold,
36  const std::vector<uint8_t> &sync,
37  size_t sync_threshold,
38  size_t frame_size_field_len,
39  size_t frame_len,
41  whitening::whitening_sptr descrambler,
42  size_t max_frame_len);
43 
45 
46  // Where all the action really happens
47  int
48  work(int noutput_items, gr_vector_const_void_star &input_items,
49  gr_vector_void_star &output_items);
50 
51 private:
52  /**
53  * Decoding FSM
54  */
55  typedef enum {
56  SEARCHING, //!< when searching for the start of the preamble
57  SEARCHING_SYNC,
58  DECODING_GENERIC_FRAME_LEN,
59  DECODING_GOLAY24_FRAME_LEN,
60  DECODING_PAYLOAD
61  } decoding_state_t;
62 
63  const variant_t d_variant;
64  shift_reg d_preamble;
65  shift_reg d_preamble_shift_reg;
66  const size_t d_preamble_len;
67  const size_t d_preamble_thrsh;
68  shift_reg d_sync;
69  shift_reg d_sync_shift_reg;
70  const size_t d_sync_len;
71  const size_t d_sync_thrsh;
72  decoding_state_t d_state;
73  uint32_t d_cnt;
74  uint32_t d_frame_size_field_len;
75  uint32_t d_frame_len;
76  const uint32_t d_max_frame_len;
77  const checksum_t d_crc;
78  uint32_t d_crc_len;
79  whitening::whitening_sptr d_whitening;
80  uint8_t *d_pdu;
81 
82 
83  int
84  searching_preamble(const uint8_t *in, int len);
85 
86  int
87  searching_sync(const uint8_t *in, int len);
88 
89  int dec_generic_frame_len(const uint8_t *in, int len);
90 
91 
92  int dec_golay24_frame_len(const uint8_t *in, int len);
93 
94  int
95  decoding(const uint8_t *in, int len);
96 
97  void
98  reset();
99 
100  bool
101  check_crc();
102 };
103 
104 } // namespace satnogs
105 } // namespace gr
106 
107 #endif /* INCLUDED_SATNOGS_FRAME_ACQUISITION_IMPL_H */
108 
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
Definition: frame_acquisition_impl.h:30
A generic frame acquisition block.
Definition: frame_acquisition.h:61
variant_t
Definition: frame_acquisition.h:68
Implements a bit shift register.
Definition: shift_reg.h:35
Definition: amsat_duv_decoder.h:29
checksum_t
Definition: frame_acquisition.h:74
Definition: crc.h:33
frame_acquisition_impl(variant_t variant, const std::vector< uint8_t > &preamble, size_t preamble_threshold, const std::vector< uint8_t > &sync, size_t sync_threshold, size_t frame_size_field_len, size_t frame_len, checksum_t crc, whitening::whitening_sptr descrambler, size_t max_frame_len)