2016-01-27 21:54:42 +01:00
|
|
|
/* -*- c++ -*- */
|
|
|
|
/*
|
|
|
|
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_SATNOGS_CW_TO_SYMBOL_IMPL_H
|
|
|
|
#define INCLUDED_SATNOGS_CW_TO_SYMBOL_IMPL_H
|
|
|
|
|
2016-01-30 20:37:36 +01:00
|
|
|
#include <satnogs/morse.h>
|
2016-01-27 21:54:42 +01:00
|
|
|
#include <satnogs/cw_to_symbol.h>
|
|
|
|
|
|
|
|
namespace gr
|
|
|
|
{
|
|
|
|
namespace satnogs
|
|
|
|
{
|
|
|
|
|
|
|
|
class cw_to_symbol_impl : public cw_to_symbol
|
|
|
|
{
|
|
|
|
typedef enum {
|
|
|
|
IDLE,
|
|
|
|
SHORT_ON_PERIOD,
|
|
|
|
LONG_ON_PERIOD,
|
|
|
|
SHORT_OFF_PERIOD,
|
|
|
|
LONG_OFF_PERIOD
|
|
|
|
} cw_state_t;
|
2016-02-27 23:45:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Different states during the WPM auto synchronization
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
SYNC_TRIGGER_OFF,//!< SYNC_TRIGGER_OFF Signal is below threshold
|
|
|
|
SYNC_TRIGGER_ON //!< SYNC_TRIGGER_ON Signal is above threshold
|
|
|
|
} sync_state_t;
|
|
|
|
|
2016-01-27 21:54:42 +01:00
|
|
|
private:
|
|
|
|
const double d_sampling_rate;
|
2016-02-17 02:16:18 +01:00
|
|
|
float d_act_thrshld;
|
2016-01-27 21:54:42 +01:00
|
|
|
const float d_confidence_level;
|
2016-02-27 23:45:41 +01:00
|
|
|
const size_t d_sync_limit;
|
|
|
|
const bool d_auto_sync;
|
|
|
|
size_t d_dot_samples;
|
|
|
|
size_t d_dash_samples;
|
|
|
|
size_t d_short_pause_samples;
|
|
|
|
size_t d_long_pause_samples;
|
2016-01-27 21:54:42 +01:00
|
|
|
cw_state_t d_state;
|
|
|
|
size_t d_state_cnt;
|
|
|
|
size_t d_pause_cnt;
|
2016-02-27 23:45:41 +01:00
|
|
|
size_t d_est_cnt;
|
|
|
|
size_t d_mean_cnt;
|
|
|
|
bool d_have_sync;
|
2016-01-30 20:37:36 +01:00
|
|
|
bool d_seq_started;
|
2016-02-27 23:45:41 +01:00
|
|
|
sync_state_t d_sync_state;
|
2016-01-27 21:54:42 +01:00
|
|
|
|
|
|
|
inline void
|
|
|
|
set_idle ();
|
|
|
|
|
|
|
|
inline void
|
|
|
|
set_short_on ();
|
|
|
|
|
|
|
|
inline void
|
|
|
|
set_long_on ();
|
|
|
|
|
|
|
|
inline void
|
2016-01-30 20:37:36 +01:00
|
|
|
set_short_off ();
|
2016-01-27 21:54:42 +01:00
|
|
|
|
|
|
|
inline void
|
|
|
|
set_long_off ();
|
|
|
|
|
2016-01-30 20:37:36 +01:00
|
|
|
inline void
|
|
|
|
send_symbol_msg (morse_symbol_t s);
|
|
|
|
|
2016-02-17 02:16:18 +01:00
|
|
|
void set_act_threshold_msg_handler(pmt::pmt_t msg);
|
|
|
|
|
2016-02-27 23:45:41 +01:00
|
|
|
void sync_msg_handler(pmt::pmt_t msg);
|
|
|
|
|
|
|
|
void estimate_dot_duration(size_t estimate);
|
|
|
|
|
|
|
|
void set_symbols_duration();
|
|
|
|
|
|
|
|
void reset_sync();
|
|
|
|
|
2016-01-27 21:54:42 +01:00
|
|
|
public:
|
2016-01-30 20:37:36 +01:00
|
|
|
cw_to_symbol_impl (double sampling_rate, float threshold,
|
2016-02-27 23:45:41 +01:00
|
|
|
float conf_level, size_t wpm, bool auto_config);
|
2016-01-27 21:54:42 +01:00
|
|
|
~cw_to_symbol_impl ();
|
|
|
|
|
|
|
|
// Where all the action really happens
|
|
|
|
int
|
|
|
|
work (int noutput_items, gr_vector_const_void_star &input_items,
|
|
|
|
gr_vector_void_star &output_items);
|
2016-02-17 02:16:18 +01:00
|
|
|
|
|
|
|
void set_act_threshold(float thrhld);
|
2016-02-27 23:45:41 +01:00
|
|
|
|
|
|
|
void start_timing_recovery();
|
2016-01-27 21:54:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace satnogs
|
|
|
|
} // namespace gr
|
|
|
|
|
|
|
|
#endif /* INCLUDED_SATNOGS_CW_TO_SYMBOL_IMPL_H */
|
|
|
|
|