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-2023, 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 * SPDX-License-Identifier: GNU General Public License v3.0 or later
21 */
22
23
24#ifndef INCLUDED_SATNOGS_ARGOS_LDR_DECODER_H
25#define INCLUDED_SATNOGS_ARGOS_LDR_DECODER_H
26
29
30#include <deque>
31
32namespace gr {
33namespace satnogs {
34
35/*!
36 * \brief ARGOS Low Data Rate HDLC decoder
37 *
38 * \ingroup satnogs
39 *
40 */
42{
43public:
44 /**
45 * The decoder take as input a quadrature demodulated bit stream.
46 * Each byte should contains only one bit of information at the LSB.
47 *
48 * propagated
49 * @param max_frame_len the maximum allowed frame length
50 *
51 * @return a shared pointer of the decoder instance
52 */
53 using sptr = std::shared_ptr<argos_ldr_decoder>;
54 static sptr make(bool crc_check = true, size_t max_frame_len = 64);
55
56 /**
57 * The decoder take as input a quadrature demodulated bit stream.
58 * Each byte should contains only one bit of information at the LSB.
59 *
60 * propagated
61 * @param max_frame_len the maximum allowed frame length
62 *
63 * @return a shared pointer of the decoder instance
64 */
65 argos_ldr_decoder(bool crc_check = true, size_t max_frame_len = 64);
66
68
69 decoder_status_t decode(const void* in, int len);
70
71 void reset();
72
73private:
74 typedef enum { NO_SYNC, IN_SYNC, DECODING } decoding_state_t;
75
76 const bool d_crc_check;
77 const size_t d_max_frame_len;
78 decoding_state_t d_state;
79 uint32_t d_shift_reg;
80 uint8_t d_dec_b;
81 size_t d_received_bytes;
82 size_t d_decoded_bits;
83 uint8_t* d_frame_buffer;
84 std::deque<uint8_t> d_bitstream;
85 size_t d_start_idx;
86 uint64_t d_frame_start;
87 uint64_t d_sample_cnt;
88
89 void reset_state();
90 void enter_sync_state();
91 void enter_decoding_state();
92 bool enter_frame_end(decoder_status_t& status);
93
94 bool _decode(decoder_status_t& status);
95
96 inline void decode_1b(uint8_t in);
97 bool frame_check();
98};
99
100} // namespace satnogs
101} // namespace gr
102
103#endif /* INCLUDED_SATNOGS_ARGOS_LDR_DECODER_H */
#define SATNOGS_API
Definition: api.h:19
ARGOS Low Data Rate HDLC decoder.
Definition: argos_ldr_decoder.h:42
std::shared_ptr< argos_ldr_decoder > sptr
Definition: argos_ldr_decoder.h:53
static sptr make(bool crc_check=true, size_t max_frame_len=64)
argos_ldr_decoder(bool crc_check=true, size_t max_frame_len=64)
decoder_status_t decode(const void *in, int len)
Abstract class that provided the API for the c decoders.
Definition: decoder.h:71
class decoder_status decoder_status_t
Definition: decoder.h:56
Definition: amsat_duv_decoder.h:29