Skip to content

Commit

Permalink
Refactor the 'TRX Burst Interface' block
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
axilirator authored and ptrkrysik committed Nov 5, 2017
1 parent ba7ad29 commit e601c36
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 86 deletions.
1 change: 0 additions & 1 deletion grc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions grc/misc_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
22 changes: 0 additions & 22 deletions grc/trx_interface/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion include/grgsm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ add_subdirectory(misc_utils)
add_subdirectory(qa_utils)
add_subdirectory(flow_control)
add_subdirectory(transmitter)
add_subdirectory(trx_interface)
1 change: 1 addition & 0 deletions include/grgsm/misc_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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(
Expand All @@ -59,5 +59,5 @@ namespace gr {
} // namespace gsm
} // namespace gr

#endif /* INCLUDED_GRGSM_TRX_H */
#endif /* INCLUDED_GRGSM_TRX_BURST_IF_H */

1 change: 0 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ add_subdirectory(misc_utils)
add_subdirectory(qa_utils)
add_subdirectory(receiver)
add_subdirectory(transmitter)
add_subdirectory(trx_interface)

########################################################################
# Setup library
Expand Down
2 changes: 2 additions & 0 deletions lib/misc_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ add_sources(
tmsi_dumper_impl.cc
time_spec.cc
fn_time.cc
udp_socket.cc
trx_burst_if_impl.cc
)

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
{
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -106,21 +108,21 @@ 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;
}

/*
* 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++)
Expand All @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -57,5 +57,5 @@ namespace gr {
} // namespace gsm
} // namespace gr

#endif /* INCLUDED_GRGSM_TRX_IMPL_H */
#endif /* INCLUDED_GRGSM_TRX_BURST_IF_IMPL_H */

File renamed without changes.
File renamed without changes.
23 changes: 0 additions & 23 deletions lib/trx_interface/CMakeLists.txt

This file was deleted.

6 changes: 3 additions & 3 deletions swig/grgsm_swig.i
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit e601c36

Please sign in to comment.