piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 1 | /* -*- c++ -*- */ |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 2 | /* |
| 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 |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 8 | * 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. |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 11 | * |
| 12 | * Gr-gsm is distributed in the hope that it will be useful, |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 13 | * 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. |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 16 | * |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 17 | * You should have received a copy of the GNU General Public License |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 18 | * along with gr-gsm; see the file COPYING. If not, write to |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 19 | * 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> |
piotr | faacc72 | 2014-07-20 23:48:32 +0200 | [diff] [blame] | 28 | #include <gsm/gsmtap.h> |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 29 | #include <iterator> |
| 30 | #include <algorithm> |
piotr | faacc72 | 2014-07-20 23:48:32 +0200 | [diff] [blame] | 31 | #include "bursts_printer_impl.h" |
piotr | c00ce9c | 2014-08-04 11:21:24 +0200 | [diff] [blame] | 32 | #include <unistd.h> |
| 33 | |
| 34 | #include <iostream> |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 35 | |
| 36 | namespace gr { |
| 37 | namespace gsm { |
piotr | c00ce9c | 2014-08-04 11:21:24 +0200 | [diff] [blame] | 38 | boost::mutex printer_mutex; |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 39 | void bursts_printer_impl::bursts_print(pmt::pmt_t msg) |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 40 | { |
ptrkrysik | 617ba03 | 2014-11-21 10:11:05 +0100 | [diff] [blame] | 41 | pmt::pmt_t header_plus_burst = pmt::cdr(msg); |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 42 | |
ptrkrysik | 617ba03 | 2014-11-21 10:11:05 +0100 | [diff] [blame] | 43 | gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst); |
| 44 | int8_t * burst = (int8_t *)(pmt::blob_data(header_plus_burst))+sizeof(gsmtap_hdr); |
| 45 | size_t burst_len=pmt::blob_length(header_plus_burst)-sizeof(gsmtap_hdr); |
| 46 | |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 47 | for(int ii=0; ii<burst_len; ii++) |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 48 | { |
ptrkrysik | 617ba03 | 2014-11-21 10:11:05 +0100 | [diff] [blame] | 49 | std::cout << std::setprecision(1) << static_cast<int>(burst[ii]) << ""; |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 50 | } |
| 51 | std::cout << std::endl; |
| 52 | } |
piotr | c00ce9c | 2014-08-04 11:21:24 +0200 | [diff] [blame] | 53 | |
piotr | 6c69287 | 2014-02-08 14:16:26 +0100 | [diff] [blame] | 54 | bursts_printer::sptr |
| 55 | bursts_printer::make() |
| 56 | { |
| 57 | return gnuradio::get_initial_sptr |
| 58 | (new bursts_printer_impl()); |
| 59 | } |
| 60 | |
| 61 | /* |
| 62 | * The private constructor |
| 63 | */ |
| 64 | bursts_printer_impl::bursts_printer_impl() |
| 65 | : gr::block("bursts_printer", |
| 66 | gr::io_signature::make(0, 0, 0), |
| 67 | gr::io_signature::make(0, 0, 0)) |
| 68 | { |
| 69 | message_port_register_in(pmt::mp("bursts")); |
| 70 | set_msg_handler(pmt::mp("bursts"), boost::bind(&bursts_printer_impl::bursts_print, this, _1)); |
| 71 | } |
| 72 | |
| 73 | /* |
| 74 | * Our virtual destructor. |
| 75 | */ |
| 76 | bursts_printer_impl::~bursts_printer_impl() |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | |
| 81 | } /* namespace gsm */ |
| 82 | } /* namespace gr */ |
| 83 | |