GNU Radio's SATNOGS Package
cw_decoder_priv.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 CW_DECODER_PRIV_H_
22 #define CW_DECODER_PRIV_H_
23 
24 #include <satnogs/api.h>
25 #include <satnogs/morse.h>
26 #include <satnogs/morse_tree.h>
27 #include <satnogs/moving_sum.h>
28 #include <satnogs/decoder.h>
29 #include <pmt/pmt.h>
30 #include <string>
31 
32 namespace gr {
33 namespace satnogs {
34 
35 /**
36  * \brief Helper class for the CW decoder.
37  *
38  * Helper class for the CW decoder. This class performs the actual decoding.
39  *
40  */
42 public:
43 
44  cw_decoder_priv(double freq, float confidence, size_t dot_duration,
45  size_t min_len, size_t max_len);
46 
47  ~cw_decoder_priv();
48 
50  decode(float newval, float snr);
51 
52  void
53  reset();
54 
55 private:
56  typedef enum {
57  NO_SYNC, SEARCH_DOT, SEARCH_DASH, SEARCH_SPACE
58  } cw_dec_state_t;
59 
60  const double d_freq;
61  const float d_confidence;
62  const size_t d_dot_duration;
63  const size_t d_dash_duration;
64  const size_t d_short_pause_duration;
65  const size_t d_long_pause_duration;
66  const size_t d_min_len;
67  const size_t d_max_len;
68  const float d_trigger_level;
69  size_t d_width;
70  morse_tree d_morse_tree;
71  std::string d_str;
72  cw_dec_state_t d_state;
73  float d_snr;
74  /**
75  * Moving sum for the SNR above threshold triggers
76  */
77  moving_sum<float> d_movs;
78  /**
79  * Local standard deviation of the triggers
80  */
81  moving_sum<float> d_std_movs;
82  /**
83  * Moving sum for the calculation of the local std
84  */
85  moving_sum<float> d_std_sq_movs;
86 
87  inline bool
88  is_triggered(float meanval, float cv);
89 
90  inline bool
91  check_conf_level(size_t cnt, size_t target);
92 
93  inline void
94  enter_no_sync();
95 
96  inline void
97  enter_search_dot();
98 
99  inline void
100  enter_search_dash();
101 
102  inline void
103  enter_search_space();
104 
105  inline void
106  reset_snr_stats();
107 
108 
109  std::string
110  received_symbol(morse_symbol_t s);
111 };
112 
113 } /* namespace satnogs */
114 } /* namespace gr */
115 
116 #endif /* CW_DECODER_PRIV_H_ */
Helper class for the CW decoder.
Definition: cw_decoder_priv.h:41
Definition: amsat_duv_decoder.h:29
A Binary tree representation of the Morse coding scheme. Left transitions occur when a dot is receive...
Definition: morse_tree.h:67
class decoder_status decoder_status_t
Definition: decoder.h:55
#define SATNOGS_API
Definition: api.h:30
data_t s[NROOTS]
Definition: decode_rs.h:75
morse_symbol_t
Definition: morse.h:28