diff --git a/grc/gsm_block_tree.xml b/grc/gsm_block_tree.xml index 89319c8..219702a 100644 --- a/grc/gsm_block_tree.xml +++ b/grc/gsm_block_tree.xml @@ -27,6 +27,7 @@ gsm_txtime_setter gsm_gmsk_mod gsm_preprocess_tx_burst + gsm_gen_test_ab Logical channels demapping diff --git a/grc/transmitter/CMakeLists.txt b/grc/transmitter/CMakeLists.txt index 76d079e..4df2abb 100644 --- a/grc/transmitter/CMakeLists.txt +++ b/grc/transmitter/CMakeLists.txt @@ -19,7 +19,9 @@ install(FILES gsm_gmsk_mod.xml - gsm_txtime_bursts_tagger.xml - gsm_txtime_setter.xml - gsm_preprocess_tx_burst.xml DESTINATION share/gnuradio/grc/blocks + gsm_txtime_bursts_tagger.xml + gsm_txtime_setter.xml + gsm_preprocess_tx_burst.xml + gsm_gen_test_ab.xml + DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/transmitter/gsm_gen_test_ab.xml b/grc/transmitter/gsm_gen_test_ab.xml new file mode 100644 index 0000000..3cb8b11 --- /dev/null +++ b/grc/transmitter/gsm_gen_test_ab.xml @@ -0,0 +1,19 @@ + + + Gen Test AB + gsm_gen_test_ab + import grgsm + grgsm.gen_test_ab() + + + bursts_in + message + 1 + + + + bursts_out + message + 1 + + diff --git a/include/grgsm/transmitter/CMakeLists.txt b/include/grgsm/transmitter/CMakeLists.txt index 29ccc4b..fab6f7c 100644 --- a/include/grgsm/transmitter/CMakeLists.txt +++ b/include/grgsm/transmitter/CMakeLists.txt @@ -23,5 +23,6 @@ install(FILES txtime_setter.h preprocess_tx_burst.h + gen_test_ab.h DESTINATION include/grgsm/transmitter ) diff --git a/include/grgsm/transmitter/gen_test_ab.h b/include/grgsm/transmitter/gen_test_ab.h new file mode 100644 index 0000000..d2756f1 --- /dev/null +++ b/include/grgsm/transmitter/gen_test_ab.h @@ -0,0 +1,60 @@ +/* -*- 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_GSM_GEN_TEST_AB_H +#define INCLUDED_GSM_GEN_TEST_AB_H + +#include +#include + +namespace gr { + namespace gsm { + + /*! + * \brief A block that does preprocessing tasks before sending bursts to modulator. + * \ingroup gsm + * + * Currently it removes GSMTAP header from a burst and puts it in first part of PDU + * pair and removes tailing zeros from Access Bursts coming from TRX interface. + */ + class GRGSM_API gen_test_ab : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief Return a shared_ptr to a new instance of gsm::gen_test_ab. + * + * To avoid accidental use of raw pointers, gsm::gen_test_ab's + * constructor is in a private implementation + * class. gsm::gen_test_ab::make is the public interface for + * creating new instances. + */ + static sptr make(); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_GEN_TEST_AB_H */ + diff --git a/lib/transmitter/CMakeLists.txt b/lib/transmitter/CMakeLists.txt index c61654a..eb53162 100644 --- a/lib/transmitter/CMakeLists.txt +++ b/lib/transmitter/CMakeLists.txt @@ -20,4 +20,5 @@ add_sources( txtime_setter_impl.cc preprocess_tx_burst_impl.cc + gen_test_ab_impl ) diff --git a/lib/transmitter/gen_test_ab_impl.cc b/lib/transmitter/gen_test_ab_impl.cc new file mode 100644 index 0000000..66873db --- /dev/null +++ b/lib/transmitter/gen_test_ab_impl.cc @@ -0,0 +1,107 @@ +/* -*- 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 +#include "gen_test_ab_impl.h" + +namespace gr { + namespace gsm { + + static uint8_t rach_synch_seq[] = { + 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0 , + 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, + }; + +// static uint8_t AB[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// static uint8_t AB[] = {0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1}; +// static uint8_t AB[] = { 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1}; + static uint8_t AB[] = {1,1,1,1,1,1,1,1,1,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,0,1,0,1,0,1,1,1,0,0,0,0,1,1,1,0,0,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; + gen_test_ab::sptr + gen_test_ab::make() + { + return gnuradio::get_initial_sptr + (new gen_test_ab_impl()); + } + + /* + * The private constructor + */ + gen_test_ab_impl::gen_test_ab_impl() + : gr::block("gen_test_ab", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)) + { + message_port_register_in(pmt::intern("bursts_in")); + message_port_register_out(pmt::intern("bursts_out")); + + set_msg_handler(pmt::intern("bursts_in"), boost::bind(&gen_test_ab_impl::generate_ab, this, _1)); + } + + /* + * Our virtual destructor. + */ + gen_test_ab_impl::~gen_test_ab_impl() + { + } + + void gen_test_ab_impl::generate_ab(pmt::pmt_t burst) + { + uint8_t buf[sizeof(gsmtap_hdr) + 148]; + struct gsmtap_hdr *tap_header = (struct gsmtap_hdr *) buf; + uint8_t *access_burst = buf + sizeof(gsmtap_hdr); + +// memset(access_burst, 0, 8); /* TB */ +// memcpy(access_burst + 8, rach_synch_seq, 41); /* sync seq */ +// memcpy(access_burst + 49, AB, 36); /* payload */ +// memset(access_burst + 85, 0, 63); /* TB + GP */ + + memcpy(access_burst, AB, 148); + + gsmtap_hdr * header = (gsmtap_hdr *)(pmt::blob_data(pmt::cdr(burst))); + uint32_t frame_nr = be32toh(header->frame_number); + frame_nr = (frame_nr+51)% (26*51*2048); + + tap_header->version = GSMTAP_VERSION; + tap_header->hdr_len = sizeof(gsmtap_hdr) / 4; + tap_header->type = GSMTAP_TYPE_UM_BURST; + tap_header->sub_type = GSMTAP_BURST_ACCESS; + tap_header->frame_number = htobe32(frame_nr); + tap_header->timeslot = header->timeslot; + tap_header->arfcn = 0; + + pmt::pmt_t blob = pmt::make_blob(buf, sizeof(gsmtap_hdr) + BURST_SIZE); + pmt::pmt_t pdu_header = pmt::make_dict(); + + pmt::pmt_t new_msg = pmt::cons(pdu_header, blob); + message_port_pub(pmt::intern("bursts_out"), new_msg); + } + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/transmitter/gen_test_ab_impl.h b/lib/transmitter/gen_test_ab_impl.h new file mode 100644 index 0000000..366481e --- /dev/null +++ b/lib/transmitter/gen_test_ab_impl.h @@ -0,0 +1,47 @@ +/* -*- 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_GSM_GEN_TEST_AB_IMPL_H +#define INCLUDED_GSM_GEN_TEST_AB_IMPL_H + +#include +#include +#include + +namespace gr { + namespace gsm { + + class gen_test_ab_impl : public gen_test_ab + { + private: + void generate_ab(pmt::pmt_t burst); + + public: + gen_test_ab_impl(); + ~gen_test_ab_impl(); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_GEN_TEST_AB_IMPL_H */ + diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i index 65c48be..005033f 100644 --- a/swig/grgsm_swig.i +++ b/swig/grgsm_swig.i @@ -1,7 +1,7 @@ /* -*- c++ -*- */ /* * @file - * @author (C) 2014 by Piotr Krysik + * @author (C) 2014-2017 by Piotr Krysik * @section LICENSE * * Gr-gsm is free software; you can redistribute it and/or modify @@ -72,6 +72,7 @@ #include "grgsm/misc_utils/fn_time.h" #include "grgsm/transmitter/txtime_setter.h" #include "grgsm/transmitter/preprocess_tx_burst.h" +#include "grgsm/transmitter/gen_test_ab.h" #include "grgsm/misc_utils/trx_burst_if.h" %} @@ -144,10 +145,6 @@ GR_SWIG_BLOCK_MAGIC2(gsm, msg_to_tag); GR_SWIG_BLOCK_MAGIC2(gsm, controlled_fractional_resampler_cc); %include "grgsm/misc_utils/extract_cmc.h" GR_SWIG_BLOCK_MAGIC2(gsm, extract_cmc); -%include "grgsm/misc_utils/trx_burst_if.h" -GR_SWIG_BLOCK_MAGIC2(gsm, trx_burst_if); - - %include "grgsm/qa_utils/burst_sink.h" GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink); %include "grgsm/qa_utils/burst_source.h" @@ -185,3 +182,9 @@ GR_SWIG_BLOCK_MAGIC2(gsm, message_sink); GR_SWIG_BLOCK_MAGIC2(gsm, txtime_setter); %include "grgsm/transmitter/preprocess_tx_burst.h" GR_SWIG_BLOCK_MAGIC2(gsm, preprocess_tx_burst); + +%include "grgsm/transmitter/gen_test_ab.h" +GR_SWIG_BLOCK_MAGIC2(gsm, gen_test_ab); + +%include "grgsm/misc_utils/trx_burst_if.h" +GR_SWIG_BLOCK_MAGIC2(gsm, trx_burst_if);