blob: 48cd95be42040e9e4d241ba6951eb229974d4560 [file] [log] [blame]
piotrab663c82014-08-06 14:14:15 +02001/* -*- c++ -*- */
ptrkrysik529895b2014-12-02 18:07:38 +01002/*
3 * @file
4 * @author Piotr Krysik <ptrkrysik@gmail.com>
5 * @section LICENSE
6 *
7 * Gr-gsm is free software; you can redistribute it and/or modify
piotrab663c82014-08-06 14:14:15 +02008 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
ptrkrysik529895b2014-12-02 18:07:38 +010011 *
12 * Gr-gsm is distributed in the hope that it will be useful,
piotrab663c82014-08-06 14:14:15 +020013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
ptrkrysik529895b2014-12-02 18:07:38 +010016 *
piotrab663c82014-08-06 14:14:15 +020017 * You should have received a copy of the GNU General Public License
ptrkrysik529895b2014-12-02 18:07:38 +010018 * along with gr-gsm; see the file COPYING. If not, write to
piotrab663c82014-08-06 14:14:15 +020019 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <gnuradio/io_signature.h>
ptrkrysik402c1fa2014-12-03 22:09:29 +010028#include <stdio.h>
piotrab663c82014-08-06 14:14:15 +020029#include "message_printer_impl.h"
ptrkrysik3be74a72014-12-13 10:11:00 +010030#include "grgsm/gsmtap.h"
piotrab663c82014-08-06 14:14:15 +020031
32namespace gr {
33 namespace gsm {
34
35 void message_printer_impl::message_print(pmt::pmt_t msg)
36 {
ptrkrysik617ba032014-11-21 10:11:05 +010037 pmt::pmt_t message_plus_header_blob = pmt::cdr(msg);
38 uint8_t * message_plus_header = (uint8_t *)pmt::blob_data(message_plus_header_blob);
39 size_t message_plus_header_len=pmt::blob_length(message_plus_header_blob);
ptrkrysik7f61c642014-10-30 08:57:27 +010040
ptrkrysik617ba032014-11-21 10:11:05 +010041 gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header;
42
43 for(int ii=sizeof(gsmtap_hdr); ii<message_plus_header_len; ii++)
piotrab663c82014-08-06 14:14:15 +020044 {
ptrkrysik617ba032014-11-21 10:11:05 +010045 printf(" %02x", message_plus_header[ii]);
piotrab663c82014-08-06 14:14:15 +020046 }
47 std::cout << std::endl;
48 }
49
50 message_printer::sptr
51 message_printer::make()
52 {
53 return gnuradio::get_initial_sptr
54 (new message_printer_impl());
55 }
56
57 /*
58 * The private constructor
59 */
60 message_printer_impl::message_printer_impl()
61 : gr::block("message_printer",
62 gr::io_signature::make(0, 0, 0),
63 gr::io_signature::make(0, 0, 0))
64 {
65 message_port_register_in(pmt::mp("msgs"));
66 set_msg_handler(pmt::mp("msgs"), boost::bind(&message_printer_impl::message_print, this, _1));
67
68 }
69
70 /*
71 * Our virtual destructor.
72 */
73 message_printer_impl::~message_printer_impl()
74 {
75 }
76 } /* namespace gsm */
77} /* namespace gr */
78