Add Morse code debug source block
Now, with the Morse code debug source block the testing of the decoder can begin. Add at the examples directory a small flowgraph that connects the debug source block with the decoder.
This commit is contained in:
parent
d307d6ac34
commit
ebd07215d0
|
@ -26,6 +26,7 @@ enable_testing()
|
|||
|
||||
# Enable C++11 support
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
add_definitions(-std=c++11)
|
||||
|
||||
#select the release build type by default to get optimization flags
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
|
@ -103,6 +104,11 @@ if(APPLE)
|
|||
endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
|
||||
endif(APPLE)
|
||||
|
||||
########################################################################
|
||||
# Find gnuradio build dependencies
|
||||
########################################################################
|
||||
find_package (Threads REQUIRED)
|
||||
|
||||
########################################################################
|
||||
# Find gnuradio build dependencies
|
||||
########################################################################
|
||||
|
|
|
@ -0,0 +1,195 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?grc format='1' created='3.7.10'?>
|
||||
<flow_graph>
|
||||
<timestamp>Fri Jan 22 20:01:21 2016</timestamp>
|
||||
<block>
|
||||
<key>options</key>
|
||||
<param>
|
||||
<key>author</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>window_size</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>category</key>
|
||||
<value>Custom</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>description</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(8, 8)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>generate_options</key>
|
||||
<value>qt_gui</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>hier_block_src_path</key>
|
||||
<value>.:</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>test_morse_decoder</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>max_nouts</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>qt_qss_theme</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>realtime_scheduling</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>run_command</key>
|
||||
<value>{python} -u {filename}</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>run_options</key>
|
||||
<value>prompt</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>run</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>thread_safe_setters</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>title</key>
|
||||
<value></value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>variable</key>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(8, 160)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>samp_rate</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>32000</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>satnogs_morse_debug_source</key>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>affinity</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(240, 196)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>satnogs_morse_debug_source_0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>maxoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>minoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>debug_seq</key>
|
||||
<value>"HELLO WORLD"</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>satnogs_morse_decoder</key>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>affinity</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(752, 276)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>satnogs_morse_decoder_0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>unrecognized_char</key>
|
||||
<value>ord('#')</value>
|
||||
</param>
|
||||
</block>
|
||||
<connection>
|
||||
<source_block_id>satnogs_morse_debug_source_0</source_block_id>
|
||||
<sink_block_id>satnogs_morse_decoder_0</sink_block_id>
|
||||
<source_key>out</source_key>
|
||||
<sink_key>in</sink_key>
|
||||
</connection>
|
||||
</flow_graph>
|
|
@ -18,5 +18,6 @@
|
|||
# Boston, MA 02110-1301, USA.
|
||||
install(FILES
|
||||
satnogs_cw_matched_filter_ff.xml
|
||||
satnogs_morse_decoder.xml DESTINATION share/gnuradio/grc/blocks
|
||||
satnogs_morse_decoder.xml
|
||||
satnogs_morse_debug_source.xml DESTINATION share/gnuradio/grc/blocks
|
||||
)
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0"?>
|
||||
<block>
|
||||
<name>Morse code Debug Source</name>
|
||||
<key>satnogs_morse_debug_source</key>
|
||||
<category>satnogs</category>
|
||||
<import>import satnogs</import>
|
||||
<make>satnogs.morse_debug_source($debug_seq)</make>
|
||||
<!-- Make one 'param' node for every Parameter you want settable from the GUI.
|
||||
Sub-nodes:
|
||||
* name
|
||||
* key (makes the value accessible as $keyname, e.g. in the make node)
|
||||
* type -->
|
||||
<param>
|
||||
<name>Sentence</name>
|
||||
<key>debug_seq</key>
|
||||
<value>"HELLO WORLD"</value>
|
||||
<type>string</type>
|
||||
</param>
|
||||
|
||||
<source>
|
||||
<name>out</name>
|
||||
<type>message</type>
|
||||
</source>
|
||||
</block>
|
|
@ -27,5 +27,6 @@ install(FILES
|
|||
log.h
|
||||
morse_tree.h
|
||||
morse.h
|
||||
morse_decoder.h DESTINATION include/satnogs
|
||||
morse_decoder.h
|
||||
morse_debug_source.h DESTINATION include/satnogs
|
||||
)
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- 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_MORSE_DEBUG_SOURCE_H
|
||||
#define INCLUDED_SATNOGS_MORSE_DEBUG_SOURCE_H
|
||||
|
||||
#include <satnogs/api.h>
|
||||
#include <gnuradio/block.h>
|
||||
|
||||
namespace gr {
|
||||
namespace satnogs {
|
||||
|
||||
/*!
|
||||
* \brief A Morse debug source block
|
||||
* \ingroup satnogs
|
||||
*
|
||||
*/
|
||||
class SATNOGS_API morse_debug_source : virtual public gr::block
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<morse_debug_source> sptr;
|
||||
|
||||
/*!
|
||||
* \brief A Morse debug source block that produces messages corresponding
|
||||
* to Morse symbols, based on the given debug_seq string.
|
||||
*
|
||||
* @param debug_seq A string containing the debug sentence
|
||||
*/
|
||||
static sptr make(const std::string& debug_seq);
|
||||
};
|
||||
|
||||
} // namespace satnogs
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_SATNOGS_MORSE_DEBUG_SOURCE_H */
|
||||
|
|
@ -34,7 +34,7 @@ namespace gr
|
|||
/*!
|
||||
* \brief Binary tree node containing the corresponding character
|
||||
*/
|
||||
class tree_node
|
||||
class SATNOGS_API tree_node
|
||||
{
|
||||
private:
|
||||
const char d_char;
|
||||
|
|
|
@ -27,7 +27,8 @@ link_directories(${Boost_LIBRARY_DIRS})
|
|||
list(APPEND satnogs_sources
|
||||
cw_matched_filter_ff_impl.cc
|
||||
morse_tree.cc
|
||||
morse_decoder_impl.cc )
|
||||
morse_decoder_impl.cc
|
||||
morse_debug_source_impl.cc )
|
||||
|
||||
set(satnogs_sources "${satnogs_sources}" PARENT_SCOPE)
|
||||
if(NOT satnogs_sources)
|
||||
|
@ -36,7 +37,11 @@ if(NOT satnogs_sources)
|
|||
endif(NOT satnogs_sources)
|
||||
|
||||
add_library(gnuradio-satnogs SHARED ${satnogs_sources})
|
||||
target_link_libraries(gnuradio-satnogs ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES})
|
||||
target_link_libraries(gnuradio-satnogs
|
||||
${Boost_LIBRARIES}
|
||||
${GNURADIO_ALL_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
set_target_properties(gnuradio-satnogs PROPERTIES DEFINE_SYMBOL "gnuradio_satnogs_EXPORTS")
|
||||
|
||||
if(APPLE)
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
/* -*- 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/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include "morse_debug_source_impl.h"
|
||||
#include <satnogs/morse.h>
|
||||
|
||||
namespace gr {
|
||||
namespace satnogs {
|
||||
|
||||
morse_debug_source::sptr
|
||||
morse_debug_source::make(const std::string& debug_seq)
|
||||
{
|
||||
return gnuradio::get_initial_sptr
|
||||
(new morse_debug_source_impl(debug_seq));
|
||||
}
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
morse_debug_source_impl::morse_debug_source_impl(std::string debug_seq)
|
||||
: gr::block("morse_debug_source",
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(0, 0, 0)),
|
||||
d_run(true),
|
||||
d_chars { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
|
||||
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
|
||||
'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', '0' },
|
||||
d_symbols { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.",
|
||||
"....", "..", ".---", "-.-", ".-..", "--", "-.",
|
||||
"---", ".--.", "--.-", ".-.", "...", "-", "..-",
|
||||
"...-", ".--", "-..-", "-.--", "--..", ".----",
|
||||
"..---", "...--", "....-", ".....", "-....", "--...",
|
||||
"---..", "----.", "-----"}
|
||||
{
|
||||
message_port_register_out(pmt::mp("out"));
|
||||
d_thread = std::thread(&morse_debug_source_impl::send_debug_msg,
|
||||
this,
|
||||
debug_seq);
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
find_char_idx(const char* characters, size_t len, char c)
|
||||
{
|
||||
size_t i;
|
||||
for(i = 0; i < len; i++) {
|
||||
if(characters[i] == c){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
void
|
||||
morse_debug_source_impl::send_debug_msg (std::string sentence)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
size_t idx;
|
||||
std::string s;
|
||||
char c;
|
||||
size_t len = sentence.length();
|
||||
pmt::pmt_t port = pmt::mp("out");
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
while(d_run) {
|
||||
/* Not the best approach, but hey, this is only for debug */
|
||||
for(i = 0; i < len; i++){
|
||||
c = std::toupper(sentence[i]);
|
||||
if(c == ' '){
|
||||
message_port_pub(port, pmt::from_long(MORSE_L_SPACE));
|
||||
}
|
||||
|
||||
idx = find_char_idx(d_chars, sizeof(d_chars), c);
|
||||
if(idx != sizeof(d_chars)){
|
||||
s = d_symbols[idx];
|
||||
for(j = 0; j < s.length(); j++) {
|
||||
if(s[j] == '.'){
|
||||
message_port_pub(port, pmt::from_long(MORSE_DOT));
|
||||
}
|
||||
else{
|
||||
message_port_pub(port, pmt::from_long(MORSE_DASH));
|
||||
}
|
||||
/* Send also a character delimiter after waiting a little */
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(400));
|
||||
message_port_pub(port, pmt::from_long(MORSE_S_SPACE));
|
||||
}
|
||||
}
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Our virtual destructor.
|
||||
*/
|
||||
morse_debug_source_impl::~morse_debug_source_impl()
|
||||
{
|
||||
d_run = false;
|
||||
d_thread.join();
|
||||
}
|
||||
|
||||
} /* namespace satnogs */
|
||||
} /* namespace gr */
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- 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_MORSE_DEBUG_SOURCE_IMPL_H
|
||||
#define INCLUDED_SATNOGS_MORSE_DEBUG_SOURCE_IMPL_H
|
||||
|
||||
#include <satnogs/morse_debug_source.h>
|
||||
#include <thread>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace gr {
|
||||
namespace satnogs {
|
||||
|
||||
class morse_debug_source_impl : public morse_debug_source
|
||||
{
|
||||
private:
|
||||
bool d_run;
|
||||
const char d_chars[36];
|
||||
const std::vector<std::string> d_symbols;
|
||||
std::thread d_thread;
|
||||
|
||||
void
|
||||
send_debug_msg(std::string sentence);
|
||||
|
||||
public:
|
||||
morse_debug_source_impl(std::string debug_seq);
|
||||
~morse_debug_source_impl();
|
||||
};
|
||||
|
||||
} // namespace satnogs
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_SATNOGS_MORSE_DEBUG_SOURCE_IMPL_H */
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include "morse_decoder_impl.h"
|
||||
|
||||
#include <satnogs/log.h>
|
||||
namespace gr
|
||||
{
|
||||
namespace satnogs
|
||||
|
@ -43,7 +43,22 @@ namespace gr
|
|||
morse_symbol_t s;
|
||||
s = (morse_symbol_t) pmt::to_long (msg);
|
||||
|
||||
//TODO Continue the logic based on s
|
||||
switch(s) {
|
||||
case MORSE_DOT:
|
||||
LOG_DEBUG("Dot received");
|
||||
break;
|
||||
case MORSE_DASH:
|
||||
LOG_DEBUG("Dash received");
|
||||
break;
|
||||
case MORSE_S_SPACE:
|
||||
LOG_DEBUG("Short space received");
|
||||
break;
|
||||
case MORSE_L_SPACE:
|
||||
LOG_DEBUG("Long space received");
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("Unknown Morse symbol");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "satnogs/cw_matched_filter_ff.h"
|
||||
#include "satnogs/morse_tree.h"
|
||||
#include "satnogs/morse_decoder.h"
|
||||
#include "satnogs/morse_debug_source.h"
|
||||
%}
|
||||
|
||||
%include "satnogs/cw_matched_filter_ff.h"
|
||||
|
@ -18,3 +19,5 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, cw_matched_filter_ff);
|
|||
%include "satnogs/morse_tree.h"
|
||||
%include "satnogs/morse_decoder.h"
|
||||
GR_SWIG_BLOCK_MAGIC2(satnogs, morse_decoder);
|
||||
%include "satnogs/morse_debug_source.h"
|
||||
GR_SWIG_BLOCK_MAGIC2(satnogs, morse_debug_source);
|
||||
|
|
Loading…
Reference in New Issue