piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 1 | /* -*- 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> |
piotr | faacc72 | 2014-07-20 23:48:32 +0200 | [diff] [blame] | 26 | #include <gsm/gsmtap.h> |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 27 | #include <iterator> |
| 28 | #include <algorithm> |
piotr | faacc72 | 2014-07-20 23:48:32 +0200 | [diff] [blame] | 29 | #include "bursts_printer_impl.h" |
piotr | c00ce9c | 2014-08-04 11:21:24 +0200 | [diff] [blame] | 30 | #include <unistd.h> |
| 31 | |
| 32 | #include <iostream> |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 33 | |
| 34 | namespace gr { |
| 35 | namespace gsm { |
piotr | c00ce9c | 2014-08-04 11:21:24 +0200 | [diff] [blame] | 36 | boost::mutex printer_mutex; |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 37 | void bursts_printer_impl::bursts_print(pmt::pmt_t msg) |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 38 | { |
piotr | c00ce9c | 2014-08-04 11:21:24 +0200 | [diff] [blame] | 39 | boost::mutex::scoped_lock lock(printer_mutex); |
| 40 | |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 41 | pmt::pmt_t burst = pmt::cdr(msg); |
| 42 | int8_t * burst_elements = (int8_t *)pmt::blob_data(burst); |
| 43 | size_t burst_len=pmt::blob_length(burst); |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 44 | |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 45 | pmt::pmt_t header_blob = pmt::car(msg); |
| 46 | gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob); |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 47 | |
| 48 | for(int ii=0; ii<burst_len; ii++) |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 49 | { |
piotr | 7f3f366 | 2014-07-08 16:47:53 +0200 | [diff] [blame] | 50 | std::cout << std::setprecision(1) << static_cast<int>(burst_elements[ii]) << ""; |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 51 | } |
| 52 | std::cout << std::endl; |
| 53 | } |
piotr | c00ce9c | 2014-08-04 11:21:24 +0200 | [diff] [blame] | 54 | |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 55 | bursts_printer::sptr |
| 56 | bursts_printer::make() |
| 57 | { |
| 58 | return gnuradio::get_initial_sptr |
| 59 | (new bursts_printer_impl()); |
| 60 | } |
| 61 | |
| 62 | /* |
| 63 | * The private constructor |
| 64 | */ |
| 65 | bursts_printer_impl::bursts_printer_impl() |
| 66 | : gr::block("bursts_printer", |
| 67 | gr::io_signature::make(0, 0, 0), |
| 68 | gr::io_signature::make(0, 0, 0)) |
| 69 | { |
| 70 | message_port_register_in(pmt::mp("bursts")); |
| 71 | set_msg_handler(pmt::mp("bursts"), boost::bind(&bursts_printer_impl::bursts_print, this, _1)); |
| 72 | } |
| 73 | |
| 74 | /* |
| 75 | * Our virtual destructor. |
| 76 | */ |
| 77 | bursts_printer_impl::~bursts_printer_impl() |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | |
| 82 | } /* namespace gsm */ |
| 83 | } /* namespace gr */ |
| 84 | |