From 2bf49e4dd58d1c0833bde8f6af3fe0d71b2b694b Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Sun, 26 Jul 2015 13:47:26 +0200 Subject: Added option to message printer that allows printing the gsmtap header. --- grc/misc_utils/gsm_message_printer.xml | 16 +++++++++++++++- include/grgsm/misc_utils/message_printer.h | 2 +- lib/misc_utils/message_printer_impl.cc | 18 +++++++++++++----- lib/misc_utils/message_printer_impl.h | 3 ++- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/grc/misc_utils/gsm_message_printer.xml b/grc/misc_utils/gsm_message_printer.xml index 8b44b22..7e390ed 100644 --- a/grc/misc_utils/gsm_message_printer.xml +++ b/grc/misc_utils/gsm_message_printer.xml @@ -4,7 +4,7 @@ gsm_message_printer import grgsm import pmt - grgsm.message_printer(pmt.intern($prepend_string)) + grgsm.message_printer(pmt.intern($prepend_string), $print_gsmtap_header) Prepend String @@ -13,6 +13,20 @@ string part + + Print GSMTap header + print_gsmtap_header + False + bool + + + msgs diff --git a/include/grgsm/misc_utils/message_printer.h b/include/grgsm/misc_utils/message_printer.h index 3914707..d40352f 100644 --- a/include/grgsm/misc_utils/message_printer.h +++ b/include/grgsm/misc_utils/message_printer.h @@ -48,7 +48,7 @@ namespace gr { * class. gsm::message_printer::make is the public interface for * creating new instances. */ - static sptr make(pmt::pmt_t prepend_string); + static sptr make(pmt::pmt_t prepend_string, bool print_gsmtap_header=false); }; } // namespace gsm diff --git a/lib/misc_utils/message_printer_impl.cc b/lib/misc_utils/message_printer_impl.cc index d02e2fe..2599f65 100644 --- a/lib/misc_utils/message_printer_impl.cc +++ b/lib/misc_utils/message_printer_impl.cc @@ -41,7 +41,15 @@ namespace gr { gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header; std::cout << d_prepend_string; - for(int ii=sizeof(gsmtap_hdr); ii Date: Mon, 27 Jul 2015 15:52:02 +0200 Subject: Implemented message source block for unit testing --- grc/CMakeLists.txt | 3 +- grc/gsm_block_tree.xml | 1 + grc/misc_utils/CMakeLists.txt | 3 +- grc/misc_utils/gsm_message_source.xml | 32 ++++++++ include/grgsm/misc_utils/CMakeLists.txt | 3 +- include/grgsm/misc_utils/message_source.h | 60 ++++++++++++++ lib/CMakeLists.txt | 3 +- lib/misc_utils/message_source_impl.cc | 131 ++++++++++++++++++++++++++++++ lib/misc_utils/message_source_impl.h | 51 ++++++++++++ swig/grgsm_swig.i | 3 + 10 files changed, 285 insertions(+), 5 deletions(-) create mode 100644 grc/misc_utils/gsm_message_source.xml create mode 100644 include/grgsm/misc_utils/message_source.h create mode 100644 lib/misc_utils/message_source_impl.cc create mode 100644 lib/misc_utils/message_source_impl.h diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index caf2660..d42bff8 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -23,6 +23,5 @@ add_subdirectory(demapping) add_subdirectory(receiver) add_subdirectory(misc_utils) install(FILES - gsm_block_tree.xml - DESTINATION share/gnuradio/grc/blocks + gsm_block_tree.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/gsm_block_tree.xml b/grc/gsm_block_tree.xml index 2503710..5837ce2 100644 --- a/grc/gsm_block_tree.xml +++ b/grc/gsm_block_tree.xml @@ -51,6 +51,7 @@ gsm_message_printer gsm_clock_offset_corrector gsm_tmsi_dumper + gsm_message_source diff --git a/grc/misc_utils/CMakeLists.txt b/grc/misc_utils/CMakeLists.txt index 5a3f874..403a321 100644 --- a/grc/misc_utils/CMakeLists.txt +++ b/grc/misc_utils/CMakeLists.txt @@ -29,5 +29,6 @@ install(FILES gsm_burst_sink.xml gsm_burst_source.xml gsm_burst_source_qa.xml - gsm_burst_sink_qa.xml DESTINATION share/gnuradio/grc/blocks + gsm_burst_sink_qa.xml + gsm_message_source.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/misc_utils/gsm_message_source.xml b/grc/misc_utils/gsm_message_source.xml new file mode 100644 index 0000000..ab06f65 --- /dev/null +++ b/grc/misc_utils/gsm_message_source.xml @@ -0,0 +1,32 @@ + + + Message Source + gsm_message_source + import grgsm + grgsm.message_source($messages) + + + Messages + messages + ["02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", +"02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", +"02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", +"02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b"] + raw + true + + + + msgs + message + + + +This block is a basic message source for testing purposes. + +It takes a list of strings as input, where each string +is a whitespace-separated list of hexadecimal values representing the data bytes of a message including the gsmtap header. + +Such strings can be obtained using the message printer with option "Print GSMTap header" + + diff --git a/include/grgsm/misc_utils/CMakeLists.txt b/include/grgsm/misc_utils/CMakeLists.txt index 8b74fc7..000b7ef 100644 --- a/include/grgsm/misc_utils/CMakeLists.txt +++ b/include/grgsm/misc_utils/CMakeLists.txt @@ -31,5 +31,6 @@ install(FILES controlled_rotator_cc.h controlled_const_source_f.h message_printer.h - tmsi_dumper.h DESTINATION include/grgsm/misc_utils + tmsi_dumper.h + message_source.h DESTINATION include/grgsm/misc_utils ) diff --git a/include/grgsm/misc_utils/message_source.h b/include/grgsm/misc_utils/message_source.h new file mode 100644 index 0000000..5c3e8a1 --- /dev/null +++ b/include/grgsm/misc_utils/message_source.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_SOURCE_H +#define INCLUDED_GSM_MESSAGE_SOURCE_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API message_source : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::message_source. + * + * To avoid accidental use of raw pointers, grgsm::message_source's + * constructor is in a private implementation + * class. grgsm::message_source::make is the public interface for + * creating new instances. + */ + static sptr make(const std::vector &msg_data); + + virtual void set_msg_data(const std::vector &msg_data) = 0; + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_SOURCE_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 61f0858..d66de3d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -54,7 +54,8 @@ list(APPEND grgsm_sources misc_utils/burst_source_impl.cc misc_utils/burst_sink_qa_impl.cc misc_utils/burst_source_qa_impl.cc - decryption/decryption_impl.cc ) + misc_utils/message_source_impl.cc + decryption/decryption_impl.cc) add_library(gnuradio-grgsm SHARED ${grgsm_sources}) target_link_libraries(gnuradio-grgsm ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES} ${LIBOSMOCORE_LIBRARIES} diff --git a/lib/misc_utils/message_source_impl.cc b/lib/misc_utils/message_source_impl.cc new file mode 100644 index 0000000..de24968 --- /dev/null +++ b/lib/misc_utils/message_source_impl.cc @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_source_impl.h" +#include "stdio.h" +#include +#include +#include + +#include +#include +#include + +#define MSG_BYTE_LEN 39 + + +namespace gr { + namespace gsm { + + message_source::sptr + message_source::make(const std::vector &msg_data) + { + return gnuradio::get_initial_sptr + (new message_source_impl(msg_data)); + } + + /* + * The private constructor + */ + message_source_impl::message_source_impl(const std::vector &msg_data) + : gr::block("message_source", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)), + d_finished(false) + { + message_port_register_out(pmt::mp("msgs")); + set_msg_data(msg_data); + } + + /* + * Our virtual destructor. + */ + message_source_impl::~message_source_impl() + { + if (d_finished == false){ + d_finished = true; + } + } + + void message_source_impl::set_msg_data(const std::vector &msg_data) + { + for (int i=0; i bytes; + unsigned int c; + + while (iss >> std::hex >> c) + { + if (c < 256) + { + bytes.push_back(c); + } + } + + if (bytes.size() == MSG_BYTE_LEN) + { + d_msgs.push_back(bytes); + } + } + } + + bool message_source_impl::start() + { + d_finished = false; + d_thread = boost::shared_ptr + (new gr::thread::thread(boost::bind(&message_source_impl::run, this))); + return block::start(); + } + + bool message_source_impl::stop() + { + d_finished = true; + d_thread->interrupt(); + d_thread->join(); + return block::stop(); + } + + bool message_source_impl::finished() + { + return d_finished; + } + + void message_source_impl::run() + { + for (int i=0; i current = d_msgs[i]; + pmt::pmt_t blob_header_plus_burst = pmt::make_blob(¤t[0], current.size()); + pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob_header_plus_burst); + message_port_pub(pmt::mp("msgs"), msg); + } + post(pmt::mp("system"), pmt::cons(pmt::mp("done"), pmt::from_long(1))); + } + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/misc_utils/message_source_impl.h b/lib/misc_utils/message_source_impl.h new file mode 100644 index 0000000..22a210e --- /dev/null +++ b/lib/misc_utils/message_source_impl.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_SOURCE_IMPL_H +#define INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H + +#include + +namespace gr { + namespace gsm { + + class message_source_impl : public message_source + { + private: + boost::shared_ptr d_thread; + std::vector > d_msgs; + bool d_finished; + void run(); + public: + message_source_impl(const std::vector &msg_data); + ~message_source_impl(); + virtual void set_msg_data(const std::vector &msg_data); + bool start(); + bool stop(); + bool finished(); + }; + + } // namespace grgsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H */ + diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i index 5dc1bcd..6189fee 100644 --- a/swig/grgsm_swig.i +++ b/swig/grgsm_swig.i @@ -27,6 +27,7 @@ #include "grgsm/misc_utils/burst_sink_qa.h" #include "grgsm/misc_utils/burst_source.h" #include "grgsm/misc_utils/burst_source_qa.h" +#include "grgsm/misc_utils/message_source.h" %} @@ -72,3 +73,5 @@ GR_SWIG_BLOCK_MAGIC2(gsm, controlled_const_source_f); GR_SWIG_BLOCK_MAGIC2(gsm, message_printer); %include "grgsm/misc_utils/tmsi_dumper.h" GR_SWIG_BLOCK_MAGIC2(gsm, tmsi_dumper); +%include "grgsm/misc_utils/message_source.h" +GR_SWIG_BLOCK_MAGIC2(gsm, message_source); -- cgit v1.2.3 From 1e82b8d4d177c4bb3b99cb53b2aff96f07f22f06 Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Wed, 29 Jul 2015 11:01:34 +0200 Subject: Implemented message sink block for unit testing --- grc/gsm_block_tree.xml | 1 + grc/misc_utils/CMakeLists.txt | 5 +- grc/misc_utils/gsm_message_sink.xml | 19 +++++++ include/grgsm/misc_utils/CMakeLists.txt | 7 +-- include/grgsm/misc_utils/message_sink.h | 60 ++++++++++++++++++++++ lib/CMakeLists.txt | 3 +- lib/misc_utils/message_sink_impl.cc | 90 +++++++++++++++++++++++++++++++++ lib/misc_utils/message_sink_impl.h | 47 +++++++++++++++++ swig/grgsm_swig.i | 4 ++ 9 files changed, 230 insertions(+), 6 deletions(-) create mode 100644 grc/misc_utils/gsm_message_sink.xml create mode 100644 include/grgsm/misc_utils/message_sink.h create mode 100644 lib/misc_utils/message_sink_impl.cc create mode 100644 lib/misc_utils/message_sink_impl.h diff --git a/grc/gsm_block_tree.xml b/grc/gsm_block_tree.xml index 5837ce2..2864e4d 100644 --- a/grc/gsm_block_tree.xml +++ b/grc/gsm_block_tree.xml @@ -52,6 +52,7 @@ gsm_clock_offset_corrector gsm_tmsi_dumper gsm_message_source + gsm_message_sink diff --git a/grc/misc_utils/CMakeLists.txt b/grc/misc_utils/CMakeLists.txt index 403a321..5dd4c1b 100644 --- a/grc/misc_utils/CMakeLists.txt +++ b/grc/misc_utils/CMakeLists.txt @@ -29,6 +29,7 @@ install(FILES gsm_burst_sink.xml gsm_burst_source.xml gsm_burst_source_qa.xml - gsm_burst_sink_qa.xml - gsm_message_source.xml DESTINATION share/gnuradio/grc/blocks + gsm_burst_sink_qa.xml + gsm_message_source.xml + gsm_message_sink.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/misc_utils/gsm_message_sink.xml b/grc/misc_utils/gsm_message_sink.xml new file mode 100644 index 0000000..e0d6ac0 --- /dev/null +++ b/grc/misc_utils/gsm_message_sink.xml @@ -0,0 +1,19 @@ + + + Message Sink + gsm_message_sink + import grgsm + grgsm.message_sink() + + + in + message + + + +This block is a message sink for testing purposes. + +The data can be retrieved using function get_messages() + + + diff --git a/include/grgsm/misc_utils/CMakeLists.txt b/include/grgsm/misc_utils/CMakeLists.txt index 000b7ef..18c2860 100644 --- a/include/grgsm/misc_utils/CMakeLists.txt +++ b/include/grgsm/misc_utils/CMakeLists.txt @@ -30,7 +30,8 @@ install(FILES extract_immediate_assignment.h controlled_rotator_cc.h controlled_const_source_f.h - message_printer.h - tmsi_dumper.h - message_source.h DESTINATION include/grgsm/misc_utils + message_printer.h + tmsi_dumper.h + message_source.h + message_sink.h DESTINATION include/grgsm/misc_utils ) diff --git a/include/grgsm/misc_utils/message_sink.h b/include/grgsm/misc_utils/message_sink.h new file mode 100644 index 0000000..5cfe2f7 --- /dev/null +++ b/include/grgsm/misc_utils/message_sink.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_SINK_H +#define INCLUDED_GSM_MESSAGE_SINK_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API message_sink : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::message_sink. + * + * To avoid accidental use of raw pointers, grgsm::message_sink's + * constructor is in a private implementation + * class. grgsm::message_sink::make is the public interface for + * creating new instances. + */ + static sptr make(); + + virtual std::vector get_messages() = 0; + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_SINK_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d66de3d..07b616e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -54,7 +54,8 @@ list(APPEND grgsm_sources misc_utils/burst_source_impl.cc misc_utils/burst_sink_qa_impl.cc misc_utils/burst_source_qa_impl.cc - misc_utils/message_source_impl.cc + misc_utils/message_source_impl.cc + misc_utils/message_sink_impl.cc decryption/decryption_impl.cc) add_library(gnuradio-grgsm SHARED ${grgsm_sources}) diff --git a/lib/misc_utils/message_sink_impl.cc b/lib/misc_utils/message_sink_impl.cc new file mode 100644 index 0000000..269cada --- /dev/null +++ b/lib/misc_utils/message_sink_impl.cc @@ -0,0 +1,90 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_sink_impl.h" +#include +#include + +namespace gr { + namespace gsm { + + message_sink::sptr + message_sink::make() + { + return gnuradio::get_initial_sptr + (new message_sink_impl()); + } + + /* + * The private constructor + */ + message_sink_impl::message_sink_impl() + : gr::block("message_sink", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)) + { + message_port_register_in(pmt::mp("in")); + set_msg_handler(pmt::mp("in"), boost::bind(&message_sink_impl::process_message, this, _1)); + } + + /* + * Our virtual destructor. + */ + message_sink_impl::~message_sink_impl() + { + for (int i=0; i0) + { + s_msg_stream << (" "); + } + s_msg_stream << std::hex << std::setw(2) << std::setfill('0') << (unsigned)message_plus_header[i]; + } + d_messages.push_back(s_msg_stream.str()); + } + + std::vector message_sink_impl::get_messages() + { + return d_messages; + } + + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/misc_utils/message_sink_impl.h b/lib/misc_utils/message_sink_impl.h new file mode 100644 index 0000000..c1fa43c --- /dev/null +++ b/lib/misc_utils/message_sink_impl.h @@ -0,0 +1,47 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_SINK_IMPL_H +#define INCLUDED_GSM_MESSAGE_SINK_IMPL_H + +#include + +namespace gr { + namespace gsm { + + class message_sink_impl : public message_sink + { + private: + std::vector d_messages; + + public: + message_sink_impl(); + ~message_sink_impl(); + void process_message(pmt::pmt_t msg); + virtual std::vector get_messages(); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_SINK_IMPL_H */ + diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i index 6189fee..5b7f458 100644 --- a/swig/grgsm_swig.i +++ b/swig/grgsm_swig.i @@ -28,6 +28,7 @@ #include "grgsm/misc_utils/burst_source.h" #include "grgsm/misc_utils/burst_source_qa.h" #include "grgsm/misc_utils/message_source.h" +#include "grgsm/misc_utils/message_sink.h" %} @@ -75,3 +76,6 @@ GR_SWIG_BLOCK_MAGIC2(gsm, message_printer); GR_SWIG_BLOCK_MAGIC2(gsm, tmsi_dumper); %include "grgsm/misc_utils/message_source.h" GR_SWIG_BLOCK_MAGIC2(gsm, message_source); +%include "grgsm/misc_utils/message_sink.h" +GR_SWIG_BLOCK_MAGIC2(gsm, message_sink); + -- cgit v1.2.3 From fa92b61aec0160e3bccd2f48d12120fc26b3ce0c Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Wed, 29 Jul 2015 11:34:31 +0200 Subject: Implemented unit tests for message printer block --- python/CMakeLists.txt | 1 + python/qa_message_printer.py | 166 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100755 python/qa_message_printer.py diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cb4b2b2..486ff80 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -47,5 +47,6 @@ include(GrTest) set(GR_TEST_TARGET_DEPS gr-gsm) set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig) GR_ADD_TEST(qa_decryption ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_decryption.py) +GR_ADD_TEST(qa_message_printer ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_message_printer.py) #GR_ADD_TEST(qa_receiver ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_receiver.py) #GR_ADD_TEST(qa_receiver_hier ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_receiver_hier.py) diff --git a/python/qa_message_printer.py b/python/qa_message_printer.py new file mode 100755 index 0000000..4efaaef --- /dev/null +++ b/python/qa_message_printer.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# @file +# @author Roman Khassraf +# @section LICENSE +# +# Gr-gsm 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. +# +# Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# +# + +from gnuradio import gr, gr_unittest, blocks +import grgsm +import os +import pmt +import sys +import tempfile + +class qa_message_printer (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block() + self.tmpfile = tempfile.NamedTemporaryFile() + self.prevfd = os.dup(sys.stdout.fileno()) + os.dup2(self.tmpfile.fileno(), sys.stdout.fileno()) + self.prev = sys.stdout + sys.stdout = os.fdopen(self.prevfd, "w") + + def tearDown (self): + self.tb = None + os.dup2(self.prevfd, self.prev.fileno()) + sys.stdout = self.prev + self.tmpfile.close() + + def getOutput(self): + self.tmpfile.seek(0) + return self.tmpfile.read() + + def getOutputExpected(self, expected_lines): + out = "" + for l in expected_lines: + out = out + l + "\n" + return out + + def test_001_no_prefix_no_header (self): + """ + Four messages, without any prefix, no gsmtap header + """ + msgs_input = [ + "02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", + "02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" + ] + + # there is a whitespace at the beginning of message_printer output + msgs_expected = [ + " 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + " 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + " 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", + " 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" + ] + + src = grgsm.message_source(msgs_input) + printer = grgsm.message_printer(pmt.intern(""), False) + self.tb.msg_connect(src, "msgs", printer, "msgs") + self.tb.run() + + self.assertEqual(self.getOutput(), self.getOutputExpected(msgs_expected)) + + + def test_002_prefix_no_header (self): + """ + Four messages, with prefix "test_002:", no gsmtap header + """ + msgs_input = [ + "02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", + "02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" + ] + + msgs_expected = [ + "test_002: 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "test_002: 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "test_002: 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", + "test_002: 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" + ] + + src = grgsm.message_source(msgs_input) + printer = grgsm.message_printer(pmt.intern("test_002:"), False) + self.tb.msg_connect(src, "msgs", printer, "msgs") + self.tb.run() + + self.assertEqual(self.getOutput(), self.getOutputExpected(msgs_expected)) + + + def test_003_no_prefix_header (self): + """ + Four messages, without any prefix, with gsmtap header + """ + msgs_input = [ + "02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", + "02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" + ] + + # there is a whitespace at the beginning of message_printer output + msgs_expected = [ + " 02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + " 02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + " 02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", + " 02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" + ] + + src = grgsm.message_source(msgs_input) + printer = grgsm.message_printer(pmt.intern(""), True) + self.tb.msg_connect(src, "msgs", printer, "msgs") + self.tb.run() + + self.assertEqual(self.getOutput(), self.getOutputExpected(msgs_expected)) + + + def test_004_prefix_header (self): + """ + Four messages, with prefix "test_004:", with gsmtap header + """ + msgs_input = [ + "02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", + "02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" + ] + + # there is a whitespace at the beginning of message_printer output + msgs_expected = [ + "test_004: 02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "test_004: 02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", + "test_004: 02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", + "test_004: 02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" + ] + + src = grgsm.message_source(msgs_input) + printer = grgsm.message_printer(pmt.intern("test_004:"), True) + self.tb.msg_connect(src, "msgs", printer, "msgs") + self.tb.run() + + self.assertEqual(self.getOutput(), self.getOutputExpected(msgs_expected)) + + +if __name__ == '__main__': + gr_unittest.run(qa_message_printer, "qa_message_printer.xml") + -- cgit v1.2.3 From 277ed307fd17dcce5fba1fb2c1898d3a0360b382 Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Mon, 3 Aug 2015 09:47:36 +0200 Subject: Added include for scoped_ptr --- lib/misc_utils/message_source_impl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/misc_utils/message_source_impl.cc b/lib/misc_utils/message_source_impl.cc index de24968..2e71ba4 100644 --- a/lib/misc_utils/message_source_impl.cc +++ b/lib/misc_utils/message_source_impl.cc @@ -26,11 +26,11 @@ #include #include "message_source_impl.h" -#include "stdio.h" +#include #include #include #include - +#include #include #include #include -- cgit v1.2.3 From c0cb6998da3c0cad463964fcc6643ff61c6e64b5 Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Mon, 3 Aug 2015 09:52:26 +0200 Subject: Removed test utilities from GRC --- grc/gsm_block_tree.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/grc/gsm_block_tree.xml b/grc/gsm_block_tree.xml index 2864e4d..94d1d82 100644 --- a/grc/gsm_block_tree.xml +++ b/grc/gsm_block_tree.xml @@ -42,8 +42,6 @@ gsm_bursts_printer gsm_burst_sink gsm_burst_source - gsm_burst_sink_qa - gsm_burst_source_qa gsm_extract_system_info gsm_extract_immediate_assignment gsm_controlled_rotator_cc @@ -51,8 +49,6 @@ gsm_message_printer gsm_clock_offset_corrector gsm_tmsi_dumper - gsm_message_source - gsm_message_sink -- cgit v1.2.3 From b8f4909d37c2c16c9c5deb09264fccfad973ed7d Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Mon, 3 Aug 2015 10:08:18 +0200 Subject: Moved qa utilities to a separate directory --- grc/misc_utils/gsm_burst_sink_qa.xml | 12 --- grc/misc_utils/gsm_burst_source_qa.xml | 35 ------- grc/misc_utils/gsm_message_sink.xml | 19 ---- grc/misc_utils/gsm_message_source.xml | 32 ------ grc/qa_utils/CMakeLists.txt | 25 +++++ grc/qa_utils/gsm_burst_sink_qa.xml | 12 +++ grc/qa_utils/gsm_burst_source_qa.xml | 35 +++++++ grc/qa_utils/gsm_message_sink.xml | 19 ++++ grc/qa_utils/gsm_message_source.xml | 32 ++++++ include/grgsm/misc_utils/burst_sink_qa.h | 60 ----------- include/grgsm/misc_utils/burst_source_qa.h | 64 ------------ include/grgsm/misc_utils/message_sink.h | 60 ----------- include/grgsm/misc_utils/message_source.h | 60 ----------- include/grgsm/qa_utils/CMakeLists.txt | 28 +++++ include/grgsm/qa_utils/burst_sink_qa.h | 60 +++++++++++ include/grgsm/qa_utils/burst_source_qa.h | 64 ++++++++++++ include/grgsm/qa_utils/message_sink.h | 60 +++++++++++ include/grgsm/qa_utils/message_source.h | 60 +++++++++++ lib/CMakeLists.txt | 11 +- lib/misc_utils/burst_sink_qa_impl.cc | 110 -------------------- lib/misc_utils/burst_sink_qa_impl.h | 51 --------- lib/misc_utils/burst_source_qa_impl.cc | 162 ----------------------------- lib/misc_utils/burst_source_qa_impl.h | 61 ----------- lib/misc_utils/message_sink_impl.cc | 90 ---------------- lib/misc_utils/message_sink_impl.h | 47 --------- lib/misc_utils/message_source_impl.cc | 131 ----------------------- lib/misc_utils/message_source_impl.h | 51 --------- lib/qa_utils/burst_sink_qa_impl.cc | 110 ++++++++++++++++++++ lib/qa_utils/burst_sink_qa_impl.h | 51 +++++++++ lib/qa_utils/burst_source_qa_impl.cc | 162 +++++++++++++++++++++++++++++ lib/qa_utils/burst_source_qa_impl.h | 61 +++++++++++ lib/qa_utils/message_sink_impl.cc | 90 ++++++++++++++++ lib/qa_utils/message_sink_impl.h | 47 +++++++++ lib/qa_utils/message_source_impl.cc | 131 +++++++++++++++++++++++ lib/qa_utils/message_source_impl.h | 51 +++++++++ swig/grgsm_swig.i | 21 ++-- 36 files changed, 1115 insertions(+), 1060 deletions(-) delete mode 100644 grc/misc_utils/gsm_burst_sink_qa.xml delete mode 100644 grc/misc_utils/gsm_burst_source_qa.xml delete mode 100644 grc/misc_utils/gsm_message_sink.xml delete mode 100644 grc/misc_utils/gsm_message_source.xml create mode 100644 grc/qa_utils/CMakeLists.txt create mode 100644 grc/qa_utils/gsm_burst_sink_qa.xml create mode 100644 grc/qa_utils/gsm_burst_source_qa.xml create mode 100644 grc/qa_utils/gsm_message_sink.xml create mode 100644 grc/qa_utils/gsm_message_source.xml delete mode 100644 include/grgsm/misc_utils/burst_sink_qa.h delete mode 100644 include/grgsm/misc_utils/burst_source_qa.h delete mode 100644 include/grgsm/misc_utils/message_sink.h delete mode 100644 include/grgsm/misc_utils/message_source.h create mode 100644 include/grgsm/qa_utils/CMakeLists.txt create mode 100644 include/grgsm/qa_utils/burst_sink_qa.h create mode 100644 include/grgsm/qa_utils/burst_source_qa.h create mode 100644 include/grgsm/qa_utils/message_sink.h create mode 100644 include/grgsm/qa_utils/message_source.h delete mode 100644 lib/misc_utils/burst_sink_qa_impl.cc delete mode 100644 lib/misc_utils/burst_sink_qa_impl.h delete mode 100644 lib/misc_utils/burst_source_qa_impl.cc delete mode 100644 lib/misc_utils/burst_source_qa_impl.h delete mode 100644 lib/misc_utils/message_sink_impl.cc delete mode 100644 lib/misc_utils/message_sink_impl.h delete mode 100644 lib/misc_utils/message_source_impl.cc delete mode 100644 lib/misc_utils/message_source_impl.h create mode 100644 lib/qa_utils/burst_sink_qa_impl.cc create mode 100644 lib/qa_utils/burst_sink_qa_impl.h create mode 100644 lib/qa_utils/burst_source_qa_impl.cc create mode 100644 lib/qa_utils/burst_source_qa_impl.h create mode 100644 lib/qa_utils/message_sink_impl.cc create mode 100644 lib/qa_utils/message_sink_impl.h create mode 100644 lib/qa_utils/message_source_impl.cc create mode 100644 lib/qa_utils/message_source_impl.h diff --git a/grc/misc_utils/gsm_burst_sink_qa.xml b/grc/misc_utils/gsm_burst_sink_qa.xml deleted file mode 100644 index c028da3..0000000 --- a/grc/misc_utils/gsm_burst_sink_qa.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - QA Burst sink - gsm_burst_sink_qa - import grgsm - grgsm.burst_sink_qa() - - - in - message - - diff --git a/grc/misc_utils/gsm_burst_source_qa.xml b/grc/misc_utils/gsm_burst_source_qa.xml deleted file mode 100644 index bb04cca..0000000 --- a/grc/misc_utils/gsm_burst_source_qa.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - QA Burst source - gsm_burst_source_qa - import grgsm - grgsm.burst_source_qa($framenumbers, $timeslots, $bursts) - - - Frame numbers - framenumbers - [] - int_vector - part - - - - Timeslots - timeslots - [] - int_vector - part - - - - Bursts - bursts - [[],] - raw - - - - out - message - - diff --git a/grc/misc_utils/gsm_message_sink.xml b/grc/misc_utils/gsm_message_sink.xml deleted file mode 100644 index e0d6ac0..0000000 --- a/grc/misc_utils/gsm_message_sink.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - Message Sink - gsm_message_sink - import grgsm - grgsm.message_sink() - - - in - message - - - -This block is a message sink for testing purposes. - -The data can be retrieved using function get_messages() - - - diff --git a/grc/misc_utils/gsm_message_source.xml b/grc/misc_utils/gsm_message_source.xml deleted file mode 100644 index ab06f65..0000000 --- a/grc/misc_utils/gsm_message_source.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - Message Source - gsm_message_source - import grgsm - grgsm.message_source($messages) - - - Messages - messages - ["02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", -"02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", -"02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", -"02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b"] - raw - true - - - - msgs - message - - - -This block is a basic message source for testing purposes. - -It takes a list of strings as input, where each string -is a whitespace-separated list of hexadecimal values representing the data bytes of a message including the gsmtap header. - -Such strings can be obtained using the message printer with option "Print GSMTap header" - - diff --git a/grc/qa_utils/CMakeLists.txt b/grc/qa_utils/CMakeLists.txt new file mode 100644 index 0000000..43398d4 --- /dev/null +++ b/grc/qa_utils/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2011,2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +install(FILES + gsm_burst_source_qa.xml + gsm_burst_sink_qa.xml + gsm_message_source.xml + gsm_message_sink.xml DESTINATION share/gnuradio/grc/blocks +) diff --git a/grc/qa_utils/gsm_burst_sink_qa.xml b/grc/qa_utils/gsm_burst_sink_qa.xml new file mode 100644 index 0000000..c028da3 --- /dev/null +++ b/grc/qa_utils/gsm_burst_sink_qa.xml @@ -0,0 +1,12 @@ + + + QA Burst sink + gsm_burst_sink_qa + import grgsm + grgsm.burst_sink_qa() + + + in + message + + diff --git a/grc/qa_utils/gsm_burst_source_qa.xml b/grc/qa_utils/gsm_burst_source_qa.xml new file mode 100644 index 0000000..bb04cca --- /dev/null +++ b/grc/qa_utils/gsm_burst_source_qa.xml @@ -0,0 +1,35 @@ + + + QA Burst source + gsm_burst_source_qa + import grgsm + grgsm.burst_source_qa($framenumbers, $timeslots, $bursts) + + + Frame numbers + framenumbers + [] + int_vector + part + + + + Timeslots + timeslots + [] + int_vector + part + + + + Bursts + bursts + [[],] + raw + + + + out + message + + diff --git a/grc/qa_utils/gsm_message_sink.xml b/grc/qa_utils/gsm_message_sink.xml new file mode 100644 index 0000000..e0d6ac0 --- /dev/null +++ b/grc/qa_utils/gsm_message_sink.xml @@ -0,0 +1,19 @@ + + + Message Sink + gsm_message_sink + import grgsm + grgsm.message_sink() + + + in + message + + + +This block is a message sink for testing purposes. + +The data can be retrieved using function get_messages() + + + diff --git a/grc/qa_utils/gsm_message_source.xml b/grc/qa_utils/gsm_message_source.xml new file mode 100644 index 0000000..ab06f65 --- /dev/null +++ b/grc/qa_utils/gsm_message_source.xml @@ -0,0 +1,32 @@ + + + Message Source + gsm_message_source + import grgsm + grgsm.message_source($messages) + + + Messages + messages + ["02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", +"02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b", +"02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00", +"02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b"] + raw + true + + + + msgs + message + + + +This block is a basic message source for testing purposes. + +It takes a list of strings as input, where each string +is a whitespace-separated list of hexadecimal values representing the data bytes of a message including the gsmtap header. + +Such strings can be obtained using the message printer with option "Print GSMTap header" + + diff --git a/include/grgsm/misc_utils/burst_sink_qa.h b/include/grgsm/misc_utils/burst_sink_qa.h deleted file mode 100644 index 3b5cac2..0000000 --- a/include/grgsm/misc_utils/burst_sink_qa.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SINK_QA_H -#define INCLUDED_GSM_BURST_SINK_QA_H - -#include -#include - -namespace gr { - namespace gsm { - - /*! - * \brief <+description of block+> - * \ingroup gsm - * - */ - class GSM_API burst_sink_qa : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of grgsm::burst_sink_qa. - * - * To avoid accidental use of raw pointers, grgsm::burst_sink_qa's - * constructor is in a private implementation - * class. grgsm::burst_sink_qa::make is the public interface for - * creating new instances. - */ - static sptr make(); - - virtual std::vector get_framenumbers() = 0; - virtual std::vector get_timeslots() = 0; - virtual std::vector get_burst_data() = 0; - }; - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SINK_QA_H */ - diff --git a/include/grgsm/misc_utils/burst_source_qa.h b/include/grgsm/misc_utils/burst_source_qa.h deleted file mode 100644 index c3c5713..0000000 --- a/include/grgsm/misc_utils/burst_source_qa.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SOURCE_QA_H -#define INCLUDED_GSM_BURST_SOURCE_QA_H - -#include -#include - -namespace gr { - namespace gsm { - - /*! - * \brief <+description of block+> - * \ingroup gsm - * - */ - class GSM_API burst_source_qa : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of grgsm::burst_source_qa. - * - * To avoid accidental use of raw pointers, grgsm::burst_source_qa's - * constructor is in a private implementation - * class. grgsm::burst_source_qa::make is the public interface for - * creating new instances. - */ - static sptr make(const std::vector &framenumbers, - const std::vector ×lots, - const std::vector &burst_data); - - virtual void set_framenumbers(const std::vector &framenumbers) = 0; - virtual void set_timeslots(const std::vector ×lots) = 0; - virtual void set_burst_data(const std::vector &burst_data) = 0; - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SOURCE_QA_H */ - - diff --git a/include/grgsm/misc_utils/message_sink.h b/include/grgsm/misc_utils/message_sink.h deleted file mode 100644 index 5cfe2f7..0000000 --- a/include/grgsm/misc_utils/message_sink.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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_SINK_H -#define INCLUDED_GSM_MESSAGE_SINK_H - -#include -#include - -namespace gr { - namespace gsm { - - /*! - * \brief <+description of block+> - * \ingroup gsm - * - */ - class GSM_API message_sink : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of grgsm::message_sink. - * - * To avoid accidental use of raw pointers, grgsm::message_sink's - * constructor is in a private implementation - * class. grgsm::message_sink::make is the public interface for - * creating new instances. - */ - static sptr make(); - - virtual std::vector get_messages() = 0; - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_MESSAGE_SINK_H */ - diff --git a/include/grgsm/misc_utils/message_source.h b/include/grgsm/misc_utils/message_source.h deleted file mode 100644 index 5c3e8a1..0000000 --- a/include/grgsm/misc_utils/message_source.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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_SOURCE_H -#define INCLUDED_GSM_MESSAGE_SOURCE_H - -#include -#include - -namespace gr { - namespace gsm { - - /*! - * \brief <+description of block+> - * \ingroup gsm - * - */ - class GSM_API message_source : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of grgsm::message_source. - * - * To avoid accidental use of raw pointers, grgsm::message_source's - * constructor is in a private implementation - * class. grgsm::message_source::make is the public interface for - * creating new instances. - */ - static sptr make(const std::vector &msg_data); - - virtual void set_msg_data(const std::vector &msg_data) = 0; - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_MESSAGE_SOURCE_H */ - diff --git a/include/grgsm/qa_utils/CMakeLists.txt b/include/grgsm/qa_utils/CMakeLists.txt new file mode 100644 index 0000000..e0b5579 --- /dev/null +++ b/include/grgsm/qa_utils/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright 2011,2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Install public header files +######################################################################## +install(FILES + burst_sink_qa.h + burst_source_qa.h + message_source.h + message_sink.h DESTINATION include/grgsm/qa_utils +) diff --git a/include/grgsm/qa_utils/burst_sink_qa.h b/include/grgsm/qa_utils/burst_sink_qa.h new file mode 100644 index 0000000..3b5cac2 --- /dev/null +++ b/include/grgsm/qa_utils/burst_sink_qa.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_SINK_QA_H +#define INCLUDED_GSM_BURST_SINK_QA_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API burst_sink_qa : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::burst_sink_qa. + * + * To avoid accidental use of raw pointers, grgsm::burst_sink_qa's + * constructor is in a private implementation + * class. grgsm::burst_sink_qa::make is the public interface for + * creating new instances. + */ + static sptr make(); + + virtual std::vector get_framenumbers() = 0; + virtual std::vector get_timeslots() = 0; + virtual std::vector get_burst_data() = 0; + }; + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_SINK_QA_H */ + diff --git a/include/grgsm/qa_utils/burst_source_qa.h b/include/grgsm/qa_utils/burst_source_qa.h new file mode 100644 index 0000000..c3c5713 --- /dev/null +++ b/include/grgsm/qa_utils/burst_source_qa.h @@ -0,0 +1,64 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_SOURCE_QA_H +#define INCLUDED_GSM_BURST_SOURCE_QA_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API burst_source_qa : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::burst_source_qa. + * + * To avoid accidental use of raw pointers, grgsm::burst_source_qa's + * constructor is in a private implementation + * class. grgsm::burst_source_qa::make is the public interface for + * creating new instances. + */ + static sptr make(const std::vector &framenumbers, + const std::vector ×lots, + const std::vector &burst_data); + + virtual void set_framenumbers(const std::vector &framenumbers) = 0; + virtual void set_timeslots(const std::vector ×lots) = 0; + virtual void set_burst_data(const std::vector &burst_data) = 0; + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_SOURCE_QA_H */ + + diff --git a/include/grgsm/qa_utils/message_sink.h b/include/grgsm/qa_utils/message_sink.h new file mode 100644 index 0000000..5cfe2f7 --- /dev/null +++ b/include/grgsm/qa_utils/message_sink.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_SINK_H +#define INCLUDED_GSM_MESSAGE_SINK_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API message_sink : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::message_sink. + * + * To avoid accidental use of raw pointers, grgsm::message_sink's + * constructor is in a private implementation + * class. grgsm::message_sink::make is the public interface for + * creating new instances. + */ + static sptr make(); + + virtual std::vector get_messages() = 0; + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_SINK_H */ + diff --git a/include/grgsm/qa_utils/message_source.h b/include/grgsm/qa_utils/message_source.h new file mode 100644 index 0000000..5c3e8a1 --- /dev/null +++ b/include/grgsm/qa_utils/message_source.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_SOURCE_H +#define INCLUDED_GSM_MESSAGE_SOURCE_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API message_source : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::message_source. + * + * To avoid accidental use of raw pointers, grgsm::message_source's + * constructor is in a private implementation + * class. grgsm::message_source::make is the public interface for + * creating new instances. + */ + static sptr make(const std::vector &msg_data); + + virtual void set_msg_data(const std::vector &msg_data) = 0; + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_SOURCE_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 07b616e..7cb05b8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -52,11 +52,12 @@ list(APPEND grgsm_sources misc_utils/tmsi_dumper_impl.cc misc_utils/burst_sink_impl.cc misc_utils/burst_source_impl.cc - misc_utils/burst_sink_qa_impl.cc - misc_utils/burst_source_qa_impl.cc - misc_utils/message_source_impl.cc - misc_utils/message_sink_impl.cc - decryption/decryption_impl.cc) + qa_utils/burst_sink_qa_impl.cc + qa_utils/burst_source_qa_impl.cc + qa_utils/message_source_impl.cc + qa_utils/message_sink_impl.cc + decryption/decryption_impl.cc +) add_library(gnuradio-grgsm SHARED ${grgsm_sources}) target_link_libraries(gnuradio-grgsm ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES} ${LIBOSMOCORE_LIBRARIES} diff --git a/lib/misc_utils/burst_sink_qa_impl.cc b/lib/misc_utils/burst_sink_qa_impl.cc deleted file mode 100644 index aa9df9d..0000000 --- a/lib/misc_utils/burst_sink_qa_impl.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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 "burst_sink_qa_impl.h" -#include -#include -#include - -namespace gr { - namespace gsm { - - burst_sink_qa::sptr - burst_sink_qa::make() - { - return gnuradio::get_initial_sptr - (new burst_sink_qa_impl()); - } - - /* - * The private constructor - */ - burst_sink_qa_impl::burst_sink_qa_impl() - : gr::block("burst_sink_qa", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)) - { - message_port_register_in(pmt::mp("in")); - set_msg_handler(pmt::mp("in"), boost::bind(&burst_sink_qa_impl::process_burst, this, _1)); - } - - /* - * Our virtual destructor. - */ - burst_sink_qa_impl::~burst_sink_qa_impl() - { -// for (int i=0; iframe_number); - - std::stringstream burst_str; - for(int i=0; i(burst[i]) == 0) - { - burst_str << "0"; - } - else - { - burst_str << "1"; - } - } - - d_framenumbers.push_back(frame_nr); - d_timeslots.push_back(header->timeslot); - d_burst_data.push_back(burst_str.str()); - } - - std::vector burst_sink_qa_impl::get_framenumbers() - { - return d_framenumbers; - } - - std::vector burst_sink_qa_impl::get_timeslots() - { - return d_timeslots; - } - - std::vector burst_sink_qa_impl::get_burst_data() - { - return d_burst_data; - } - - } /* namespace gsm */ -} /* namespace gr */ - diff --git a/lib/misc_utils/burst_sink_qa_impl.h b/lib/misc_utils/burst_sink_qa_impl.h deleted file mode 100644 index 412a0a1..0000000 --- a/lib/misc_utils/burst_sink_qa_impl.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SINK_QA_IMPL_H -#define INCLUDED_GSM_BURST_SINK_QA_IMPL_H - -#include -#include - -namespace gr { - namespace gsm { - - class burst_sink_qa_impl : public burst_sink_qa - { - private: - std::vector d_framenumbers; - std::vector d_timeslots; - std::vector d_burst_data; - public: - burst_sink_qa_impl(); - ~burst_sink_qa_impl(); - void process_burst(pmt::pmt_t msg); - virtual std::vector get_framenumbers(); - virtual std::vector get_timeslots(); - virtual std::vector get_burst_data(); - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SINK_QA_IMPL_H */ - diff --git a/lib/misc_utils/burst_source_qa_impl.cc b/lib/misc_utils/burst_source_qa_impl.cc deleted file mode 100644 index 7b2d412..0000000 --- a/lib/misc_utils/burst_source_qa_impl.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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 "burst_source_qa_impl.h" -#include "stdio.h" -#include -#include -#include - -#define PMT_SIZE 174 - -namespace gr { - namespace gsm { - - burst_source_qa::sptr - burst_source_qa::make(const std::vector &framenumbers, - const std::vector ×lots, - const std::vector &burst_data) - { - return gnuradio::get_initial_sptr - (new burst_source_qa_impl(framenumbers, timeslots, burst_data)); - } - - /* - * The private constructor - */ - burst_source_qa_impl::burst_source_qa_impl(const std::vector &framenumbers, - const std::vector ×lots, - const std::vector &burst_data) - : gr::block("burst_source_qa", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)), - d_finished(false) - { - message_port_register_out(pmt::mp("out")); - set_framenumbers(framenumbers); - set_timeslots(timeslots); - set_burst_data(burst_data); - } - - /* - * Our virtual destructor. - */ - burst_source_qa_impl::~burst_source_qa_impl() - { - if (d_finished == false){ - d_finished = true; - } - } - - void burst_source_qa_impl::set_framenumbers(const std::vector &framenumbers) - { - d_framenumbers = framenumbers; - } - - void burst_source_qa_impl::set_timeslots(const std::vector ×lots) - { - d_timeslots = timeslots; - } - - void burst_source_qa_impl::set_burst_data(const std::vector &burst_data) - { - d_burst_data = burst_data; - } - - bool burst_source_qa_impl::start() - { - d_finished = false; - d_thread = boost::shared_ptr - (new gr::thread::thread(boost::bind(&burst_source_qa_impl::run, this))); - return block::start(); - } - - bool burst_source_qa_impl::stop() - { - d_finished = true; - d_thread->interrupt(); - d_thread->join(); - return block::stop(); - } - - bool burst_source_qa_impl::finished() - { - return d_finished; - } - - void burst_source_qa_impl::run() - { - char *unserialized = (char*)malloc(sizeof(char) * PMT_SIZE); - - for (int i=0; i= 0 && d_timeslots[i] <= 7 && - d_framenumbers[i] >= 0 && d_framenumbers[i] <= (26 * 51 * 2048 - 1)) - { - boost::scoped_ptr tap_header(new gsmtap_hdr()); - - tap_header->version = GSMTAP_VERSION; - tap_header->hdr_len = sizeof(gsmtap_hdr)/4; - tap_header->type = GSMTAP_TYPE_UM_BURST; - tap_header->timeslot = d_timeslots[i]; - tap_header->frame_number = htobe32(d_framenumbers[i]); - tap_header->sub_type = GSMTAP_BURST_NORMAL; - tap_header->arfcn = 0; - tap_header->signal_dbm = 0; - tap_header->snr_db = 0; - - uint8_t burst[BURST_SIZE]; - - for (int j=0; j - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H -#define INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H - -#define BURST_SIZE 148 - -#include -#include - - -namespace gr { - namespace gsm { - - class burst_source_qa_impl : public burst_source_qa - { - private: - boost::shared_ptr d_thread; - std::vector d_framenumbers; - std::vector d_timeslots; - std::vector d_burst_data; - bool d_finished; - void run(); - public: - burst_source_qa_impl(const std::vector &framenumbers, - const std::vector ×lots, - const std::vector &burst_data); - ~burst_source_qa_impl(); - virtual void set_framenumbers(const std::vector &framenumbers); - virtual void set_timeslots(const std::vector ×lots); - virtual void set_burst_data(const std::vector &burst_data); - bool start(); - bool stop(); - bool finished(); - }; - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H */ - - diff --git a/lib/misc_utils/message_sink_impl.cc b/lib/misc_utils/message_sink_impl.cc deleted file mode 100644 index 269cada..0000000 --- a/lib/misc_utils/message_sink_impl.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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_sink_impl.h" -#include -#include - -namespace gr { - namespace gsm { - - message_sink::sptr - message_sink::make() - { - return gnuradio::get_initial_sptr - (new message_sink_impl()); - } - - /* - * The private constructor - */ - message_sink_impl::message_sink_impl() - : gr::block("message_sink", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)) - { - message_port_register_in(pmt::mp("in")); - set_msg_handler(pmt::mp("in"), boost::bind(&message_sink_impl::process_message, this, _1)); - } - - /* - * Our virtual destructor. - */ - message_sink_impl::~message_sink_impl() - { - for (int i=0; i0) - { - s_msg_stream << (" "); - } - s_msg_stream << std::hex << std::setw(2) << std::setfill('0') << (unsigned)message_plus_header[i]; - } - d_messages.push_back(s_msg_stream.str()); - } - - std::vector message_sink_impl::get_messages() - { - return d_messages; - } - - } /* namespace gsm */ -} /* namespace gr */ - diff --git a/lib/misc_utils/message_sink_impl.h b/lib/misc_utils/message_sink_impl.h deleted file mode 100644 index c1fa43c..0000000 --- a/lib/misc_utils/message_sink_impl.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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_SINK_IMPL_H -#define INCLUDED_GSM_MESSAGE_SINK_IMPL_H - -#include - -namespace gr { - namespace gsm { - - class message_sink_impl : public message_sink - { - private: - std::vector d_messages; - - public: - message_sink_impl(); - ~message_sink_impl(); - void process_message(pmt::pmt_t msg); - virtual std::vector get_messages(); - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_MESSAGE_SINK_IMPL_H */ - diff --git a/lib/misc_utils/message_source_impl.cc b/lib/misc_utils/message_source_impl.cc deleted file mode 100644 index 2e71ba4..0000000 --- a/lib/misc_utils/message_source_impl.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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_source_impl.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#define MSG_BYTE_LEN 39 - - -namespace gr { - namespace gsm { - - message_source::sptr - message_source::make(const std::vector &msg_data) - { - return gnuradio::get_initial_sptr - (new message_source_impl(msg_data)); - } - - /* - * The private constructor - */ - message_source_impl::message_source_impl(const std::vector &msg_data) - : gr::block("message_source", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)), - d_finished(false) - { - message_port_register_out(pmt::mp("msgs")); - set_msg_data(msg_data); - } - - /* - * Our virtual destructor. - */ - message_source_impl::~message_source_impl() - { - if (d_finished == false){ - d_finished = true; - } - } - - void message_source_impl::set_msg_data(const std::vector &msg_data) - { - for (int i=0; i bytes; - unsigned int c; - - while (iss >> std::hex >> c) - { - if (c < 256) - { - bytes.push_back(c); - } - } - - if (bytes.size() == MSG_BYTE_LEN) - { - d_msgs.push_back(bytes); - } - } - } - - bool message_source_impl::start() - { - d_finished = false; - d_thread = boost::shared_ptr - (new gr::thread::thread(boost::bind(&message_source_impl::run, this))); - return block::start(); - } - - bool message_source_impl::stop() - { - d_finished = true; - d_thread->interrupt(); - d_thread->join(); - return block::stop(); - } - - bool message_source_impl::finished() - { - return d_finished; - } - - void message_source_impl::run() - { - for (int i=0; i current = d_msgs[i]; - pmt::pmt_t blob_header_plus_burst = pmt::make_blob(¤t[0], current.size()); - pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob_header_plus_burst); - message_port_pub(pmt::mp("msgs"), msg); - } - post(pmt::mp("system"), pmt::cons(pmt::mp("done"), pmt::from_long(1))); - } - } /* namespace gsm */ -} /* namespace gr */ - diff --git a/lib/misc_utils/message_source_impl.h b/lib/misc_utils/message_source_impl.h deleted file mode 100644 index 22a210e..0000000 --- a/lib/misc_utils/message_source_impl.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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_SOURCE_IMPL_H -#define INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H - -#include - -namespace gr { - namespace gsm { - - class message_source_impl : public message_source - { - private: - boost::shared_ptr d_thread; - std::vector > d_msgs; - bool d_finished; - void run(); - public: - message_source_impl(const std::vector &msg_data); - ~message_source_impl(); - virtual void set_msg_data(const std::vector &msg_data); - bool start(); - bool stop(); - bool finished(); - }; - - } // namespace grgsm -} // namespace gr - -#endif /* INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H */ - diff --git a/lib/qa_utils/burst_sink_qa_impl.cc b/lib/qa_utils/burst_sink_qa_impl.cc new file mode 100644 index 0000000..aa9df9d --- /dev/null +++ b/lib/qa_utils/burst_sink_qa_impl.cc @@ -0,0 +1,110 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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 "burst_sink_qa_impl.h" +#include +#include +#include + +namespace gr { + namespace gsm { + + burst_sink_qa::sptr + burst_sink_qa::make() + { + return gnuradio::get_initial_sptr + (new burst_sink_qa_impl()); + } + + /* + * The private constructor + */ + burst_sink_qa_impl::burst_sink_qa_impl() + : gr::block("burst_sink_qa", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)) + { + message_port_register_in(pmt::mp("in")); + set_msg_handler(pmt::mp("in"), boost::bind(&burst_sink_qa_impl::process_burst, this, _1)); + } + + /* + * Our virtual destructor. + */ + burst_sink_qa_impl::~burst_sink_qa_impl() + { +// for (int i=0; iframe_number); + + std::stringstream burst_str; + for(int i=0; i(burst[i]) == 0) + { + burst_str << "0"; + } + else + { + burst_str << "1"; + } + } + + d_framenumbers.push_back(frame_nr); + d_timeslots.push_back(header->timeslot); + d_burst_data.push_back(burst_str.str()); + } + + std::vector burst_sink_qa_impl::get_framenumbers() + { + return d_framenumbers; + } + + std::vector burst_sink_qa_impl::get_timeslots() + { + return d_timeslots; + } + + std::vector burst_sink_qa_impl::get_burst_data() + { + return d_burst_data; + } + + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/qa_utils/burst_sink_qa_impl.h b/lib/qa_utils/burst_sink_qa_impl.h new file mode 100644 index 0000000..4bd3825 --- /dev/null +++ b/lib/qa_utils/burst_sink_qa_impl.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_SINK_QA_IMPL_H +#define INCLUDED_GSM_BURST_SINK_QA_IMPL_H + +#include +#include + +namespace gr { + namespace gsm { + + class burst_sink_qa_impl : public burst_sink_qa + { + private: + std::vector d_framenumbers; + std::vector d_timeslots; + std::vector d_burst_data; + public: + burst_sink_qa_impl(); + ~burst_sink_qa_impl(); + void process_burst(pmt::pmt_t msg); + virtual std::vector get_framenumbers(); + virtual std::vector get_timeslots(); + virtual std::vector get_burst_data(); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_SINK_QA_IMPL_H */ + diff --git a/lib/qa_utils/burst_source_qa_impl.cc b/lib/qa_utils/burst_source_qa_impl.cc new file mode 100644 index 0000000..7b2d412 --- /dev/null +++ b/lib/qa_utils/burst_source_qa_impl.cc @@ -0,0 +1,162 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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 "burst_source_qa_impl.h" +#include "stdio.h" +#include +#include +#include + +#define PMT_SIZE 174 + +namespace gr { + namespace gsm { + + burst_source_qa::sptr + burst_source_qa::make(const std::vector &framenumbers, + const std::vector ×lots, + const std::vector &burst_data) + { + return gnuradio::get_initial_sptr + (new burst_source_qa_impl(framenumbers, timeslots, burst_data)); + } + + /* + * The private constructor + */ + burst_source_qa_impl::burst_source_qa_impl(const std::vector &framenumbers, + const std::vector ×lots, + const std::vector &burst_data) + : gr::block("burst_source_qa", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)), + d_finished(false) + { + message_port_register_out(pmt::mp("out")); + set_framenumbers(framenumbers); + set_timeslots(timeslots); + set_burst_data(burst_data); + } + + /* + * Our virtual destructor. + */ + burst_source_qa_impl::~burst_source_qa_impl() + { + if (d_finished == false){ + d_finished = true; + } + } + + void burst_source_qa_impl::set_framenumbers(const std::vector &framenumbers) + { + d_framenumbers = framenumbers; + } + + void burst_source_qa_impl::set_timeslots(const std::vector ×lots) + { + d_timeslots = timeslots; + } + + void burst_source_qa_impl::set_burst_data(const std::vector &burst_data) + { + d_burst_data = burst_data; + } + + bool burst_source_qa_impl::start() + { + d_finished = false; + d_thread = boost::shared_ptr + (new gr::thread::thread(boost::bind(&burst_source_qa_impl::run, this))); + return block::start(); + } + + bool burst_source_qa_impl::stop() + { + d_finished = true; + d_thread->interrupt(); + d_thread->join(); + return block::stop(); + } + + bool burst_source_qa_impl::finished() + { + return d_finished; + } + + void burst_source_qa_impl::run() + { + char *unserialized = (char*)malloc(sizeof(char) * PMT_SIZE); + + for (int i=0; i= 0 && d_timeslots[i] <= 7 && + d_framenumbers[i] >= 0 && d_framenumbers[i] <= (26 * 51 * 2048 - 1)) + { + boost::scoped_ptr tap_header(new gsmtap_hdr()); + + tap_header->version = GSMTAP_VERSION; + tap_header->hdr_len = sizeof(gsmtap_hdr)/4; + tap_header->type = GSMTAP_TYPE_UM_BURST; + tap_header->timeslot = d_timeslots[i]; + tap_header->frame_number = htobe32(d_framenumbers[i]); + tap_header->sub_type = GSMTAP_BURST_NORMAL; + tap_header->arfcn = 0; + tap_header->signal_dbm = 0; + tap_header->snr_db = 0; + + uint8_t burst[BURST_SIZE]; + + for (int j=0; j + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H +#define INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H + +#define BURST_SIZE 148 + +#include +#include + + +namespace gr { + namespace gsm { + + class burst_source_qa_impl : public burst_source_qa + { + private: + boost::shared_ptr d_thread; + std::vector d_framenumbers; + std::vector d_timeslots; + std::vector d_burst_data; + bool d_finished; + void run(); + public: + burst_source_qa_impl(const std::vector &framenumbers, + const std::vector ×lots, + const std::vector &burst_data); + ~burst_source_qa_impl(); + virtual void set_framenumbers(const std::vector &framenumbers); + virtual void set_timeslots(const std::vector ×lots); + virtual void set_burst_data(const std::vector &burst_data); + bool start(); + bool stop(); + bool finished(); + }; + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H */ + + diff --git a/lib/qa_utils/message_sink_impl.cc b/lib/qa_utils/message_sink_impl.cc new file mode 100644 index 0000000..269cada --- /dev/null +++ b/lib/qa_utils/message_sink_impl.cc @@ -0,0 +1,90 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_sink_impl.h" +#include +#include + +namespace gr { + namespace gsm { + + message_sink::sptr + message_sink::make() + { + return gnuradio::get_initial_sptr + (new message_sink_impl()); + } + + /* + * The private constructor + */ + message_sink_impl::message_sink_impl() + : gr::block("message_sink", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)) + { + message_port_register_in(pmt::mp("in")); + set_msg_handler(pmt::mp("in"), boost::bind(&message_sink_impl::process_message, this, _1)); + } + + /* + * Our virtual destructor. + */ + message_sink_impl::~message_sink_impl() + { + for (int i=0; i0) + { + s_msg_stream << (" "); + } + s_msg_stream << std::hex << std::setw(2) << std::setfill('0') << (unsigned)message_plus_header[i]; + } + d_messages.push_back(s_msg_stream.str()); + } + + std::vector message_sink_impl::get_messages() + { + return d_messages; + } + + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/qa_utils/message_sink_impl.h b/lib/qa_utils/message_sink_impl.h new file mode 100644 index 0000000..dd11819 --- /dev/null +++ b/lib/qa_utils/message_sink_impl.h @@ -0,0 +1,47 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_SINK_IMPL_H +#define INCLUDED_GSM_MESSAGE_SINK_IMPL_H + +#include + +namespace gr { + namespace gsm { + + class message_sink_impl : public message_sink + { + private: + std::vector d_messages; + + public: + message_sink_impl(); + ~message_sink_impl(); + void process_message(pmt::pmt_t msg); + virtual std::vector get_messages(); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_SINK_IMPL_H */ + diff --git a/lib/qa_utils/message_source_impl.cc b/lib/qa_utils/message_source_impl.cc new file mode 100644 index 0000000..2e71ba4 --- /dev/null +++ b/lib/qa_utils/message_source_impl.cc @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_source_impl.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define MSG_BYTE_LEN 39 + + +namespace gr { + namespace gsm { + + message_source::sptr + message_source::make(const std::vector &msg_data) + { + return gnuradio::get_initial_sptr + (new message_source_impl(msg_data)); + } + + /* + * The private constructor + */ + message_source_impl::message_source_impl(const std::vector &msg_data) + : gr::block("message_source", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)), + d_finished(false) + { + message_port_register_out(pmt::mp("msgs")); + set_msg_data(msg_data); + } + + /* + * Our virtual destructor. + */ + message_source_impl::~message_source_impl() + { + if (d_finished == false){ + d_finished = true; + } + } + + void message_source_impl::set_msg_data(const std::vector &msg_data) + { + for (int i=0; i bytes; + unsigned int c; + + while (iss >> std::hex >> c) + { + if (c < 256) + { + bytes.push_back(c); + } + } + + if (bytes.size() == MSG_BYTE_LEN) + { + d_msgs.push_back(bytes); + } + } + } + + bool message_source_impl::start() + { + d_finished = false; + d_thread = boost::shared_ptr + (new gr::thread::thread(boost::bind(&message_source_impl::run, this))); + return block::start(); + } + + bool message_source_impl::stop() + { + d_finished = true; + d_thread->interrupt(); + d_thread->join(); + return block::stop(); + } + + bool message_source_impl::finished() + { + return d_finished; + } + + void message_source_impl::run() + { + for (int i=0; i current = d_msgs[i]; + pmt::pmt_t blob_header_plus_burst = pmt::make_blob(¤t[0], current.size()); + pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob_header_plus_burst); + message_port_pub(pmt::mp("msgs"), msg); + } + post(pmt::mp("system"), pmt::cons(pmt::mp("done"), pmt::from_long(1))); + } + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/qa_utils/message_source_impl.h b/lib/qa_utils/message_source_impl.h new file mode 100644 index 0000000..9856f78 --- /dev/null +++ b/lib/qa_utils/message_source_impl.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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_SOURCE_IMPL_H +#define INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H + +#include + +namespace gr { + namespace gsm { + + class message_source_impl : public message_source + { + private: + boost::shared_ptr d_thread; + std::vector > d_msgs; + bool d_finished; + void run(); + public: + message_source_impl(const std::vector &msg_data); + ~message_source_impl(); + virtual void set_msg_data(const std::vector &msg_data); + bool start(); + bool stop(); + bool finished(); + }; + + } // namespace grgsm +} // namespace gr + +#endif /* INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H */ + diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i index 5b7f458..c067757 100644 --- a/swig/grgsm_swig.i +++ b/swig/grgsm_swig.i @@ -24,11 +24,11 @@ #include "grgsm/misc_utils/message_printer.h" #include "grgsm/misc_utils/tmsi_dumper.h" #include "grgsm/misc_utils/burst_sink.h" -#include "grgsm/misc_utils/burst_sink_qa.h" #include "grgsm/misc_utils/burst_source.h" -#include "grgsm/misc_utils/burst_source_qa.h" -#include "grgsm/misc_utils/message_source.h" -#include "grgsm/misc_utils/message_sink.h" +#include "grgsm/qa_utils/burst_sink_qa.h" +#include "grgsm/qa_utils/burst_source_qa.h" +#include "grgsm/qa_utils/message_source.h" +#include "grgsm/qa_utils/message_sink.h" %} @@ -58,10 +58,6 @@ GR_SWIG_BLOCK_MAGIC2(gsm, bursts_printer); GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink); %include "grgsm/misc_utils/burst_source.h" GR_SWIG_BLOCK_MAGIC2(gsm, burst_source); -%include "grgsm/misc_utils/burst_sink_qa.h" -GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink_qa); -%include "grgsm/misc_utils/burst_source_qa.h" -GR_SWIG_BLOCK_MAGIC2(gsm, burst_source_qa); %include "grgsm/misc_utils/extract_system_info.h" GR_SWIG_BLOCK_MAGIC2(gsm, extract_system_info); %include "grgsm/misc_utils/extract_immediate_assignment.h" @@ -74,8 +70,13 @@ GR_SWIG_BLOCK_MAGIC2(gsm, controlled_const_source_f); GR_SWIG_BLOCK_MAGIC2(gsm, message_printer); %include "grgsm/misc_utils/tmsi_dumper.h" GR_SWIG_BLOCK_MAGIC2(gsm, tmsi_dumper); -%include "grgsm/misc_utils/message_source.h" + +%include "grgsm/qa_utils/burst_sink_qa.h" +GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink_qa); +%include "grgsm/qa_utils/burst_source_qa.h" +GR_SWIG_BLOCK_MAGIC2(gsm, burst_source_qa); +%include "grgsm/qa_utils/message_source.h" GR_SWIG_BLOCK_MAGIC2(gsm, message_source); -%include "grgsm/misc_utils/message_sink.h" +%include "grgsm/qa_utils/message_sink.h" GR_SWIG_BLOCK_MAGIC2(gsm, message_sink); -- cgit v1.2.3 From 1c3419e88f6b24fd7100de346db9bb9b9e8ebd0d Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Mon, 3 Aug 2015 10:58:57 +0200 Subject: Renamed burst sink/source to burst file sink/source --- grc/gsm_block_tree.xml | 4 +- grc/misc_utils/CMakeLists.txt | 8 +- grc/misc_utils/gsm_burst_file_sink.xml | 19 +++++ grc/misc_utils/gsm_burst_file_source.xml | 19 +++++ grc/misc_utils/gsm_burst_sink.xml | 19 ----- grc/misc_utils/gsm_burst_source.xml | 19 ----- include/grgsm/CMakeLists.txt | 2 +- include/grgsm/misc_utils/CMakeLists.txt | 10 +-- include/grgsm/misc_utils/burst_file_sink.h | 56 ++++++++++++++ include/grgsm/misc_utils/burst_file_source.h | 57 ++++++++++++++ include/grgsm/misc_utils/burst_sink.h | 56 -------------- include/grgsm/misc_utils/burst_source.h | 57 -------------- lib/CMakeLists.txt | 4 +- lib/misc_utils/burst_file_sink_impl.cc | 73 ++++++++++++++++++ lib/misc_utils/burst_file_sink_impl.h | 46 ++++++++++++ lib/misc_utils/burst_file_source_impl.cc | 106 +++++++++++++++++++++++++++ lib/misc_utils/burst_file_source_impl.h | 50 +++++++++++++ lib/misc_utils/burst_sink_impl.cc | 73 ------------------ lib/misc_utils/burst_sink_impl.h | 46 ------------ lib/misc_utils/burst_source_impl.cc | 106 --------------------------- lib/misc_utils/burst_source_impl.h | 50 ------------- swig/grgsm_swig.i | 12 +-- 22 files changed, 442 insertions(+), 450 deletions(-) create mode 100644 grc/misc_utils/gsm_burst_file_sink.xml create mode 100644 grc/misc_utils/gsm_burst_file_source.xml delete mode 100644 grc/misc_utils/gsm_burst_sink.xml delete mode 100644 grc/misc_utils/gsm_burst_source.xml create mode 100644 include/grgsm/misc_utils/burst_file_sink.h create mode 100644 include/grgsm/misc_utils/burst_file_source.h delete mode 100644 include/grgsm/misc_utils/burst_sink.h delete mode 100644 include/grgsm/misc_utils/burst_source.h create mode 100644 lib/misc_utils/burst_file_sink_impl.cc create mode 100644 lib/misc_utils/burst_file_sink_impl.h create mode 100644 lib/misc_utils/burst_file_source_impl.cc create mode 100644 lib/misc_utils/burst_file_source_impl.h delete mode 100644 lib/misc_utils/burst_sink_impl.cc delete mode 100644 lib/misc_utils/burst_sink_impl.h delete mode 100644 lib/misc_utils/burst_source_impl.cc delete mode 100644 lib/misc_utils/burst_source_impl.h diff --git a/grc/gsm_block_tree.xml b/grc/gsm_block_tree.xml index 94d1d82..fe29895 100644 --- a/grc/gsm_block_tree.xml +++ b/grc/gsm_block_tree.xml @@ -40,8 +40,8 @@ Utilities gsm_bursts_printer - gsm_burst_sink - gsm_burst_source + gsm_burst_file_sink + gsm_burst_file_source gsm_extract_system_info gsm_extract_immediate_assignment gsm_controlled_rotator_cc diff --git a/grc/misc_utils/CMakeLists.txt b/grc/misc_utils/CMakeLists.txt index 5dd4c1b..bbb4bce 100644 --- a/grc/misc_utils/CMakeLists.txt +++ b/grc/misc_utils/CMakeLists.txt @@ -26,10 +26,6 @@ install(FILES gsm_bursts_printer.xml gsm_clock_offset_corrector.xml gsm_tmsi_dumper.xml - gsm_burst_sink.xml - gsm_burst_source.xml - gsm_burst_source_qa.xml - gsm_burst_sink_qa.xml - gsm_message_source.xml - gsm_message_sink.xml DESTINATION share/gnuradio/grc/blocks + gsm_burst_file_sink.xml + gsm_burst_file_source.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/misc_utils/gsm_burst_file_sink.xml b/grc/misc_utils/gsm_burst_file_sink.xml new file mode 100644 index 0000000..e468e5f --- /dev/null +++ b/grc/misc_utils/gsm_burst_file_sink.xml @@ -0,0 +1,19 @@ + + + Burst file sink + gsm_burst_file_sink + import grgsm + grgsm.burst_file_sink($filename) + + + Destination file + filename + /tmp/bursts + file_open + + + + in + message + + diff --git a/grc/misc_utils/gsm_burst_file_source.xml b/grc/misc_utils/gsm_burst_file_source.xml new file mode 100644 index 0000000..e32a708 --- /dev/null +++ b/grc/misc_utils/gsm_burst_file_source.xml @@ -0,0 +1,19 @@ + + + Burst file source + gsm_burst_file_source + import grgsm + grgsm.burst_file_source($filename) + + + Source file + filename + /tmp/bursts + file_open + + + + out + message + + diff --git a/grc/misc_utils/gsm_burst_sink.xml b/grc/misc_utils/gsm_burst_sink.xml deleted file mode 100644 index a0e7532..0000000 --- a/grc/misc_utils/gsm_burst_sink.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - Burst sink - gsm_burst_sink - import grgsm - grgsm.burst_sink($filename) - - - Destination file - filename - /tmp/bursts - file_open - - - - in - message - - diff --git a/grc/misc_utils/gsm_burst_source.xml b/grc/misc_utils/gsm_burst_source.xml deleted file mode 100644 index 9e78069..0000000 --- a/grc/misc_utils/gsm_burst_source.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - Burst source - gsm_burst_source - import grgsm - grgsm.burst_source($filename) - - - Source file - filename - /tmp/bursts - file_open - - - - out - message - - diff --git a/include/grgsm/CMakeLists.txt b/include/grgsm/CMakeLists.txt index fd44c54..a16c076 100644 --- a/include/grgsm/CMakeLists.txt +++ b/include/grgsm/CMakeLists.txt @@ -32,4 +32,4 @@ add_subdirectory(decryption) add_subdirectory(demapping) add_subdirectory(receiver) add_subdirectory(misc_utils) - +add_subdirectory(qa_utils) diff --git a/include/grgsm/misc_utils/CMakeLists.txt b/include/grgsm/misc_utils/CMakeLists.txt index 18c2860..527ae51 100644 --- a/include/grgsm/misc_utils/CMakeLists.txt +++ b/include/grgsm/misc_utils/CMakeLists.txt @@ -22,16 +22,12 @@ ######################################################################## install(FILES bursts_printer.h - burst_sink.h - burst_source.h - burst_sink_qa.h - burst_source_qa.h + burst_file_source.h + burst_file_sink.h extract_system_info.h extract_immediate_assignment.h controlled_rotator_cc.h controlled_const_source_f.h message_printer.h - tmsi_dumper.h - message_source.h - message_sink.h DESTINATION include/grgsm/misc_utils + tmsi_dumper.h DESTINATION include/grgsm/misc_utils ) diff --git a/include/grgsm/misc_utils/burst_file_sink.h b/include/grgsm/misc_utils/burst_file_sink.h new file mode 100644 index 0000000..7263baa --- /dev/null +++ b/include/grgsm/misc_utils/burst_file_sink.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_FILE_SINK_H +#define INCLUDED_GSM_BURST_FILE_SINK_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API burst_file_sink : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::burst_file_sink. + * + * To avoid accidental use of raw pointers, grgsm::burst_file_sink's + * constructor is in a private implementation + * class. grgsm::burst_file_sink::make is the public interface for + * creating new instances. + */ + static sptr make(const std::string &filename); + }; + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_FILE_SINK_H */ + diff --git a/include/grgsm/misc_utils/burst_file_source.h b/include/grgsm/misc_utils/burst_file_source.h new file mode 100644 index 0000000..e18ef44 --- /dev/null +++ b/include/grgsm/misc_utils/burst_file_source.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_FILE_SOURCE_H +#define INCLUDED_GSM_BURST_FILE_SOURCE_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API burst_file_source : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::burst_file_source. + * + * To avoid accidental use of raw pointers, grgsm::burst_file_source's + * constructor is in a private implementation + * class. grgsm::burst_file_source::make is the public interface for + * creating new instances. + */ + static sptr make(const std::string &filename); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_FILE_SOURCE_H */ + diff --git a/include/grgsm/misc_utils/burst_sink.h b/include/grgsm/misc_utils/burst_sink.h deleted file mode 100644 index 6903df9..0000000 --- a/include/grgsm/misc_utils/burst_sink.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SINK_H -#define INCLUDED_GSM_BURST_SINK_H - -#include -#include - -namespace gr { - namespace gsm { - - /*! - * \brief <+description of block+> - * \ingroup gsm - * - */ - class GSM_API burst_sink : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of grgsm::burst_sink. - * - * To avoid accidental use of raw pointers, grgsm::burst_sink's - * constructor is in a private implementation - * class. grgsm::burst_sink::make is the public interface for - * creating new instances. - */ - static sptr make(const std::string &filename); - }; - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SINK_H */ - diff --git a/include/grgsm/misc_utils/burst_source.h b/include/grgsm/misc_utils/burst_source.h deleted file mode 100644 index bd8644f..0000000 --- a/include/grgsm/misc_utils/burst_source.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SOURCE_H -#define INCLUDED_GSM_BURST_SOURCE_H - -#include -#include - -namespace gr { - namespace gsm { - - /*! - * \brief <+description of block+> - * \ingroup gsm - * - */ - class GSM_API burst_source : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of grgsm::burst_source. - * - * To avoid accidental use of raw pointers, grgsm::burst_source's - * constructor is in a private implementation - * class. grgsm::burst_source::make is the public interface for - * creating new instances. - */ - static sptr make(const std::string &filename); - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SOURCE_H */ - diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 7cb05b8..a3a3388 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -50,8 +50,8 @@ list(APPEND grgsm_sources misc_utils/controlled_const_source_f_impl.cc misc_utils/message_printer_impl.cc misc_utils/tmsi_dumper_impl.cc - misc_utils/burst_sink_impl.cc - misc_utils/burst_source_impl.cc + misc_utils/burst_file_sink_impl.cc + misc_utils/burst_file_source_impl.cc qa_utils/burst_sink_qa_impl.cc qa_utils/burst_source_qa_impl.cc qa_utils/message_source_impl.cc diff --git a/lib/misc_utils/burst_file_sink_impl.cc b/lib/misc_utils/burst_file_sink_impl.cc new file mode 100644 index 0000000..25a262e --- /dev/null +++ b/lib/misc_utils/burst_file_sink_impl.cc @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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 "burst_file_sink_impl.h" +#include "stdio.h" + +namespace gr { + namespace gsm { + + burst_file_sink::sptr + burst_file_sink::make(const std::string &filename) + { + return gnuradio::get_initial_sptr + (new burst_file_sink_impl(filename)); + } + + /* + * The private constructor + */ + burst_file_sink_impl::burst_file_sink_impl(const std::string &filename) + : gr::block("burst_file_sink", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)), + d_output_file(filename.c_str(), std::ofstream::binary) + { + message_port_register_in(pmt::mp("in")); + set_msg_handler(pmt::mp("in"), boost::bind(&burst_file_sink_impl::process_burst, this, _1)); + } + + /* + * Our virtual destructor. + */ + burst_file_sink_impl::~burst_file_sink_impl() + { + if (d_output_file.is_open()) + { + d_output_file.close(); + } + } + + void burst_file_sink_impl::process_burst(pmt::pmt_t msg) + { + std::string s = pmt::serialize_str(msg); + const char *serialized = s.data(); + d_output_file.write(serialized, s.length()); + } + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/misc_utils/burst_file_sink_impl.h b/lib/misc_utils/burst_file_sink_impl.h new file mode 100644 index 0000000..898c609 --- /dev/null +++ b/lib/misc_utils/burst_file_sink_impl.h @@ -0,0 +1,46 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_FILE_SINK_IMPL_H +#define INCLUDED_GSM_BURST_FILE_SINK_IMPL_H + +#include +#include + +namespace gr { + namespace gsm { + + class burst_file_sink_impl : public burst_file_sink + { + private: + std::ofstream d_output_file; + public: + burst_file_sink_impl(const std::string &filename); + ~burst_file_sink_impl(); + void process_burst(pmt::pmt_t msg); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_FILE_SINK_IMPL_H */ + diff --git a/lib/misc_utils/burst_file_source_impl.cc b/lib/misc_utils/burst_file_source_impl.cc new file mode 100644 index 0000000..4661dfb --- /dev/null +++ b/lib/misc_utils/burst_file_source_impl.cc @@ -0,0 +1,106 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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 "burst_file_source_impl.h" +#include "stdio.h" + +#define PMT_SIZE 174 + +namespace gr { + namespace gsm { + + burst_file_source::sptr + burst_file_source::make(const std::string &filename) + { + return gnuradio::get_initial_sptr + (new burst_file_source_impl(filename)); + } + + /* + * The private constructor + */ + burst_file_source_impl::burst_file_source_impl(const std::string &filename) + : gr::block("burst_file_source", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)), + d_input_file(filename.c_str(), std::ifstream::binary), + d_finished(false) + { + message_port_register_out(pmt::mp("out")); + } + + /* + * Our virtual destructor. + */ + burst_file_source_impl::~burst_file_source_impl() + { + if (d_finished == false){ + d_finished = true; + } + } + + bool burst_file_source_impl::start() + { + d_finished = false; + d_thread = boost::shared_ptr + (new gr::thread::thread(boost::bind(&burst_file_source_impl::run, this))); + return block::start(); + } + + bool burst_file_source_impl::stop() + { + d_finished = true; + d_thread->interrupt(); + d_thread->join(); + return block::stop(); + } + + bool burst_file_source_impl::finished() + { + return d_finished; + } + + void burst_file_source_impl::run() + { + char *unserialized = (char*)malloc(sizeof(char) * PMT_SIZE); + while (d_input_file.read(unserialized, PMT_SIZE) && !d_finished) + { + if (d_input_file.bad()) + { + break; + } + + std::string s(unserialized, PMT_SIZE); + pmt::pmt_t burst = pmt::deserialize_str(s); + message_port_pub(pmt::mp("out"), burst); + } + d_input_file.close(); + post(pmt::mp("system"), pmt::cons(pmt::mp("done"), pmt::from_long(1))); + } + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/misc_utils/burst_file_source_impl.h b/lib/misc_utils/burst_file_source_impl.h new file mode 100644 index 0000000..383dc90 --- /dev/null +++ b/lib/misc_utils/burst_file_source_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_FILE_SOURCE_IMPL_H +#define INCLUDED_GSM_BURST_FILE_SOURCE_IMPL_H + +#include +#include + +namespace gr { + namespace gsm { + + class burst_file_source_impl : public burst_file_source + { + private: + boost::shared_ptr d_thread; + std::ifstream d_input_file; + bool d_finished; + void run(); + public: + burst_file_source_impl(const std::string &filename); + ~burst_file_source_impl(); + bool start(); + bool stop(); + bool finished(); + }; + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_FILE_SOURCE_IMPL_H */ + diff --git a/lib/misc_utils/burst_sink_impl.cc b/lib/misc_utils/burst_sink_impl.cc deleted file mode 100644 index fdb7d98..0000000 --- a/lib/misc_utils/burst_sink_impl.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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 "burst_sink_impl.h" -#include "stdio.h" - -namespace gr { - namespace gsm { - - burst_sink::sptr - burst_sink::make(const std::string &filename) - { - return gnuradio::get_initial_sptr - (new burst_sink_impl(filename)); - } - - /* - * The private constructor - */ - burst_sink_impl::burst_sink_impl(const std::string &filename) - : gr::block("burst_sink", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)), - d_output_file(filename.c_str(), std::ofstream::binary) - { - message_port_register_in(pmt::mp("in")); - set_msg_handler(pmt::mp("in"), boost::bind(&burst_sink_impl::process_burst, this, _1)); - } - - /* - * Our virtual destructor. - */ - burst_sink_impl::~burst_sink_impl() - { - if (d_output_file.is_open()) - { - d_output_file.close(); - } - } - - void burst_sink_impl::process_burst(pmt::pmt_t msg) - { - std::string s = pmt::serialize_str(msg); - const char *serialized = s.data(); - d_output_file.write(serialized, s.length()); - } - } /* namespace gsm */ -} /* namespace gr */ - diff --git a/lib/misc_utils/burst_sink_impl.h b/lib/misc_utils/burst_sink_impl.h deleted file mode 100644 index f981826..0000000 --- a/lib/misc_utils/burst_sink_impl.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SINK_IMPL_H -#define INCLUDED_GSM_BURST_SINK_IMPL_H - -#include -#include - -namespace gr { - namespace gsm { - - class burst_sink_impl : public burst_sink - { - private: - std::ofstream d_output_file; - public: - burst_sink_impl(const std::string &filename); - ~burst_sink_impl(); - void process_burst(pmt::pmt_t msg); - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SINK_IMPL_H */ - diff --git a/lib/misc_utils/burst_source_impl.cc b/lib/misc_utils/burst_source_impl.cc deleted file mode 100644 index 76d1eaa..0000000 --- a/lib/misc_utils/burst_source_impl.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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 "burst_source_impl.h" -#include "stdio.h" - -#define PMT_SIZE 174 - -namespace gr { - namespace gsm { - - burst_source::sptr - burst_source::make(const std::string &filename) - { - return gnuradio::get_initial_sptr - (new burst_source_impl(filename)); - } - - /* - * The private constructor - */ - burst_source_impl::burst_source_impl(const std::string &filename) - : gr::block("burst_source", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)), - d_input_file(filename.c_str(), std::ifstream::binary), - d_finished(false) - { - message_port_register_out(pmt::mp("out")); - } - - /* - * Our virtual destructor. - */ - burst_source_impl::~burst_source_impl() - { - if (d_finished == false){ - d_finished = true; - } - } - - bool burst_source_impl::start() - { - d_finished = false; - d_thread = boost::shared_ptr - (new gr::thread::thread(boost::bind(&burst_source_impl::run, this))); - return block::start(); - } - - bool burst_source_impl::stop() - { - d_finished = true; - d_thread->interrupt(); - d_thread->join(); - return block::stop(); - } - - bool burst_source_impl::finished() - { - return d_finished; - } - - void burst_source_impl::run() - { - char *unserialized = (char*)malloc(sizeof(char) * PMT_SIZE); - while (d_input_file.read(unserialized, PMT_SIZE) && !d_finished) - { - if (d_input_file.bad()) - { - break; - } - - std::string s(unserialized, PMT_SIZE); - pmt::pmt_t burst = pmt::deserialize_str(s); - message_port_pub(pmt::mp("out"), burst); - } - d_input_file.close(); - post(pmt::mp("system"), pmt::cons(pmt::mp("done"), pmt::from_long(1))); - } - } /* namespace gsm */ -} /* namespace gr */ - diff --git a/lib/misc_utils/burst_source_impl.h b/lib/misc_utils/burst_source_impl.h deleted file mode 100644 index 85217b0..0000000 --- a/lib/misc_utils/burst_source_impl.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SOURCE_IMPL_H -#define INCLUDED_GSM_BURST_SOURCE_IMPL_H - -#include -#include - -namespace gr { - namespace gsm { - - class burst_source_impl : public burst_source - { - private: - boost::shared_ptr d_thread; - std::ifstream d_input_file; - bool d_finished; - void run(); - public: - burst_source_impl(const std::string &filename); - ~burst_source_impl(); - bool start(); - bool stop(); - bool finished(); - }; - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SOURCE_IMPL_H */ - diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i index c067757..fbc4151 100644 --- a/swig/grgsm_swig.i +++ b/swig/grgsm_swig.i @@ -23,8 +23,8 @@ #include "grgsm/misc_utils/extract_immediate_assignment.h" #include "grgsm/misc_utils/message_printer.h" #include "grgsm/misc_utils/tmsi_dumper.h" -#include "grgsm/misc_utils/burst_sink.h" -#include "grgsm/misc_utils/burst_source.h" +#include "grgsm/misc_utils/burst_file_sink.h" +#include "grgsm/misc_utils/burst_file_source.h" #include "grgsm/qa_utils/burst_sink_qa.h" #include "grgsm/qa_utils/burst_source_qa.h" #include "grgsm/qa_utils/message_source.h" @@ -54,10 +54,10 @@ GR_SWIG_BLOCK_MAGIC2(gsm, tch_f_chans_demapper); %include "grgsm/misc_utils/bursts_printer.h" GR_SWIG_BLOCK_MAGIC2(gsm, bursts_printer); -%include "grgsm/misc_utils/burst_sink.h" -GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink); -%include "grgsm/misc_utils/burst_source.h" -GR_SWIG_BLOCK_MAGIC2(gsm, burst_source); +%include "grgsm/misc_utils/burst_file_sink.h" +GR_SWIG_BLOCK_MAGIC2(gsm, burst_file_sink); +%include "grgsm/misc_utils/burst_file_source.h" +GR_SWIG_BLOCK_MAGIC2(gsm, burst_file_source); %include "grgsm/misc_utils/extract_system_info.h" GR_SWIG_BLOCK_MAGIC2(gsm, extract_system_info); %include "grgsm/misc_utils/extract_immediate_assignment.h" -- cgit v1.2.3 From 1ce4469fd20a466984607ce0d075cb213e9c86f9 Mon Sep 17 00:00:00 2001 From: Roman Khassraf Date: Mon, 3 Aug 2015 11:16:10 +0200 Subject: Renamed burst_sink_qa/burst_source_qa to burst_sink/burst_source --- grc/qa_utils/CMakeLists.txt | 4 +- grc/qa_utils/gsm_burst_sink.xml | 12 +++ grc/qa_utils/gsm_burst_sink_qa.xml | 12 --- grc/qa_utils/gsm_burst_source.xml | 35 +++++++ grc/qa_utils/gsm_burst_source_qa.xml | 35 ------- include/grgsm/qa_utils/CMakeLists.txt | 4 +- include/grgsm/qa_utils/burst_sink.h | 60 ++++++++++++ include/grgsm/qa_utils/burst_sink_qa.h | 60 ------------ include/grgsm/qa_utils/burst_source.h | 64 ++++++++++++ include/grgsm/qa_utils/burst_source_qa.h | 64 ------------ lib/CMakeLists.txt | 4 +- lib/qa_utils/burst_sink_impl.cc | 110 +++++++++++++++++++++ lib/qa_utils/burst_sink_impl.h | 51 ++++++++++ lib/qa_utils/burst_sink_qa_impl.cc | 110 --------------------- lib/qa_utils/burst_sink_qa_impl.h | 51 ---------- lib/qa_utils/burst_source_impl.cc | 162 +++++++++++++++++++++++++++++++ lib/qa_utils/burst_source_impl.h | 61 ++++++++++++ lib/qa_utils/burst_source_qa_impl.cc | 162 ------------------------------- lib/qa_utils/burst_source_qa_impl.h | 61 ------------ python/qa_decryption.py | 16 +-- swig/grgsm_swig.i | 12 +-- 21 files changed, 575 insertions(+), 575 deletions(-) create mode 100644 grc/qa_utils/gsm_burst_sink.xml delete mode 100644 grc/qa_utils/gsm_burst_sink_qa.xml create mode 100644 grc/qa_utils/gsm_burst_source.xml delete mode 100644 grc/qa_utils/gsm_burst_source_qa.xml create mode 100644 include/grgsm/qa_utils/burst_sink.h delete mode 100644 include/grgsm/qa_utils/burst_sink_qa.h create mode 100644 include/grgsm/qa_utils/burst_source.h delete mode 100644 include/grgsm/qa_utils/burst_source_qa.h create mode 100644 lib/qa_utils/burst_sink_impl.cc create mode 100644 lib/qa_utils/burst_sink_impl.h delete mode 100644 lib/qa_utils/burst_sink_qa_impl.cc delete mode 100644 lib/qa_utils/burst_sink_qa_impl.h create mode 100644 lib/qa_utils/burst_source_impl.cc create mode 100644 lib/qa_utils/burst_source_impl.h delete mode 100644 lib/qa_utils/burst_source_qa_impl.cc delete mode 100644 lib/qa_utils/burst_source_qa_impl.h diff --git a/grc/qa_utils/CMakeLists.txt b/grc/qa_utils/CMakeLists.txt index 43398d4..1f57aa1 100644 --- a/grc/qa_utils/CMakeLists.txt +++ b/grc/qa_utils/CMakeLists.txt @@ -18,8 +18,8 @@ # Boston, MA 02110-1301, USA. install(FILES - gsm_burst_source_qa.xml - gsm_burst_sink_qa.xml + gsm_burst_source.xml + gsm_burst_sink.xml gsm_message_source.xml gsm_message_sink.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/qa_utils/gsm_burst_sink.xml b/grc/qa_utils/gsm_burst_sink.xml new file mode 100644 index 0000000..740960f --- /dev/null +++ b/grc/qa_utils/gsm_burst_sink.xml @@ -0,0 +1,12 @@ + + + Burst sink + gsm_burst_sink + import grgsm + grgsm.burst_sink() + + + in + message + + diff --git a/grc/qa_utils/gsm_burst_sink_qa.xml b/grc/qa_utils/gsm_burst_sink_qa.xml deleted file mode 100644 index c028da3..0000000 --- a/grc/qa_utils/gsm_burst_sink_qa.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - QA Burst sink - gsm_burst_sink_qa - import grgsm - grgsm.burst_sink_qa() - - - in - message - - diff --git a/grc/qa_utils/gsm_burst_source.xml b/grc/qa_utils/gsm_burst_source.xml new file mode 100644 index 0000000..9f55ac5 --- /dev/null +++ b/grc/qa_utils/gsm_burst_source.xml @@ -0,0 +1,35 @@ + + + Burst source + gsm_burst_source + import grgsm + grgsm.burst_source($framenumbers, $timeslots, $bursts) + + + Frame numbers + framenumbers + [] + int_vector + part + + + + Timeslots + timeslots + [] + int_vector + part + + + + Bursts + bursts + [[],] + raw + + + + out + message + + diff --git a/grc/qa_utils/gsm_burst_source_qa.xml b/grc/qa_utils/gsm_burst_source_qa.xml deleted file mode 100644 index bb04cca..0000000 --- a/grc/qa_utils/gsm_burst_source_qa.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - QA Burst source - gsm_burst_source_qa - import grgsm - grgsm.burst_source_qa($framenumbers, $timeslots, $bursts) - - - Frame numbers - framenumbers - [] - int_vector - part - - - - Timeslots - timeslots - [] - int_vector - part - - - - Bursts - bursts - [[],] - raw - - - - out - message - - diff --git a/include/grgsm/qa_utils/CMakeLists.txt b/include/grgsm/qa_utils/CMakeLists.txt index e0b5579..44bbbfb 100644 --- a/include/grgsm/qa_utils/CMakeLists.txt +++ b/include/grgsm/qa_utils/CMakeLists.txt @@ -21,8 +21,8 @@ # Install public header files ######################################################################## install(FILES - burst_sink_qa.h - burst_source_qa.h + burst_sink.h + burst_source.h message_source.h message_sink.h DESTINATION include/grgsm/qa_utils ) diff --git a/include/grgsm/qa_utils/burst_sink.h b/include/grgsm/qa_utils/burst_sink.h new file mode 100644 index 0000000..266cbc8 --- /dev/null +++ b/include/grgsm/qa_utils/burst_sink.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_SINK_H +#define INCLUDED_GSM_BURST_SINK_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API burst_sink : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::burst_sink. + * + * To avoid accidental use of raw pointers, grgsm::burst_sink's + * constructor is in a private implementation + * class. grgsm::burst_sink::make is the public interface for + * creating new instances. + */ + static sptr make(); + + virtual std::vector get_framenumbers() = 0; + virtual std::vector get_timeslots() = 0; + virtual std::vector get_burst_data() = 0; + }; + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_SINK_H */ + diff --git a/include/grgsm/qa_utils/burst_sink_qa.h b/include/grgsm/qa_utils/burst_sink_qa.h deleted file mode 100644 index 3b5cac2..0000000 --- a/include/grgsm/qa_utils/burst_sink_qa.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SINK_QA_H -#define INCLUDED_GSM_BURST_SINK_QA_H - -#include -#include - -namespace gr { - namespace gsm { - - /*! - * \brief <+description of block+> - * \ingroup gsm - * - */ - class GSM_API burst_sink_qa : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of grgsm::burst_sink_qa. - * - * To avoid accidental use of raw pointers, grgsm::burst_sink_qa's - * constructor is in a private implementation - * class. grgsm::burst_sink_qa::make is the public interface for - * creating new instances. - */ - static sptr make(); - - virtual std::vector get_framenumbers() = 0; - virtual std::vector get_timeslots() = 0; - virtual std::vector get_burst_data() = 0; - }; - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SINK_QA_H */ - diff --git a/include/grgsm/qa_utils/burst_source.h b/include/grgsm/qa_utils/burst_source.h new file mode 100644 index 0000000..bfed70f --- /dev/null +++ b/include/grgsm/qa_utils/burst_source.h @@ -0,0 +1,64 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_SOURCE_H +#define INCLUDED_GSM_BURST_SOURCE_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API burst_source : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::burst_source. + * + * To avoid accidental use of raw pointers, grgsm::burst_source's + * constructor is in a private implementation + * class. grgsm::burst_source::make is the public interface for + * creating new instances. + */ + static sptr make(const std::vector &framenumbers, + const std::vector ×lots, + const std::vector &burst_data); + + virtual void set_framenumbers(const std::vector &framenumbers) = 0; + virtual void set_timeslots(const std::vector ×lots) = 0; + virtual void set_burst_data(const std::vector &burst_data) = 0; + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_SOURCE_H */ + + diff --git a/include/grgsm/qa_utils/burst_source_qa.h b/include/grgsm/qa_utils/burst_source_qa.h deleted file mode 100644 index c3c5713..0000000 --- a/include/grgsm/qa_utils/burst_source_qa.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SOURCE_QA_H -#define INCLUDED_GSM_BURST_SOURCE_QA_H - -#include -#include - -namespace gr { - namespace gsm { - - /*! - * \brief <+description of block+> - * \ingroup gsm - * - */ - class GSM_API burst_source_qa : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of grgsm::burst_source_qa. - * - * To avoid accidental use of raw pointers, grgsm::burst_source_qa's - * constructor is in a private implementation - * class. grgsm::burst_source_qa::make is the public interface for - * creating new instances. - */ - static sptr make(const std::vector &framenumbers, - const std::vector ×lots, - const std::vector &burst_data); - - virtual void set_framenumbers(const std::vector &framenumbers) = 0; - virtual void set_timeslots(const std::vector ×lots) = 0; - virtual void set_burst_data(const std::vector &burst_data) = 0; - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SOURCE_QA_H */ - - diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a3a3388..c9a39ce 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -52,8 +52,8 @@ list(APPEND grgsm_sources misc_utils/tmsi_dumper_impl.cc misc_utils/burst_file_sink_impl.cc misc_utils/burst_file_source_impl.cc - qa_utils/burst_sink_qa_impl.cc - qa_utils/burst_source_qa_impl.cc + qa_utils/burst_sink_impl.cc + qa_utils/burst_source_impl.cc qa_utils/message_source_impl.cc qa_utils/message_sink_impl.cc decryption/decryption_impl.cc diff --git a/lib/qa_utils/burst_sink_impl.cc b/lib/qa_utils/burst_sink_impl.cc new file mode 100644 index 0000000..de26d39 --- /dev/null +++ b/lib/qa_utils/burst_sink_impl.cc @@ -0,0 +1,110 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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 "burst_sink_impl.h" +#include +#include +#include + +namespace gr { + namespace gsm { + + burst_sink::sptr + burst_sink::make() + { + return gnuradio::get_initial_sptr + (new burst_sink_impl()); + } + + /* + * The private constructor + */ + burst_sink_impl::burst_sink_impl() + : gr::block("burst_sink", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)) + { + message_port_register_in(pmt::mp("in")); + set_msg_handler(pmt::mp("in"), boost::bind(&burst_sink_impl::process_burst, this, _1)); + } + + /* + * Our virtual destructor. + */ + burst_sink_impl::~burst_sink_impl() + { +// for (int i=0; iframe_number); + + std::stringstream burst_str; + for(int i=0; i(burst[i]) == 0) + { + burst_str << "0"; + } + else + { + burst_str << "1"; + } + } + + d_framenumbers.push_back(frame_nr); + d_timeslots.push_back(header->timeslot); + d_burst_data.push_back(burst_str.str()); + } + + std::vector burst_sink_impl::get_framenumbers() + { + return d_framenumbers; + } + + std::vector burst_sink_impl::get_timeslots() + { + return d_timeslots; + } + + std::vector burst_sink_impl::get_burst_data() + { + return d_burst_data; + } + + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/qa_utils/burst_sink_impl.h b/lib/qa_utils/burst_sink_impl.h new file mode 100644 index 0000000..42e1e4a --- /dev/null +++ b/lib/qa_utils/burst_sink_impl.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_SINK_IMPL_H +#define INCLUDED_GSM_BURST_SINK_IMPL_H + +#include +#include + +namespace gr { + namespace gsm { + + class burst_sink_impl : public burst_sink + { + private: + std::vector d_framenumbers; + std::vector d_timeslots; + std::vector d_burst_data; + public: + burst_sink_impl(); + ~burst_sink_impl(); + void process_burst(pmt::pmt_t msg); + virtual std::vector get_framenumbers(); + virtual std::vector get_timeslots(); + virtual std::vector get_burst_data(); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_SINK_IMPL_H */ + diff --git a/lib/qa_utils/burst_sink_qa_impl.cc b/lib/qa_utils/burst_sink_qa_impl.cc deleted file mode 100644 index aa9df9d..0000000 --- a/lib/qa_utils/burst_sink_qa_impl.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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 "burst_sink_qa_impl.h" -#include -#include -#include - -namespace gr { - namespace gsm { - - burst_sink_qa::sptr - burst_sink_qa::make() - { - return gnuradio::get_initial_sptr - (new burst_sink_qa_impl()); - } - - /* - * The private constructor - */ - burst_sink_qa_impl::burst_sink_qa_impl() - : gr::block("burst_sink_qa", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)) - { - message_port_register_in(pmt::mp("in")); - set_msg_handler(pmt::mp("in"), boost::bind(&burst_sink_qa_impl::process_burst, this, _1)); - } - - /* - * Our virtual destructor. - */ - burst_sink_qa_impl::~burst_sink_qa_impl() - { -// for (int i=0; iframe_number); - - std::stringstream burst_str; - for(int i=0; i(burst[i]) == 0) - { - burst_str << "0"; - } - else - { - burst_str << "1"; - } - } - - d_framenumbers.push_back(frame_nr); - d_timeslots.push_back(header->timeslot); - d_burst_data.push_back(burst_str.str()); - } - - std::vector burst_sink_qa_impl::get_framenumbers() - { - return d_framenumbers; - } - - std::vector burst_sink_qa_impl::get_timeslots() - { - return d_timeslots; - } - - std::vector burst_sink_qa_impl::get_burst_data() - { - return d_burst_data; - } - - } /* namespace gsm */ -} /* namespace gr */ - diff --git a/lib/qa_utils/burst_sink_qa_impl.h b/lib/qa_utils/burst_sink_qa_impl.h deleted file mode 100644 index 4bd3825..0000000 --- a/lib/qa_utils/burst_sink_qa_impl.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SINK_QA_IMPL_H -#define INCLUDED_GSM_BURST_SINK_QA_IMPL_H - -#include -#include - -namespace gr { - namespace gsm { - - class burst_sink_qa_impl : public burst_sink_qa - { - private: - std::vector d_framenumbers; - std::vector d_timeslots; - std::vector d_burst_data; - public: - burst_sink_qa_impl(); - ~burst_sink_qa_impl(); - void process_burst(pmt::pmt_t msg); - virtual std::vector get_framenumbers(); - virtual std::vector get_timeslots(); - virtual std::vector get_burst_data(); - }; - - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SINK_QA_IMPL_H */ - diff --git a/lib/qa_utils/burst_source_impl.cc b/lib/qa_utils/burst_source_impl.cc new file mode 100644 index 0000000..7391872 --- /dev/null +++ b/lib/qa_utils/burst_source_impl.cc @@ -0,0 +1,162 @@ +/* -*- c++ -*- */ +/* @file + * @author Roman Khassraf + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; 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 "burst_source_impl.h" +#include "stdio.h" +#include +#include +#include + +#define PMT_SIZE 174 + +namespace gr { + namespace gsm { + + burst_source::sptr + burst_source::make(const std::vector &framenumbers, + const std::vector ×lots, + const std::vector &burst_data) + { + return gnuradio::get_initial_sptr + (new burst_source_impl(framenumbers, timeslots, burst_data)); + } + + /* + * The private constructor + */ + burst_source_impl::burst_source_impl(const std::vector &framenumbers, + const std::vector ×lots, + const std::vector &burst_data) + : gr::block("burst_source", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)), + d_finished(false) + { + message_port_register_out(pmt::mp("out")); + set_framenumbers(framenumbers); + set_timeslots(timeslots); + set_burst_data(burst_data); + } + + /* + * Our virtual destructor. + */ + burst_source_impl::~burst_source_impl() + { + if (d_finished == false){ + d_finished = true; + } + } + + void burst_source_impl::set_framenumbers(const std::vector &framenumbers) + { + d_framenumbers = framenumbers; + } + + void burst_source_impl::set_timeslots(const std::vector ×lots) + { + d_timeslots = timeslots; + } + + void burst_source_impl::set_burst_data(const std::vector &burst_data) + { + d_burst_data = burst_data; + } + + bool burst_source_impl::start() + { + d_finished = false; + d_thread = boost::shared_ptr + (new gr::thread::thread(boost::bind(&burst_source_impl::run, this))); + return block::start(); + } + + bool burst_source_impl::stop() + { + d_finished = true; + d_thread->interrupt(); + d_thread->join(); + return block::stop(); + } + + bool burst_source_impl::finished() + { + return d_finished; + } + + void burst_source_impl::run() + { + char *unserialized = (char*)malloc(sizeof(char) * PMT_SIZE); + + for (int i=0; i= 0 && d_timeslots[i] <= 7 && + d_framenumbers[i] >= 0 && d_framenumbers[i] <= (26 * 51 * 2048 - 1)) + { + boost::scoped_ptr tap_header(new gsmtap_hdr()); + + tap_header->version = GSMTAP_VERSION; + tap_header->hdr_len = sizeof(gsmtap_hdr)/4; + tap_header->type = GSMTAP_TYPE_UM_BURST; + tap_header->timeslot = d_timeslots[i]; + tap_header->frame_number = htobe32(d_framenumbers[i]); + tap_header->sub_type = GSMTAP_BURST_NORMAL; + tap_header->arfcn = 0; + tap_header->signal_dbm = 0; + tap_header->snr_db = 0; + + uint8_t burst[BURST_SIZE]; + + for (int j=0; j + * @section LICENSE + * + * Gr-gsm 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. + * + * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INCLUDED_GSM_BURST_SOURCE_IMPL_H +#define INCLUDED_GSM_BURST_SOURCE_IMPL_H + +#define BURST_SIZE 148 + +#include +#include + + +namespace gr { + namespace gsm { + + class burst_source_impl : public burst_source + { + private: + boost::shared_ptr d_thread; + std::vector d_framenumbers; + std::vector d_timeslots; + std::vector d_burst_data; + bool d_finished; + void run(); + public: + burst_source_impl(const std::vector &framenumbers, + const std::vector ×lots, + const std::vector &burst_data); + ~burst_source_impl(); + virtual void set_framenumbers(const std::vector &framenumbers); + virtual void set_timeslots(const std::vector ×lots); + virtual void set_burst_data(const std::vector &burst_data); + bool start(); + bool stop(); + bool finished(); + }; + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_BURST_SOURCE_IMPL_H */ + + diff --git a/lib/qa_utils/burst_source_qa_impl.cc b/lib/qa_utils/burst_source_qa_impl.cc deleted file mode 100644 index 7b2d412..0000000 --- a/lib/qa_utils/burst_source_qa_impl.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- c++ -*- */ -/* @file - * @author Roman Khassraf - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; 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 "burst_source_qa_impl.h" -#include "stdio.h" -#include -#include -#include - -#define PMT_SIZE 174 - -namespace gr { - namespace gsm { - - burst_source_qa::sptr - burst_source_qa::make(const std::vector &framenumbers, - const std::vector ×lots, - const std::vector &burst_data) - { - return gnuradio::get_initial_sptr - (new burst_source_qa_impl(framenumbers, timeslots, burst_data)); - } - - /* - * The private constructor - */ - burst_source_qa_impl::burst_source_qa_impl(const std::vector &framenumbers, - const std::vector ×lots, - const std::vector &burst_data) - : gr::block("burst_source_qa", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)), - d_finished(false) - { - message_port_register_out(pmt::mp("out")); - set_framenumbers(framenumbers); - set_timeslots(timeslots); - set_burst_data(burst_data); - } - - /* - * Our virtual destructor. - */ - burst_source_qa_impl::~burst_source_qa_impl() - { - if (d_finished == false){ - d_finished = true; - } - } - - void burst_source_qa_impl::set_framenumbers(const std::vector &framenumbers) - { - d_framenumbers = framenumbers; - } - - void burst_source_qa_impl::set_timeslots(const std::vector ×lots) - { - d_timeslots = timeslots; - } - - void burst_source_qa_impl::set_burst_data(const std::vector &burst_data) - { - d_burst_data = burst_data; - } - - bool burst_source_qa_impl::start() - { - d_finished = false; - d_thread = boost::shared_ptr - (new gr::thread::thread(boost::bind(&burst_source_qa_impl::run, this))); - return block::start(); - } - - bool burst_source_qa_impl::stop() - { - d_finished = true; - d_thread->interrupt(); - d_thread->join(); - return block::stop(); - } - - bool burst_source_qa_impl::finished() - { - return d_finished; - } - - void burst_source_qa_impl::run() - { - char *unserialized = (char*)malloc(sizeof(char) * PMT_SIZE); - - for (int i=0; i= 0 && d_timeslots[i] <= 7 && - d_framenumbers[i] >= 0 && d_framenumbers[i] <= (26 * 51 * 2048 - 1)) - { - boost::scoped_ptr tap_header(new gsmtap_hdr()); - - tap_header->version = GSMTAP_VERSION; - tap_header->hdr_len = sizeof(gsmtap_hdr)/4; - tap_header->type = GSMTAP_TYPE_UM_BURST; - tap_header->timeslot = d_timeslots[i]; - tap_header->frame_number = htobe32(d_framenumbers[i]); - tap_header->sub_type = GSMTAP_BURST_NORMAL; - tap_header->arfcn = 0; - tap_header->signal_dbm = 0; - tap_header->snr_db = 0; - - uint8_t burst[BURST_SIZE]; - - for (int j=0; j - * @section LICENSE - * - * Gr-gsm 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. - * - * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H -#define INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H - -#define BURST_SIZE 148 - -#include -#include - - -namespace gr { - namespace gsm { - - class burst_source_qa_impl : public burst_source_qa - { - private: - boost::shared_ptr d_thread; - std::vector d_framenumbers; - std::vector d_timeslots; - std::vector d_burst_data; - bool d_finished; - void run(); - public: - burst_source_qa_impl(const std::vector &framenumbers, - const std::vector ×lots, - const std::vector &burst_data); - ~burst_source_qa_impl(); - virtual void set_framenumbers(const std::vector &framenumbers); - virtual void set_timeslots(const std::vector ×lots); - virtual void set_burst_data(const std::vector &burst_data); - bool start(); - bool stop(); - bool finished(); - }; - } // namespace gsm -} // namespace gr - -#endif /* INCLUDED_GSM_BURST_SOURCE_QA_IMPL_H */ - - diff --git a/python/qa_decryption.py b/python/qa_decryption.py index cf228ae..08f0915 100755 --- a/python/qa_decryption.py +++ b/python/qa_decryption.py @@ -56,9 +56,9 @@ class qa_decryption (gr_unittest.TestCase): key = [0x32,0xE5,0x45,0x53,0x20,0x8C,0xE0,0x00] a5_version = 1 - src = grgsm.burst_source_qa(framenumbers_input, timeslots_input, bursts_input) + src = grgsm.burst_source(framenumbers_input, timeslots_input, bursts_input) decryption = grgsm.decryption((key), a5_version) - dst = grgsm.burst_sink_qa() + dst = grgsm.burst_sink() self.tb.msg_connect(src, "out", decryption, "bursts") self.tb.msg_connect(decryption, "bursts", dst, "in") @@ -97,9 +97,9 @@ class qa_decryption (gr_unittest.TestCase): key = [0xAD,0x6A,0x3E,0xC2,0xB4,0x42,0xE4,0x00] a5_version = 1 - src = grgsm.burst_source_qa(framenumbers_input, timeslots_input, bursts_input) + src = grgsm.burst_source(framenumbers_input, timeslots_input, bursts_input) decryption = grgsm.decryption((key), a5_version) - dst = grgsm.burst_sink_qa() + dst = grgsm.burst_sink() self.tb.msg_connect(src, "out", decryption, "bursts") self.tb.msg_connect(decryption, "bursts", dst, "in") @@ -138,9 +138,9 @@ class qa_decryption (gr_unittest.TestCase): key = [0x41,0xBC,0x19,0x30,0xB6,0x31,0x8A,0xC8] a5_version = 3 - src = grgsm.burst_source_qa(framenumbers_input, timeslots_input, bursts_input) + src = grgsm.burst_source(framenumbers_input, timeslots_input, bursts_input) decryption = grgsm.decryption((key), a5_version) - dst = grgsm.burst_sink_qa() + dst = grgsm.burst_sink() self.tb.msg_connect(src, "out", decryption, "bursts") self.tb.msg_connect(decryption, "bursts", dst, "in") @@ -179,9 +179,9 @@ class qa_decryption (gr_unittest.TestCase): key = [0xAD,0x2C,0xB3,0x83,0x2F,0x4A,0x6C,0xF1] a5_version = 3 - src = grgsm.burst_source_qa(framenumbers_input, timeslots_input, bursts_input) + src = grgsm.burst_source(framenumbers_input, timeslots_input, bursts_input) decryption = grgsm.decryption((key), a5_version) - dst = grgsm.burst_sink_qa() + dst = grgsm.burst_sink() self.tb.msg_connect(src, "out", decryption, "bursts") self.tb.msg_connect(decryption, "bursts", dst, "in") diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i index fbc4151..36a4415 100644 --- a/swig/grgsm_swig.i +++ b/swig/grgsm_swig.i @@ -25,8 +25,8 @@ #include "grgsm/misc_utils/tmsi_dumper.h" #include "grgsm/misc_utils/burst_file_sink.h" #include "grgsm/misc_utils/burst_file_source.h" -#include "grgsm/qa_utils/burst_sink_qa.h" -#include "grgsm/qa_utils/burst_source_qa.h" +#include "grgsm/qa_utils/burst_sink.h" +#include "grgsm/qa_utils/burst_source.h" #include "grgsm/qa_utils/message_source.h" #include "grgsm/qa_utils/message_sink.h" %} @@ -71,10 +71,10 @@ GR_SWIG_BLOCK_MAGIC2(gsm, message_printer); %include "grgsm/misc_utils/tmsi_dumper.h" GR_SWIG_BLOCK_MAGIC2(gsm, tmsi_dumper); -%include "grgsm/qa_utils/burst_sink_qa.h" -GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink_qa); -%include "grgsm/qa_utils/burst_source_qa.h" -GR_SWIG_BLOCK_MAGIC2(gsm, burst_source_qa); +%include "grgsm/qa_utils/burst_sink.h" +GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink); +%include "grgsm/qa_utils/burst_source.h" +GR_SWIG_BLOCK_MAGIC2(gsm, burst_source); %include "grgsm/qa_utils/message_source.h" GR_SWIG_BLOCK_MAGIC2(gsm, message_source); %include "grgsm/qa_utils/message_sink.h" -- cgit v1.2.3