Added hex and binary output sink

This commit is contained in:
George Vardakis 2016-05-13 15:57:33 +03:00
parent b7ebcd5db5
commit 455e19e466
9 changed files with 79 additions and 41 deletions

View File

@ -20,7 +20,7 @@ install(FILES
satnogs_cw_matched_filter_ff.xml satnogs_cw_matched_filter_ff.xml
satnogs_morse_decoder.xml satnogs_morse_decoder.xml
satnogs_morse_debug_source.xml satnogs_morse_debug_source.xml
satnogs_clear_text_msg_sink.xml satnogs_multi_format_msg_sink.xml
satnogs_cw_to_symbol.xml satnogs_cw_to_symbol.xml
satnogs_afsk_decoder.xml satnogs_afsk_decoder.xml
satnogs_sine_matched_filter_ff.xml satnogs_sine_matched_filter_ff.xml

View File

@ -1,13 +0,0 @@
<?xml version="1.0"?>
<block>
<name>Clear Text Message Sink</name>
<key>satnogs_clear_text_msg_sink</key>
<category>satnogs</category>
<import>import satnogs</import>
<make>satnogs.clear_text_msg_sink()</make>
<sink>
<name>in</name>
<type>message</type>
</sink>
</block>

View File

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<block>
<name>Multi Format Message Sink</name>
<key>satnogs_multi_format_msg_sink</key>
<category>satnogs</category>
<import>import satnogs</import>
<make>satnogs.multi_format_msg_sink($format)</make>
<param>
<name>Output format</name>
<key>format</key>
<type>enum</type>
<option>
<name>Clear Text</name>
<key>0</key>
</option>
<option>
<name>Hex</name>
<key>1</key>
</option>
<option>
<name>Binary</name>
<key>2</key>
</option>
</param>
<sink>
<name>in</name>
<type>message</type>
</sink>
</block>

View File

@ -30,7 +30,7 @@ install(FILES
morse.h morse.h
morse_decoder.h morse_decoder.h
morse_debug_source.h morse_debug_source.h
clear_text_msg_sink.h multi_format_msg_sink.h
cw_to_symbol.h cw_to_symbol.h
afsk_decoder.h afsk_decoder.h
sine_matched_filter_ff.h sine_matched_filter_ff.h

View File

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_H #ifndef INCLUDED_SATNOGS_MULTI_FORMAT_MSG_SINK_H
#define INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_H #define INCLUDED_SATNOGS_MULTI_FORMAT_MSG_SINK_H
#include <satnogs/api.h> #include <satnogs/api.h>
#include <gnuradio/block.h> #include <gnuradio/block.h>
@ -37,10 +37,10 @@ namespace gr
* \ingroup satnogs * \ingroup satnogs
* *
*/ */
class SATNOGS_API clear_text_msg_sink : virtual public gr::block class SATNOGS_API multi_format_msg_sink : virtual public gr::block
{ {
public: public:
typedef boost::shared_ptr<clear_text_msg_sink> sptr; typedef boost::shared_ptr<multi_format_msg_sink> sptr;
/*! /*!
* \brief Block accepting clear text messages from various decoders. * \brief Block accepting clear text messages from various decoders.
@ -49,11 +49,11 @@ namespace gr
* *
*/ */
static sptr static sptr
make (); make (size_t format);
}; };
} // namespace satnogs } // namespace satnogs
} // namespace gr } // namespace gr
#endif /* INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_H */ #endif /* INCLUDED_SATNOGS_multi_format_MSG_SINK_H */

View File

@ -29,7 +29,7 @@ list(APPEND satnogs_sources
morse_tree.cc morse_tree.cc
morse_decoder_impl.cc morse_decoder_impl.cc
morse_debug_source_impl.cc morse_debug_source_impl.cc
clear_text_msg_sink_impl.cc multi_format_msg_sink_impl.cc
cw_to_symbol_impl.cc cw_to_symbol_impl.cc
afsk_decoder_impl.cc afsk_decoder_impl.cc
sine_matched_filter_ff_impl.cc sine_matched_filter_ff_impl.cc

View File

@ -23,37 +23,55 @@
#endif #endif
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include "clear_text_msg_sink_impl.h" #include "multi_format_msg_sink_impl.h"
namespace gr { namespace gr {
namespace satnogs { namespace satnogs {
clear_text_msg_sink::sptr multi_format_msg_sink::sptr
clear_text_msg_sink::make() multi_format_msg_sink::make(size_t format)
{ {
return gnuradio::get_initial_sptr return gnuradio::get_initial_sptr
(new clear_text_msg_sink_impl()); (new multi_format_msg_sink_impl(format));
} }
void void
clear_text_msg_sink_impl::msg_handler (pmt::pmt_t msg) multi_format_msg_sink_impl::msg_handler (pmt::pmt_t msg)
{ {
std::string s((const char *)pmt::blob_data(msg), pmt::blob_length(msg)); std::string s((const char *)pmt::blob_data(msg), pmt::blob_length(msg));
std::cout << "Received text sequence:" << s << " " << std::endl; switch(d_format){
case 0:
std::cout << "Received text sequence:" << s << " " << std::endl;
break;
case 1:
//for(size_t i=0; i< pmt::blob_length(msg); i++)
for (size_t i = 0; i < s.length(); ++i)
std::cout << std::hex << std::setfill('0') << std::setw(2) <<(int)s[i];
std::cout<<std::endl;
break;
case 2:
for(size_t i=0; i< pmt::blob_length(msg); i++)
std::cout<< std::bitset<8>(((uint8_t*)pmt::blob_data(msg))[i]);
std::cout<<std::endl;
break;
default:
printf("Invalid format");
}
} }
/* /*
* The private constructor * The private constructor
*/ */
clear_text_msg_sink_impl::clear_text_msg_sink_impl() multi_format_msg_sink_impl::multi_format_msg_sink_impl(size_t format)
: gr::block("clear_text_msg_sink", : gr::block("multi_format_msg_sink",
gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0)) gr::io_signature::make(0, 0, 0)),
d_format(format)
{ {
message_port_register_in(pmt::mp("in")); message_port_register_in(pmt::mp("in"));
set_msg_handler ( set_msg_handler (
pmt::mp ("in"), pmt::mp ("in"),
boost::bind (&clear_text_msg_sink_impl::msg_handler, this, _1)); boost::bind (&multi_format_msg_sink_impl::msg_handler, this, _1));
} }
} /* namespace satnogs */ } /* namespace satnogs */

View File

@ -18,29 +18,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_IMPL_H #ifndef INCLUDED_SATNOGS_MULTI_FORMAT_MSG_SINK_IMPL_H
#define INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_IMPL_H #define INCLUDED_SATNOGS_MULTI_FORMAT_MSG_SINK_IMPL_H
#include <satnogs/clear_text_msg_sink.h> #include <satnogs/multi_format_msg_sink.h>
namespace gr namespace gr
{ {
namespace satnogs namespace satnogs
{ {
class clear_text_msg_sink_impl : public clear_text_msg_sink class multi_format_msg_sink_impl : public multi_format_msg_sink
{ {
private: private:
void void
msg_handler(pmt::pmt_t msg); msg_handler(pmt::pmt_t msg);
size_t d_format;
public: public:
clear_text_msg_sink_impl (); multi_format_msg_sink_impl (size_t format);
}; };
} // namespace satnogs } // namespace satnogs
} // namespace gr } // namespace gr
#endif /* INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_IMPL_H */ #endif /* INCLUDED_SATNOGS_multi_format_MSG_SINK_IMPL_H */

View File

@ -13,7 +13,7 @@
#include "satnogs/morse_tree.h" #include "satnogs/morse_tree.h"
#include "satnogs/morse_decoder.h" #include "satnogs/morse_decoder.h"
#include "satnogs/morse_debug_source.h" #include "satnogs/morse_debug_source.h"
#include "satnogs/clear_text_msg_sink.h" #include "satnogs/multi_format_msg_sink.h"
#include "satnogs/cw_to_symbol.h" #include "satnogs/cw_to_symbol.h"
#include "satnogs/afsk_decoder.h" #include "satnogs/afsk_decoder.h"
#include "satnogs/sine_matched_filter_ff.h" #include "satnogs/sine_matched_filter_ff.h"
@ -40,8 +40,8 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, cw_matched_filter_ff);
GR_SWIG_BLOCK_MAGIC2(satnogs, morse_decoder); GR_SWIG_BLOCK_MAGIC2(satnogs, morse_decoder);
%include "satnogs/morse_debug_source.h" %include "satnogs/morse_debug_source.h"
GR_SWIG_BLOCK_MAGIC2(satnogs, morse_debug_source); GR_SWIG_BLOCK_MAGIC2(satnogs, morse_debug_source);
%include "satnogs/clear_text_msg_sink.h" %include "satnogs/multi_format_msg_sink.h"
GR_SWIG_BLOCK_MAGIC2(satnogs, clear_text_msg_sink); GR_SWIG_BLOCK_MAGIC2(satnogs, multi_format_msg_sink);
%include "satnogs/cw_to_symbol.h" %include "satnogs/cw_to_symbol.h"
GR_SWIG_BLOCK_MAGIC2(satnogs, cw_to_symbol); GR_SWIG_BLOCK_MAGIC2(satnogs, cw_to_symbol);
%include "satnogs/afsk_decoder.h" %include "satnogs/afsk_decoder.h"