2016-03-08 22:19:17 +01:00
|
|
|
/* -*- c++ -*- */
|
|
|
|
/*
|
|
|
|
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
|
|
|
*
|
2018-03-18 10:09:13 +01:00
|
|
|
* Copyright (C) 2016,2018
|
|
|
|
* Libre Space Foundation <http://librespacefoundation.org/>
|
2016-03-08 22:19:17 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-07-01 23:18:44 +02:00
|
|
|
#ifndef INCLUDED_SATNOGS_AX25_DECODER_BM_IMPL_H
|
|
|
|
#define INCLUDED_SATNOGS_AX25_DECODER_BM_IMPL_H
|
2016-03-08 22:19:17 +01:00
|
|
|
|
2016-07-01 23:18:44 +02:00
|
|
|
#include <satnogs/ax25_decoder_bm.h>
|
|
|
|
#include <gnuradio/digital/lfsr.h>
|
2016-03-08 22:19:17 +01:00
|
|
|
|
|
|
|
namespace gr
|
|
|
|
{
|
|
|
|
namespace satnogs
|
|
|
|
{
|
|
|
|
|
2016-07-01 23:18:44 +02:00
|
|
|
class ax25_decoder_bm_impl : public ax25_decoder_bm
|
2016-03-08 22:19:17 +01:00
|
|
|
{
|
|
|
|
private:
|
2016-07-01 23:18:44 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
2018-03-18 10:09:13 +01:00
|
|
|
NO_SYNC, IN_SYNC, DECODING, FRAME_END
|
2016-03-08 22:19:17 +01:00
|
|
|
} decoding_state_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If this flag is set, the decoder operates in promiscuous mode and
|
|
|
|
* forwards all successfully decoded frames
|
|
|
|
*/
|
|
|
|
const bool d_promisc;
|
2016-07-01 23:18:44 +02:00
|
|
|
const bool d_descramble;
|
|
|
|
const size_t d_max_frame_len;
|
2016-03-08 22:19:17 +01:00
|
|
|
decoding_state_t d_state;
|
2016-07-07 16:57:06 +02:00
|
|
|
uint8_t d_shift_reg;
|
2016-03-08 22:19:17 +01:00
|
|
|
uint8_t d_dec_b;
|
2016-07-01 23:18:44 +02:00
|
|
|
uint8_t d_prev_bit_nrzi;
|
2016-03-08 22:19:17 +01:00
|
|
|
size_t d_received_bytes;
|
|
|
|
size_t d_decoded_bits;
|
2016-07-01 23:18:44 +02:00
|
|
|
digital::lfsr d_lfsr;
|
2016-03-08 22:19:17 +01:00
|
|
|
uint8_t *d_frame_buffer;
|
|
|
|
|
2016-07-01 23:18:44 +02:00
|
|
|
void
|
|
|
|
reset_state ();
|
|
|
|
void
|
|
|
|
enter_sync_state ();
|
|
|
|
void
|
2016-08-07 01:11:59 +02:00
|
|
|
enter_decoding_state ();
|
|
|
|
void
|
2016-07-01 23:18:44 +02:00
|
|
|
enter_frame_end ();
|
|
|
|
|
2018-03-18 10:09:13 +01:00
|
|
|
size_t
|
2016-07-01 23:18:44 +02:00
|
|
|
descramble_and_decode (const uint8_t *in, size_t nitems);
|
2018-03-18 10:09:13 +01:00
|
|
|
size_t
|
2016-07-01 23:18:44 +02:00
|
|
|
decode (const uint8_t *in, size_t nitems);
|
2016-03-08 22:19:17 +01:00
|
|
|
|
2018-03-18 10:09:13 +01:00
|
|
|
inline void
|
|
|
|
descramble_and_decode_1b (uint8_t in);
|
|
|
|
inline void
|
|
|
|
decode_1b (uint8_t in);
|
|
|
|
|
|
|
|
|
2016-03-08 22:19:17 +01:00
|
|
|
public:
|
2016-07-01 23:18:44 +02:00
|
|
|
ax25_decoder_bm_impl (const std::string& addr, uint8_t ssid, bool promisc,
|
2018-03-18 10:09:13 +01:00
|
|
|
bool descramble, size_t max_frame_len);
|
2016-07-01 23:18:44 +02:00
|
|
|
~ax25_decoder_bm_impl ();
|
2016-03-08 22:19:17 +01:00
|
|
|
|
|
|
|
// Where all the action really happens
|
|
|
|
int
|
|
|
|
work (int noutput_items, gr_vector_const_void_star &input_items,
|
2018-03-18 10:09:13 +01:00
|
|
|
gr_vector_void_star &output_items);
|
2016-03-08 22:19:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace satnogs
|
|
|
|
} // namespace gr
|
|
|
|
|
2016-07-01 23:18:44 +02:00
|
|
|
#endif /* INCLUDED_SATNOGS_AX25_DECODER_BM_IMPL_H */
|
2016-03-08 22:19:17 +01:00
|
|
|
|