Commit 12a2aa00 authored by Nikos Karamolegkos's avatar Nikos Karamolegkos

Add minimum frame length on the morse decoder

parent de05c3f1
Pipeline #16987219 passed with stage
in 9 minutes and 25 seconds
<?xml version='1.0' encoding='utf-8'?>
<?grc format='1' created='3.7.10'?>
<?grc format='1' created='3.7.11'?>
<flow_graph>
<timestamp>Fri Jan 22 20:01:21 2016</timestamp>
<block>
......@@ -131,6 +131,14 @@
<key>debug_seq</key>
<value>"SATNOGS HELLO EARTH WORLD 123456789"</value>
</param>
<param>
<key>seq_pause_ms</key>
<value>1000</value>
</param>
<param>
<key>wpm</key>
<value>20</value>
</param>
</block>
<block>
<key>satnogs_morse_decoder</key>
......@@ -170,6 +178,10 @@
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>min_frame_len</key>
<value>3</value>
</param>
<param>
<key>unrecognized_char</key>
<value>ord('#')</value>
......
......@@ -3,7 +3,7 @@
<name>Morse Decoder</name>
<key>satnogs_morse_decoder</key>
<import>import satnogs</import>
<make>satnogs.morse_decoder($unrecognized_char)</make>
<make>satnogs.morse_decoder($unrecognized_char, $min_frame_len)</make>
<param>
<name>Unrecognized character</name>
......@@ -11,6 +11,13 @@
<value>ord('#')</value>
<type>int</type>
</param>
<param>
<name>Minimum frame length</name>
<key>min_frame_len</key>
<value>3</value>
<type>int</type>
</param>
<sink>
......
......@@ -42,8 +42,10 @@ namespace gr {
* @param unrecognized_char the character that will be placed
* in situations where the decoder can not decide which character
* was received.
* @param min_frame_len the minimum frame length in order to reduce
* false alarms
*/
static sptr make(char unrecognized_char = '#');
static sptr make(char unrecognized_char = '#', size_t min_frame_len = 3);
};
} // namespace satnogs
......
......@@ -32,10 +32,10 @@ namespace gr
{
morse_decoder::sptr
morse_decoder::make (char unrecognized_char)
morse_decoder::make (char unrecognized_char, size_t min_frame_len)
{
return gnuradio::get_initial_sptr (
new morse_decoder_impl (unrecognized_char));
new morse_decoder_impl (unrecognized_char, min_frame_len));
}
void
......@@ -69,9 +69,11 @@ namespace gr
break;
}
str = d_morse_tree.get_word ();
d_morse_tree.reset ();
message_port_pub (pmt::mp ("out"),
pmt::make_blob (str.c_str (), str.length ()));
if (str.length () > d_min_frame_len) {
d_morse_tree.reset ();
message_port_pub (pmt::mp ("out"),
pmt::make_blob (str.c_str (), str.length ()));
}
break;
case MORSE_INTRA_SPACE:
/*Ignore it */
......@@ -98,10 +100,13 @@ namespace gr
/*
* The private constructor
*/
morse_decoder_impl::morse_decoder_impl (char unrecognized_char) :
morse_decoder_impl::morse_decoder_impl (char unrecognized_char,
size_t min_frame_len) :
gr::block ("morse_decoder", gr::io_signature::make (0, 0, 0),
gr::io_signature::make (0, 0, 0)),
d_morse_tree (unrecognized_char)
d_morse_tree (unrecognized_char),
d_min_frame_len (min_frame_len)
{
/* Register the input and output msg handler */
message_port_register_in (pmt::mp ("in"));
......
......@@ -31,12 +31,13 @@ namespace gr {
{
private:
morse_tree d_morse_tree;
size_t d_min_frame_len;
void
symbol_msg_handler(pmt::pmt_t msg);
public:
morse_decoder_impl(char unrecognized_char);
morse_decoder_impl(char unrecognized_char, size_t min_frame_len);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment