2016-01-24 20:43:17 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gnuradio/io_signature.h>
|
2016-05-13 14:57:33 +02:00
|
|
|
#include "multi_format_msg_sink_impl.h"
|
2016-01-24 20:43:17 +01:00
|
|
|
|
|
|
|
namespace gr {
|
|
|
|
namespace satnogs {
|
|
|
|
|
2016-05-13 14:57:33 +02:00
|
|
|
multi_format_msg_sink::sptr
|
|
|
|
multi_format_msg_sink::make(size_t format)
|
2016-01-24 20:43:17 +01:00
|
|
|
{
|
|
|
|
return gnuradio::get_initial_sptr
|
2016-05-13 14:57:33 +02:00
|
|
|
(new multi_format_msg_sink_impl(format));
|
2016-01-24 20:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-13 14:57:33 +02:00
|
|
|
multi_format_msg_sink_impl::msg_handler (pmt::pmt_t msg)
|
2016-01-24 20:43:17 +01:00
|
|
|
{
|
2016-05-14 23:07:23 +02:00
|
|
|
uint8_t *su;
|
2016-01-24 20:43:17 +01:00
|
|
|
std::string s((const char *)pmt::blob_data(msg), pmt::blob_length(msg));
|
2016-05-13 14:57:33 +02:00
|
|
|
switch(d_format){
|
|
|
|
case 0:
|
|
|
|
std::cout << "Received text sequence:" << s << " " << std::endl;
|
|
|
|
break;
|
|
|
|
case 1:
|
2016-05-14 23:07:23 +02:00
|
|
|
su = (uint8_t *)pmt::blob_data(msg);
|
|
|
|
for (size_t i = 0; i < pmt::blob_length (msg); i++) {
|
|
|
|
printf ("0x%02x ", su[i]);
|
|
|
|
}
|
|
|
|
std::cout << std::endl;
|
2016-05-13 14:57:33 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-05-14 23:07:23 +02:00
|
|
|
su = (uint8_t *)pmt::blob_data(msg);
|
|
|
|
for (size_t i = 0; i < pmt::blob_length (msg); i++) {
|
|
|
|
std::cout << "0b" << std::bitset<8> (su[i]) << " ";
|
|
|
|
}
|
|
|
|
std::cout << std::endl;
|
2016-05-13 14:57:33 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Invalid format");
|
|
|
|
}
|
2016-01-24 20:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The private constructor
|
|
|
|
*/
|
2016-05-13 14:57:33 +02:00
|
|
|
multi_format_msg_sink_impl::multi_format_msg_sink_impl(size_t format)
|
|
|
|
: gr::block("multi_format_msg_sink",
|
2016-01-24 20:43:17 +01:00
|
|
|
gr::io_signature::make(0, 0, 0),
|
2016-05-13 14:57:33 +02:00
|
|
|
gr::io_signature::make(0, 0, 0)),
|
|
|
|
d_format(format)
|
2016-01-24 20:43:17 +01:00
|
|
|
{
|
|
|
|
message_port_register_in(pmt::mp("in"));
|
|
|
|
set_msg_handler (
|
|
|
|
pmt::mp ("in"),
|
2016-05-13 14:57:33 +02:00
|
|
|
boost::bind (&multi_format_msg_sink_impl::msg_handler, this, _1));
|
2016-01-24 20:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace satnogs */
|
|
|
|
} /* namespace gr */
|
|
|
|
|