diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index e1fbdf7..64b14de 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -41,7 +41,11 @@ list(APPEND enabled_blocks satnogs_coarse_doppler_correction_cc.xml satnogs_ax25_encoder_mb.xml satnogs_ax25_decoder_bm.xml - satnogs_waterfall_sink.xml + satnogs_waterfall_sink.xml + satnogs_ogg_source.xml + satnogs_noaa_apt_sink.xml + satnogs_frame_file_sink.xml + satnogs_iq_sink.xml ) if(${INCLUDE_DEBUG_BLOCKS}) @@ -49,8 +53,5 @@ if(${INCLUDE_DEBUG_BLOCKS}) endif() install(FILES ${enabled_blocks} - satnogs_ogg_source.xml - satnogs_noaa_apt_sink.xml - satnogs_frame_file_sink.xml DESTINATION share/gnuradio/grc/blocks - satnogs_iq_sink.xml + DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/satnogs_morse_debug_source.xml b/grc/satnogs_morse_debug_source.xml index 84b411c..a6db658 100644 --- a/grc/satnogs_morse_debug_source.xml +++ b/grc/satnogs_morse_debug_source.xml @@ -4,7 +4,14 @@ satnogs_morse_debug_source [SatNOGS]/Debug import satnogs - satnogs.morse_debug_source($debug_seq, $errors, $p) + satnogs.morse_debug_source($wpm, $debug_seq, $errors, $p, $seq_pause_ms) + + + WPM + wpm + 20 + int + Sentence @@ -33,6 +40,13 @@ 0.1 real + + + Sequence Pause (millis) + seq_pause_ms + 1000 + int + out diff --git a/include/satnogs/CMakeLists.txt b/include/satnogs/CMakeLists.txt index d8e1ee5..a803a97 100644 --- a/include/satnogs/CMakeLists.txt +++ b/include/satnogs/CMakeLists.txt @@ -55,16 +55,18 @@ list(APPEND HEADER_FILES ax25_encoder_mb.h ax25_decoder_bm.h qb50_deframer.h - waterfall_sink.h + waterfall_sink.h + ogg_source.h + noaa_apt_sink.h + frame_file_sink.h + iq_sink.h ) if(${INCLUDE_DEBUG_BLOCKS}) list(APPEND HEADER_FILES ${DEBUG_HEADER_FILES}) endif() + install(FILES ${HEADER_FILES} - ogg_source.h - noaa_apt_sink.h - frame_file_sink.h DESTINATION include/satnogs - iq_sink.h DESTINATION + DESTINATION include/satnogs ) \ No newline at end of file diff --git a/include/satnogs/morse_debug_source.h b/include/satnogs/morse_debug_source.h index a972d6b..fd0f489 100644 --- a/include/satnogs/morse_debug_source.h +++ b/include/satnogs/morse_debug_source.h @@ -2,7 +2,8 @@ /* * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module * - * Copyright (C) 2016, Libre Space Foundation + * Copyright (C) 2016,2017 + * Libre Space Foundation * * 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 @@ -24,8 +25,10 @@ #include #include -namespace gr { - namespace satnogs { +namespace gr +{ + namespace satnogs + { /*! * \brief A Morse debug source block that supports injection of random @@ -36,7 +39,7 @@ namespace gr { */ class SATNOGS_API morse_debug_source : virtual public gr::block { - public: + public: typedef boost::shared_ptr sptr; /*! @@ -45,13 +48,21 @@ namespace gr { * This block can also inject random errors, based on a Bernoulli * distribution. * + * @param wpm words per minute * @param debug_seq A string containing the debug sentence * @param inject_errors if set the debug source block will produce * errors that follow a Bernoulli distribution * @param error_prob the probability p of error for the Bernulli distribution + * @param seq_pause_ms pause in milliseconds between concecutive debug + * sequences. For simplicity the pause duration will be scaled to multiple + * dot durations. */ - static sptr make(const std::string& debug_seq, bool inject_errors = false, - float error_prob = 0.1); + static sptr + make (const size_t wpm, + const std::string& debug_seq, + bool inject_errors = false, + float error_prob = 0.1, + size_t seq_pause_ms = 1000); }; } // namespace satnogs diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 354937d..64aa230 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -63,8 +63,8 @@ list(APPEND satnogs_sources waterfall_sink_impl.cc ogg_source_impl.cc noaa_apt_sink_impl.cc - frame_file_sink_impl.cc) - iq_sink_impl.cc + frame_file_sink_impl.cc + iq_sink_impl.cc) if(${INCLUDE_DEBUG_BLOCKS}) list(APPEND satnogs_sources ${satnogs_debug_sources}) diff --git a/lib/cw_to_symbol_impl.cc b/lib/cw_to_symbol_impl.cc index c2ad18e..95b3f46 100644 --- a/lib/cw_to_symbol_impl.cc +++ b/lib/cw_to_symbol_impl.cc @@ -93,7 +93,7 @@ namespace gr */ size_t i = 1; d_window_size = d_dot_samples / i; - while(d_window_size > 256) { + while(d_window_size > 64) { i++; d_window_size = d_dot_samples / i; } @@ -202,13 +202,17 @@ namespace gr gr_vector_void_star &output_items) { bool triggered; - int i; + size_t i; const float *in_old = (const float *) input_items[0]; const float *in = in_old + history() - 1; + if(noutput_items < 0) { + return noutput_items; + } + /* During idle state search for a possible trigger */ if(d_dec_state == NO_SYNC) { - for(i = 0; i < noutput_items; i++) { + for(i = 0; i < (size_t)noutput_items; i++) { /* * Clamp the input so the window mean is not affected by strong spikes * Good luck understanding this black magic shit! @@ -224,7 +228,7 @@ namespace gr } /* From now one, we handle the input in multiples of a window */ - for (i = 0; i < noutput_items / d_window_size; i++) { + for (i = 0; i < (size_t)noutput_items / d_window_size; i++) { triggered = is_triggered(in + i * d_window_size, d_window_size); switch(d_dec_state) { case SEARCH_DOT: @@ -312,8 +316,8 @@ namespace gr volk_32f_binary_slicer_32i(d_out, d_tmp, len); } - inline int32_t - cw_to_symbol_impl::hadd (const int32_t* in, size_t len) + static inline int32_t + hadd (const int32_t* in, size_t len) { size_t i; int32_t cnt = 0; diff --git a/lib/cw_to_symbol_impl.h b/lib/cw_to_symbol_impl.h index ec3d31d..59fa4ed 100644 --- a/lib/cw_to_symbol_impl.h +++ b/lib/cw_to_symbol_impl.h @@ -67,9 +67,6 @@ namespace gr inline void set_search_space (); - inline int32_t - hadd (const int32_t *in, size_t len); - inline void clamp_input (int32_t *out, const float *in, size_t len); diff --git a/lib/morse_debug_source_impl.cc b/lib/morse_debug_source_impl.cc index 448fe09..0e8e259 100644 --- a/lib/morse_debug_source_impl.cc +++ b/lib/morse_debug_source_impl.cc @@ -34,24 +34,31 @@ namespace gr { morse_debug_source::sptr - morse_debug_source::make (const std::string& debug_seq, bool inject_errors, - float error_prob) + morse_debug_source::make (const size_t wpm, + const std::string& debug_seq, bool inject_errors, + float error_prob, + size_t seq_pause_ms) { return gnuradio::get_initial_sptr ( - new morse_debug_source_impl (debug_seq, inject_errors, error_prob)); + new morse_debug_source_impl (wpm, debug_seq, inject_errors, + error_prob, seq_pause_ms)); } /* * The private constructor */ - morse_debug_source_impl::morse_debug_source_impl (std::string debug_seq, + morse_debug_source_impl::morse_debug_source_impl (const size_t wpm, + std::string debug_seq, bool inject_errors, - float error_prob) : + float error_prob, + size_t seq_pause_ms) : gr::block ("morse_debug_source", gr::io_signature::make (0, 0, 0), gr::io_signature::make (0, 0, 0)), + d_wpm (wpm), d_inject_errors (inject_errors), d_p (error_prob), + d_seq_pause_ms (seq_pause_ms), d_run (true), d_chars { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', @@ -142,7 +149,13 @@ namespace gr } } message_port_pub (port, pmt::from_long (MORSE_L_SPACE)); - std::this_thread::sleep_for (std::chrono::milliseconds (1000)); + + for(i = 0; i < d_seq_pause_ms / (1200/d_wpm); i++) { + message_port_pub (port, pmt::from_long (MORSE_INTRA_SPACE)); + } + + /* Perform a true sleep, to avoid message overload */ + std::this_thread::sleep_for (std::chrono::milliseconds (d_seq_pause_ms)); } } diff --git a/lib/morse_debug_source_impl.h b/lib/morse_debug_source_impl.h index c88d70a..047a418 100644 --- a/lib/morse_debug_source_impl.h +++ b/lib/morse_debug_source_impl.h @@ -2,7 +2,8 @@ /* * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module * - * Copyright (C) 2016, Libre Space Foundation + * Copyright (C) 2016, 2017 + * Libre Space Foundation * * 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 @@ -26,26 +27,31 @@ #include #include -namespace gr { - namespace satnogs { +namespace gr +{ + namespace satnogs + { class morse_debug_source_impl : public morse_debug_source { - private: + private: + const size_t d_wpm; const bool d_inject_errors; const float d_p; + const size_t d_seq_pause_ms; bool d_run; const char d_chars[36]; const std::vector d_symbols; std::thread d_thread; void - send_debug_msg(std::string sentence); + send_debug_msg (std::string sentence); - public: - morse_debug_source_impl(std::string debug_seq, bool inject_errors, - float error_prob); - ~morse_debug_source_impl(); + public: + morse_debug_source_impl (const size_t wpm, std::string debug_seq, + bool inject_errors, + float error_prob, size_t seq_pause_ms); + ~morse_debug_source_impl (); }; } // namespace satnogs