From c6eb3b5c6a013d5c19878a584b03c31813f87e77 Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Sun, 29 May 2016 13:06:39 +0200 Subject: Added msg_to_tag block - currently it does nothing --- grc/CMakeLists.txt | 3 +- grc/grgsm_msg_to_tag.xml | 38 +++++++++++++++++++++ include/grgsm/CMakeLists.txt | 2 +- include/grgsm/msg_to_tag.h | 58 ++++++++++++++++++++++++++++++++ lib/CMakeLists.txt | 1 + lib/msg_to_tag_impl.cc | 80 ++++++++++++++++++++++++++++++++++++++++++++ lib/msg_to_tag_impl.h | 50 +++++++++++++++++++++++++++ python/CMakeLists.txt | 1 + python/qa_msg_to_tag.py | 43 ++++++++++++++++++++++++ swig/grgsm_swig.i | 3 ++ 10 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 grc/grgsm_msg_to_tag.xml create mode 100644 include/grgsm/msg_to_tag.h create mode 100644 lib/msg_to_tag_impl.cc create mode 100644 lib/msg_to_tag_impl.h create mode 100755 python/qa_msg_to_tag.py diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 2b94539..47dfc89 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -24,5 +24,6 @@ add_subdirectory(receiver) add_subdirectory(flow_control) add_subdirectory(misc_utils) install(FILES - gsm_block_tree.xml DESTINATION share/gnuradio/grc/blocks + gsm_block_tree.xml + grgsm_msg_to_tag.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/grgsm_msg_to_tag.xml b/grc/grgsm_msg_to_tag.xml new file mode 100644 index 0000000..fab2c6c --- /dev/null +++ b/grc/grgsm_msg_to_tag.xml @@ -0,0 +1,38 @@ + + + msg_to_tag + grgsm_msg_to_tag + grgsm + import grgsm + grgsm.msg_to_tag() + + + ... + ... + ... + + + + + in + + + + + + out + + + diff --git a/include/grgsm/CMakeLists.txt b/include/grgsm/CMakeLists.txt index e9f6cc2..50788ae 100644 --- a/include/grgsm/CMakeLists.txt +++ b/include/grgsm/CMakeLists.txt @@ -24,7 +24,7 @@ install(FILES plotting.hpp api.h gsmtap.h - DESTINATION include/grgsm + msg_to_tag.h DESTINATION include/grgsm ) add_subdirectory(decoding) diff --git a/include/grgsm/msg_to_tag.h b/include/grgsm/msg_to_tag.h new file mode 100644 index 0000000..3d63460 --- /dev/null +++ b/include/grgsm/msg_to_tag.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* @file + * @author Piotr Krysik + * @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_GRGSM_MSG_TO_TAG_H +#define INCLUDED_GRGSM_MSG_TO_TAG_H + +#include +#include + +namespace gr { + namespace grgsm { + + /*! + * \brief <+description of block+> + * \ingroup grgsm + * + */ + class GRGSM_API msg_to_tag : virtual public gr::sync_block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of grgsm::msg_to_tag. + * + * To avoid accidental use of raw pointers, grgsm::msg_to_tag's + * constructor is in a private implementation + * class. grgsm::msg_to_tag::make is the public interface for + * creating new instances. + */ + static sptr make(); + }; + + } // namespace grgsm +} // namespace gr + +#endif /* INCLUDED_GRGSM_MSG_TO_TAG_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 723ecce..3ce05f8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -65,6 +65,7 @@ list(APPEND grgsm_sources qa_utils/message_source_impl.cc qa_utils/message_sink_impl.cc decryption/decryption_impl.cc + msg_to_tag_impl.cc ) diff --git a/lib/msg_to_tag_impl.cc b/lib/msg_to_tag_impl.cc new file mode 100644 index 0000000..eb0fc13 --- /dev/null +++ b/lib/msg_to_tag_impl.cc @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* @file + * @author Piotr Krysik + * @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 +#include "msg_to_tag_impl.h" + +namespace gr { + namespace grgsm { + + msg_to_tag::sptr + msg_to_tag::make() + { + return gnuradio::get_initial_sptr + (new msg_to_tag_impl()); + } + +// void msg_to_tag_impl::queue_msg(pmt::pmt_t msg){ +// +// } + + /* + * The private constructor + */ + msg_to_tag_impl::msg_to_tag_impl() + : gr::sync_block("msg_to_tag", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(gr_complex))) + { + message_port_register_in(pmt::mp("msg")); +// set_msg_handler(pmt::mp("msg"), boost::bind(&msg_to_tag::queue_msg, this, _1)); + } + + /* + * Our virtual destructor. + */ + msg_to_tag_impl::~msg_to_tag_impl() + { + } + + int + msg_to_tag_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + + // Do <+signal processing+> + memcpy(out, in, sizeof(gr_complex)*noutput_items); + // Tell runtime system how many output items we produced. + return noutput_items; + } + + } /* namespace grgsm */ +} /* namespace gr */ + diff --git a/lib/msg_to_tag_impl.h b/lib/msg_to_tag_impl.h new file mode 100644 index 0000000..e761d3e --- /dev/null +++ b/lib/msg_to_tag_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* @file + * @author Piotr Krysik + * @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_GRGSM_MSG_TO_TAG_IMPL_H +#define INCLUDED_GRGSM_MSG_TO_TAG_IMPL_H + +#include + +namespace gr { + namespace grgsm { + + class msg_to_tag_impl : public msg_to_tag + { + private: + // Nothing to declare in this block. + + public: + msg_to_tag_impl(); + ~msg_to_tag_impl(); + + // Where all the action really happens + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace grgsm +} // namespace gr + +#endif /* INCLUDED_GRGSM_MSG_TO_TAG_IMPL_H */ + diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 8fc48de..aa77ff1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -62,3 +62,4 @@ GR_ADD_TEST(qa_burst_sdcch_subslot_filter ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_S GR_ADD_TEST(qa_burst_fnr_filter ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_burst_fnr_filter.py) GR_ADD_TEST(qa_dummy_burst_filter ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_dummy_burst_filter.py) GR_ADD_TEST(qa_arfcn ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_arfcn.py) +GR_ADD_TEST(qa_msg_to_tag ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_msg_to_tag.py) diff --git a/python/qa_msg_to_tag.py b/python/qa_msg_to_tag.py new file mode 100755 index 0000000..eb206b1 --- /dev/null +++ b/python/qa_msg_to_tag.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# @file +# @author Piotr Krysik +# @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 +from gnuradio import blocks +import grgsm_swig as grgsm + +class qa_msg_to_tag (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_t (self): + # set up fg + self.tb.run () + # check data + + +if __name__ == '__main__': + gr_unittest.run(qa_msg_to_tag, "qa_msg_to_tag.xml") diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i index dc2718e..81a5942 100644 --- a/swig/grgsm_swig.i +++ b/swig/grgsm_swig.i @@ -37,6 +37,7 @@ #include "grgsm/qa_utils/message_sink.h" #include "grgsm/misc_utils/message_file_sink.h" #include "grgsm/misc_utils/message_file_source.h" +#include "grgsm/msg_to_tag.h" %} %include "grgsm/receiver/receiver.h" @@ -103,3 +104,5 @@ GR_SWIG_BLOCK_MAGIC2(gsm, burst_source); GR_SWIG_BLOCK_MAGIC2(gsm, message_source); %include "grgsm/qa_utils/message_sink.h" GR_SWIG_BLOCK_MAGIC2(gsm, message_sink); +%include "grgsm/msg_to_tag.h" +GR_SWIG_BLOCK_MAGIC2(grgsm, msg_to_tag); -- cgit v1.2.3