Refactor the 'TRX Burst Interface' block

The following changes were made:

  - Both implementation and headers were merged with misc_utils
  - Fixed namespace mess: was gr::grgsm, became gr::gsm
  - More accurate class name was chosen: "trx_burst_if"
This commit is contained in:
Vadim Yanitskiy 2017-10-17 08:24:25 +07:00 committed by Piotr Krysik
parent ba7ad29638
commit e601c366bd
15 changed files with 44 additions and 86 deletions

View File

@ -23,7 +23,6 @@ add_subdirectory(demapping)
add_subdirectory(receiver)
add_subdirectory(flow_control)
add_subdirectory(misc_utils)
add_subdirectory(trx_interface)
add_subdirectory(transmitter)
install(FILES
gsm_block_tree.xml DESTINATION share/gnuradio/grc/blocks

View File

@ -31,6 +31,7 @@ install(FILES
gsm_burst_file_source.xml
gsm_message_file_sink.xml
gsm_message_file_source.xml
gsm_trx_burst_if.xml
gsm_msg_to_tag.xml
gsm_controlled_fractional_resampler_cc.xml DESTINATION share/gnuradio/grc/blocks
)

View File

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<block>
<name>TRX Interface</name>
<key>grgsm_trx_interface</key>
<name>TRX Burst Interface</name>
<key>grgsm_trx_burst_if</key>
<import>import grgsm</import>
<make>grgsm.trx($remote_addr, $base_port)</make>
<make>grgsm.trx_burst_if($remote_addr, $base_port)</make>
<param>
<name>base_port</name>

View File

@ -1,22 +0,0 @@
# 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_trx.xml DESTINATION share/gnuradio/grc/blocks
)

View File

@ -36,4 +36,3 @@ add_subdirectory(misc_utils)
add_subdirectory(qa_utils)
add_subdirectory(flow_control)
add_subdirectory(transmitter)
add_subdirectory(trx_interface)

View File

