GNU Radio's SATNOGS Package
whitening.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) 2016, 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_WHITENING_H
22 #define INCLUDED_SATNOGS_WHITENING_H
23 
24 #include <satnogs/api.h>
25 #include <gnuradio/digital/lfsr.h>
26 #include <boost/shared_ptr.hpp>
27 
28 namespace gr {
29 namespace satnogs {
30 
31 /*!
32  * \brief Performs data whitening and de-whitening
33  *
34  */
36 public:
37  static int base_unique_id;
38 
39  int
40  unique_id();
41 
42  typedef boost::shared_ptr<whitening> whitening_sptr;
43 
44  static whitening_sptr
45  make(uint32_t mask, uint32_t seed, uint32_t order, bool msb = false,
46  bool self_sync = false);
47 
48  static whitening_sptr
49  make_ccsds(bool msb = false);
50 
51  static whitening_sptr
52  make_g3ruh(bool msb = false);
53 
54  whitening(uint32_t mask, uint32_t seed, uint32_t order, bool msb = false,
55  bool self_sync = false);
56 
57  ~whitening();
58 
59  void
60  reset();
61 
62  void
63  scramble(uint8_t *out, const uint8_t *in, size_t len);
64  void
65  descramble(uint8_t *out, const uint8_t *in, size_t len);
66 
67  void
68  scramble_one_bit_per_byte(uint8_t *out, const uint8_t *in, size_t bits_num);
69  void
70  descramble_one_bit_per_byte(uint8_t *out, const uint8_t *in,
71  size_t bits_num);
72 
73 private:
74  const bool d_msb;
75  const bool d_self_sync;
76  digital::lfsr d_lfsr;
77  int d_id;
78 };
79 
80 } // namespace satnogs
81 } // namespace gr
82 
83 #endif /* INCLUDED_SATNOGS_WHITENING_H */
Performs data whitening and de-whitening.
Definition: whitening.h:35
static int base_unique_id
Definition: whitening.h:37
Definition: amsat_duv_decoder.h:29
#define SATNOGS_API
Definition: api.h:30