blob: e4281633f7ecd6e4e8960d7756d6fac16e52caca [file] [log] [blame]
piotr6c692872014-02-08 14:16:26 +01001/* -*- 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>
piotrfaacc722014-07-20 23:48:32 +020026#include <gsm/gsmtap.h>
piotr6d152d92014-02-21 00:02:44 +010027#include <iterator>
28#include <algorithm>
piotrfaacc722014-07-20 23:48:32 +020029#include "bursts_printer_impl.h"
piotrc00ce9c2014-08-04 11:21:24 +020030#include <unistd.h>
31
32#include <iostream>
piotr6c692872014-02-08 14:16:26 +010033
34namespace gr {
35 namespace gsm {
piotrc00ce9c2014-08-04 11:21:24 +020036 boost::mutex printer_mutex;
piotr6d152d92014-02-21 00:02:44 +010037 void bursts_printer_impl::bursts_print(pmt::pmt_t msg)
piotr6c692872014-02-08 14:16:26 +010038 {
ptrkrysik617ba032014-11-21 10:11:05 +010039 pmt::pmt_t header_plus_burst = pmt::cdr(msg);
piotr6c692872014-02-08 14:16:26 +010040
ptrkrysik617ba032014-11-21 10:11:05 +010041 gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst);
42 int8_t * burst = (int8_t *)(pmt::blob_data(header_plus_burst))+sizeof(gsmtap_hdr);
43 size_t burst_len=pmt::blob_length(header_plus_burst)-sizeof(gsmtap_hdr);
44
piotr6d152d92014-02-21 00:02:44 +010045 for(int ii=0; ii<burst_len; ii++)
piotr6c692872014-02-08 14:16:26 +010046 {
ptrkrysik617ba032014-11-21 10:11:05 +010047 std::cout << std::setprecision(1) << static_cast<int>(burst[ii]) << "";
piotr6c692872014-02-08 14:16:26 +010048 }
49 std::cout << std::endl;
50 }
piotrc00ce9c2014-08-04 11:21:24 +020051
piotr6c692872014-02-08 14:16:26 +010052 bursts_printer::sptr
53 bursts_printer::make()
54 {
55 return gnuradio::get_initial_sptr
56 (new bursts_printer_impl());
57 }
58
59 /*
60 * The private constructor
61 */
62 bursts_printer_impl::bursts_printer_impl()
63 : gr::block("bursts_printer",
64 gr::io_signature::make(0, 0, 0),
65 gr::io_signature::make(0, 0, 0))
66 {
67 message_port_register_in(pmt::mp("bursts"));
68 set_msg_handler(pmt::mp("bursts"), boost::bind(&bursts_printer_impl::bursts_print, this, _1));
69 }
70
71 /*
72 * Our virtual destructor.
73 */
74 bursts_printer_impl::~bursts_printer_impl()
75 {
76 }
77
78
79 } /* namespace gsm */
80} /* namespace gr */
81