@ -34,6 +34,7 @@ install(FILES
message_printer.h
tmsi_dumper.h
msg_to_tag.h
trx_burst_if.h
controlled_fractional_resampler_cc.h
time_spec.h
fn_time.h DESTINATION include/grgsm/misc_utils

View File

@ -20,8 +20,8 @@
*
*/
#ifndef INCLUDED_GRGSM_TRX_H
#define INCLUDED_GRGSM_TRX_H
#ifndef INCLUDED_GRGSM_TRX_BURST_IF_H
#define INCLUDED_GRGSM_TRX_BURST_IF_H
#include <grgsm/api.h>
#include <gnuradio/sync_block.h>
@ -34,17 +34,17 @@ namespace gr {
* \ingroup grgsm
*
*/
class GRGSM_API trx : virtual public gr::block
class GRGSM_API trx_burst_if : virtual public gr::block
{
public:
typedef boost::shared_ptr<trx> sptr;
typedef boost::shared_ptr<trx_burst_if> sptr;
/*!
* \brief Return a shared_ptr to a new instance of grgsm::trx.
* \brief Return a shared_ptr to a new instance of grgsm::trx_burst_if.
*
* To avoid accidental use of raw pointers, grgsm::trx's
* To avoid accidental use of raw pointers, grgsm::trx_burst_if's
* constructor is in a private implementation
* class. grgsm::trx::make is the public interface for
* class. grgsm::trx_burst_if::make is the public interface for
* creating new instances.
*/
static sptr make(
@ -59,5 +59,5 @@ namespace gr {
} // namespace gsm
} // namespace gr
#endif /* INCLUDED_GRGSM_TRX_H */
#endif /* INCLUDED_GRGSM_TRX_BURST_IF_H */

View File

@ -71,7 +71,6 @@ add_subdirectory(misc_utils)
add_subdirectory(qa_utils)
add_subdirectory(receiver)
add_subdirectory(transmitter)
add_subdirectory(trx_interface)
########################################################################
# Setup library

View File

@ -34,5 +34,7 @@ add_sources(
tmsi_dumper_impl.cc
time_spec.cc
fn_time.cc
udp_socket.cc
trx_burst_if_impl.cc
)

View File

@ -28,7 +28,7 @@
#include <boost/lexical_cast.hpp>
#include "udp_socket.h"
#include "trx_impl.h"
#include "trx_burst_if_impl.h"
#define BURST_SIZE 148
#define DATA_IF_MTU 160
@ -46,22 +46,24 @@ static uint8_t rach_synch_seq[] = {
namespace gr {
namespace gsm {
trx::sptr
trx::make(
trx_burst_if::sptr
trx_burst_if::make(
const std::string &remote_addr,
const std::string &base_port)
{
int base_port_int = boost::lexical_cast<int> (base_port);
return gnuradio::get_initial_sptr
(new trx_impl(remote_addr, base_port_int));
(new trx_burst_if_impl(remote_addr, base_port_int));
}
/*
* The private constructor
*/
trx_impl::trx_impl(const std::string &remote_addr, int base_port)
: gr::block("trx",
trx_burst_if_impl::trx_burst_if_impl(
const std::string &remote_addr,
int base_port
) : gr::block("trx_burst_if",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0))
{
@ -70,7 +72,7 @@ namespace gr {
// Bind a port handler
set_msg_handler(pmt::mp("bursts"),
boost::bind(&trx_impl::handle_dl_burst, this, _1));
boost::bind(&trx_burst_if_impl::handle_dl_burst, this, _1));
// Prepare port numbers
std::string clck_src_port = boost::lexical_cast<std::string> (base_port + 0);
@ -86,7 +88,7 @@ namespace gr {
// Bind DATA interface handler
d_data_sock->udp_rx_handler = boost::bind(
&trx_impl::handle_ul_burst, this, _1, _2);
&trx_burst_if_impl::handle_ul_burst, this, _1, _2);
// Init timeslot filter
d_ts_filter_tn = -1;
@ -95,7 +97,7 @@ namespace gr {
/*
* Our virtual destructor.
*/
trx_impl::~trx_impl()
trx_burst_if_impl::~trx_burst_if_impl()
{
// Release all UDP sockets and free memory
delete d_data_sock;
@ -106,13 +108,13 @@ namespace gr {
* Timeslot filter API (getter and setter)
*/
void
trx_impl::ts_filter_set_tn(int tn)
trx_burst_if_impl::ts_filter_set_tn(int tn)
{
d_ts_filter_tn = (tn >= 0 && tn <= 7) ? tn : -1;
}
int
trx_impl::ts_filter_get_tn(void)
trx_burst_if_impl::ts_filter_get_tn(void)
{
return d_ts_filter_tn;
}
@ -120,7 +122,7 @@ namespace gr {
/*
* Check if burst is a RACH burst
*/
bool trx_impl::detect_rach(uint8_t *burst)
bool trx_burst_if_impl::detect_rach(uint8_t *burst)
{
// Compare synchronization sequence
for (int i = 0; i < 41; i++)
@ -139,7 +141,7 @@ namespace gr {
* Create an UDP payload with clock indication
*/
void
trx_impl::clck_ind_send(uint32_t frame_nr)
trx_burst_if_impl::clck_ind_send(uint32_t frame_nr)
{
char buf[20];
size_t n;
@ -153,7 +155,7 @@ namespace gr {
* and some channel data.
*/
void
trx_impl::burst_pack(pmt::pmt_t msg, uint8_t *buf)
trx_burst_if_impl::burst_pack(pmt::pmt_t msg, uint8_t *buf)
{
pmt::pmt_t header_plus_burst = pmt::cdr(msg);
@ -200,7 +202,7 @@ namespace gr {
}
void
trx_impl::handle_dl_burst(pmt::pmt_t msg)
trx_burst_if_impl::handle_dl_burst(pmt::pmt_t msg)
{
// 8 bytes of header + 148 bytes of burst
// + two unused, but required bytes
@ -219,7 +221,7 @@ namespace gr {
}
void
trx_impl::handle_ul_burst(uint8_t *payload, size_t len)
trx_burst_if_impl::handle_ul_burst(uint8_t *payload, size_t len)
{
// Check length according to the protocol
if (len != 154)

View File

@ -20,18 +20,18 @@
*
*/
#ifndef INCLUDED_GRGSM_TRX_IMPL_H
#define INCLUDED_GRGSM_TRX_IMPL_H
#ifndef INCLUDED_GRGSM_TRX_BURST_IF_IMPL_H
#define INCLUDED_GRGSM_TRX_BURST_IF_IMPL_H
#include <stddef.h>
#include <grgsm/gsmtap.h>
#include <grgsm/trx_interface/trx.h>
#include <grgsm/misc_utils/trx_burst_if.h>
namespace gr {
namespace gsm {
class trx_impl : public trx
class trx_burst_if_impl : public trx_burst_if
{
private:
udp_socket *d_data_sock;
@ -43,8 +43,8 @@ namespace gr {
void burst_pack(pmt::pmt_t msg, uint8_t *buf);
public:
trx_impl(const std::string &remote_addr, int base_port);
~trx_impl();
trx_burst_if_impl(const std::string &remote_addr, int base_port);
~trx_burst_if_impl();
/* Timeslot filter API */
void ts_filter_set_tn(int tn);
@ -57,5 +57,5 @@ namespace gr {
} // namespace gsm
} // namespace gr
#endif /* INCLUDED_GRGSM_TRX_IMPL_H */
#endif /* INCLUDED_GRGSM_TRX_BURST_IF_IMPL_H */

View File

@ -1,23 +0,0 @@
# 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.
add_sources(
trx_impl.cc
udp_socket.cc
)

View File

@ -67,10 +67,10 @@
#include "grgsm/misc_utils/message_file_source.h"
#include "grgsm/misc_utils/msg_to_tag.h"
#include "grgsm/misc_utils/controlled_fractional_resampler_cc.h"
#include "grgsm/trx_interface/trx.h"
//#include "grgsm/misc_utils/time_spec.h"
#include "grgsm/misc_utils/fn_time.h"
#include "grgsm/transmitter/txtime_setter.h"
#include "grgsm/misc_utils/trx_burst_if.h"
%}
%include "constants.i"
@ -140,6 +140,8 @@ 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"
@ -150,8 +152,6 @@ 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/trx_interface/trx.h"
GR_SWIG_BLOCK_MAGIC2(gsm, trx);
//#pragma SWIG nowarn=319
//%include "grgsm/misc_utils/time_spec.h"