blob: 5a9e6db4497654de855b64983e2f21a515628254 [file] [log] [blame]
piotrab663c82014-08-06 14:14:15 +02001/* -*- c++ -*- */
2/*
3 * Copyright 2014 <+YOU OR YOUR COMPANY+>.
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifdef HAVE_CONFIG_H
22#include "config.h"
23#endif
24
25#include <gnuradio/io_signature.h>
26#include "message_printer_impl.h"
ptrkrysik7f61c642014-10-30 08:57:27 +010027#include "gsm/gsmtap.h"
piotrab663c82014-08-06 14:14:15 +020028
29namespace gr {
30 namespace gsm {
31
32 void message_printer_impl::message_print(pmt::pmt_t msg)
33 {
ptrkrysik617ba032014-11-21 10:11:05 +010034 pmt::pmt_t message_plus_header_blob = pmt::cdr(msg);
35 uint8_t * message_plus_header = (uint8_t *)pmt::blob_data(message_plus_header_blob);
36 size_t message_plus_header_len=pmt::blob_length(message_plus_header_blob);
ptrkrysik7f61c642014-10-30 08:57:27 +010037
ptrkrysik617ba032014-11-21 10:11:05 +010038 gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header;
39
40 for(int ii=sizeof(gsmtap_hdr); ii<message_plus_header_len; ii++)
piotrab663c82014-08-06 14:14:15 +020041 {
ptrkrysik617ba032014-11-21 10:11:05 +010042 printf(" %02x", message_plus_header[ii]);
piotrab663c82014-08-06 14:14:15 +020043 }
44 std::cout << std::endl;
45 }
46
47 message_printer::sptr
48 message_printer::make()
49 {
50 return gnuradio::get_initial_sptr
51 (new message_printer_impl());
52 }
53
54 /*
55 * The private constructor
56 */
57 message_printer_impl::message_printer_impl()
58 : gr::block("message_printer",
59 gr::io_signature::make(0, 0, 0),
60 gr::io_signature::make(0, 0, 0))
61 {
62 message_port_register_in(pmt::mp("msgs"));
63 set_msg_handler(pmt::mp("msgs"), boost::bind(&message_printer_impl::message_print, this, _1));
64
65 }
66
67 /*
68 * Our virtual destructor.
69 */
70 message_printer_impl::~message_printer_impl()
71 {
72 }
73 } /* namespace gsm */
74} /* namespace gr */
75