From ab663c884480cc9030a5716d1389dc8b525afe82 Mon Sep 17 00:00:00 2001 From: piotr Date: Wed, 6 Aug 2014 14:14:15 +0200 Subject: Added new block for message printing, removed legacy code from the decoder and bursts printer --- lib/decoding/control_channels_decoder_impl.cc | 23 +++----- lib/misc_utils/bursts_printer_impl.cc | 2 - lib/misc_utils/message_printer_impl.cc | 75 +++++++++++++++++++++++++++ lib/misc_utils/message_printer_impl.h | 42 +++++++++++++++ 4 files changed, 123 insertions(+), 19 deletions(-) create mode 100644 lib/misc_utils/message_printer_impl.cc create mode 100644 lib/misc_utils/message_printer_impl.h (limited to 'lib') diff --git a/lib/decoding/control_channels_decoder_impl.cc b/lib/decoding/control_channels_decoder_impl.cc index 23ec7fd..e9d1146 100644 --- a/lib/decoding/control_channels_decoder_impl.cc +++ b/lib/decoding/control_channels_decoder_impl.cc @@ -73,8 +73,6 @@ namespace gr { d_bursts[d_collected_bursts_num] = msg; d_collected_bursts_num++; //get convecutive bursts -// pmt::pmt_t header_blob = pmt::car(msg); -// gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob); if(d_collected_bursts_num==4) { @@ -109,7 +107,7 @@ namespace gr { if (FC_check_crc(&fc_ctx, decoded_data, crc_result) == 0) { //("error: sacch: parity error (errors=%d fn=%d)\n", errors, ctx->fn); - std::cout << "Uncorrectable errors!" << std::endl; + //std::cout << "Uncorrectable errors!" << std::endl; errors = -1; } else { //DEBUGF("Successfully corrected parity bits! (errors=%d fn=%d)\n", errors, ctx->fn); @@ -125,25 +123,16 @@ namespace gr { unsigned char sbuf_len=224; int i, j, c, pos=0; for(i = 0; i < sbuf_len; i += 8) { - for(j = 0, c = 0; (j < 8) && (i + j < sbuf_len); j++){ - c |= (!!decoded_data[i + j]) << j; - } - outmsg[pos++] = c & 0xff; - } - - int jj=0; - while (jj < 23){ - printf(" %02x", outmsg[jj]);//decoded_data[jj]); - jj++; - } - printf("\n"); - fflush(stdout); + for(j = 0, c = 0; (j < 8) && (i + j < sbuf_len); j++){ + c |= (!!decoded_data[i + j]) << j; + } + outmsg[pos++] = c & 0xff; + } //send message with header of the first burst pmt::pmt_t header_blob = pmt::car(d_bursts[0]); pmt::pmt_t msg_binary_blob = pmt::make_blob(outmsg,23); pmt::pmt_t msg_out = pmt::cons(header_blob, msg_binary_blob); - message_port_pub(pmt::mp("msgs"), msg_out); } return; diff --git a/lib/misc_utils/bursts_printer_impl.cc b/lib/misc_utils/bursts_printer_impl.cc index deedf02..3e7d843 100644 --- a/lib/misc_utils/bursts_printer_impl.cc +++ b/lib/misc_utils/bursts_printer_impl.cc @@ -36,8 +36,6 @@ namespace gr { boost::mutex printer_mutex; void bursts_printer_impl::bursts_print(pmt::pmt_t msg) { - boost::mutex::scoped_lock lock(printer_mutex); - pmt::pmt_t burst = pmt::cdr(msg); int8_t * burst_elements = (int8_t *)pmt::blob_data(burst); size_t burst_len=pmt::blob_length(burst); diff --git a/lib/misc_utils/message_printer_impl.cc b/lib/misc_utils/message_printer_impl.cc new file mode 100644 index 0000000..36bd964 --- /dev/null +++ b/lib/misc_utils/message_printer_impl.cc @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "message_printer_impl.h" + +namespace gr { + namespace gsm { + + void message_printer_impl::message_print(pmt::pmt_t msg) + { + pmt::pmt_t message = pmt::cdr(msg); + uint8_t * message_elements = (uint8_t *)pmt::blob_data(message); + size_t message_len=pmt::blob_length(message); + +// pmt::pmt_t header_blob = pmt::car(msg); +// gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob); + + for(int ii=0; ii. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GSM_MESSAGE_PRINTER_IMPL_H +#define INCLUDED_GSM_MESSAGE_PRINTER_IMPL_H + +#include + +namespace gr { + namespace gsm { + + class message_printer_impl : public message_printer + { + private: + void message_print(pmt::pmt_t msg); + public: + message_printer_impl(); + ~message_printer_impl(); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_PRINTER_IMPL_H */ + -- cgit v1.2.3