aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2016-05-20 12:45:54 +0200
committerPiotr Krysik <ptrkrysik@gmail.com>2016-05-20 12:45:54 +0200
commit773a194c327c89161b3d11e5246dfea04d9b45dc (patch)
treed81ba89769c7a807a4b155b84e8d4bfb3e2bae16 /lib
parentbac8284599e137981f178e8998d6426f011d9dab (diff)
Big change of the universal control channels demapper:
-simplification of the universal demapper, -addition of hierarhical blocks for each of the demappers - so they also look well and readable in python, -addition of helper script for compilation of the demappers.
Diffstat (limited to 'lib')
-rw-r--r--lib/demapping/universal_ctrl_chans_demapper_impl.cc300
-rw-r--r--lib/demapping/universal_ctrl_chans_demapper_impl.h31
2 files changed, 96 insertions, 235 deletions
diff --git a/lib/demapping/universal_ctrl_chans_demapper_impl.cc b/lib/demapping/universal_ctrl_chans_demapper_impl.cc
index cbbbc32..32987ca 100644
--- a/lib/demapping/universal_ctrl_chans_demapper_impl.cc
+++ b/lib/demapping/universal_ctrl_chans_demapper_impl.cc
@@ -36,158 +36,34 @@ namespace gr {
namespace gsm {
universal_ctrl_chans_demapper::sptr
- universal_ctrl_chans_demapper::make(unsigned int timeslot_nr, const std::vector<int> &downlink_starts_fn_mod51, const std::vector<int> &downlink_channel_types, const std::vector<int> &uplink_starts_fn_mod51, const std::vector<int> &uplink_channel_types)
- {
+ universal_ctrl_chans_demapper::make(unsigned int timeslot_nr, const std::vector<int> &downlink_starts_fn_mod51, const std::vector<int> &downlink_channel_types, const std::vector<int> &downlink_subslots, const std::vector<int> &uplink_starts_fn_mod51, const std::vector<int> &uplink_channel_types, const std::vector<int> &uplink_subslots)
+ {
return gnuradio::get_initial_sptr
- (new universal_ctrl_chans_demapper_impl(timeslot_nr, downlink_starts_fn_mod51, downlink_channel_types, uplink_starts_fn_mod51, uplink_channel_types));
+ (new universal_ctrl_chans_demapper_impl(timeslot_nr, downlink_starts_fn_mod51, downlink_channel_types, downlink_subslots, uplink_starts_fn_mod51, uplink_channel_types, uplink_subslots));
}
/*
* The private constructor
*/
- universal_ctrl_chans_demapper_impl::universal_ctrl_chans_demapper_impl(unsigned int timeslot_nr, const std::vector<int> &downlink_starts_fn_mod51, const std::vector<int> &downlink_channel_types, const std::vector<int> &uplink_starts_fn_mod51, const std::vector<int> &uplink_channel_types)
+ universal_ctrl_chans_demapper_impl::universal_ctrl_chans_demapper_impl(unsigned int timeslot_nr, const std::vector<int> &downlink_starts_fn_mod51, const std::vector<int> &downlink_channel_types, const std::vector<int> &downlink_subslots, const std::vector<int> &uplink_starts_fn_mod51, const std::vector<int> &uplink_channel_types, const std::vector<int> &uplink_subslots)
: gr::block("universal_ctrl_chans_demapper",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0)),
- d_timeslot(timeslot_nr)
-
+ d_timeslot_nr(timeslot_nr),
+ d_downlink_starts_fn_mod51(51, 0),
+ d_downlink_channel_types(51, 0),
+ d_downlink_subslots(102, 0),
+ d_uplink_starts_fn_mod51(51, 0),
+ d_uplink_channel_types(51, 0),
+ d_uplink_subslots(102, 0)
{
-
-
- for(int ii=0; ii<51; ii++)
- {
- d_downlink_starts_fn_mod51[ii]=0;
- d_downlink_channel_types[ii]=0;
- d_downlink_subslots[ii] = 0;
- d_downlink_subslots[ii+51] = 0;
-
- d_uplink_starts_fn_mod51[ii]=0;
- d_uplink_channel_types[ii]=0;
- d_uplink_subslots[ii] = 0;
- d_uplink_subslots[ii+51] = 0;
- }
-
- std::vector<int>::const_iterator s;
- std::vector<int>::const_iterator ch_type;
-
- for(s=downlink_starts_fn_mod51.begin(), ch_type=downlink_channel_types.begin();s != downlink_starts_fn_mod51.end(); s++)
- {
- if((*s >= 0) and (*s <= (51-4)))
- {
- for(int ii=0; ii<4; ii++){
- d_downlink_starts_fn_mod51[*s+ii] = *s;
- if(ch_type!=downlink_channel_types.end())
- {
- d_downlink_channel_types[*s+ii] = *ch_type;
- }
- }
- if(ch_type!=downlink_channel_types.end())
- {
- ch_type++;
- }
- }
- }
-
- for(s=uplink_starts_fn_mod51.begin(), ch_type=uplink_channel_types.begin();s != uplink_starts_fn_mod51.end(); s++)
- {
- if((*s >= 0) and (*s <= (51-4)))
- {
- for(int ii=0; ii<4; ii++){
- d_uplink_starts_fn_mod51[*s+ii] = *s;
- if(ch_type!=uplink_channel_types.end())
- {
- d_uplink_channel_types[*s+ii] = *ch_type;
- }
- }
- if(ch_type!=uplink_channel_types.end())
- {
- ch_type++;
- }
- }
- }
-
- std::set<int> distinct_downlink_channels(downlink_channel_types.begin(), downlink_channel_types.end());
- std::set<int>::iterator it;
- unsigned int subslot;
-
- for (it=distinct_downlink_channels.begin(); it != distinct_downlink_channels.end(); it++)
- {
- subslot = 0;
- for(s=downlink_starts_fn_mod51.begin();s != downlink_starts_fn_mod51.end(); s++)
- {
- if ((d_downlink_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4)))
- {
- for(int ii=0; ii<4; ii++)
- {
- d_downlink_subslots[*s+ii] = subslot;
- d_downlink_subslots[*s+ii+51] = subslot;
- }
- subslot++;
- }
- }
-
- if (*it == GSMTAP_CHANNEL_ACCH or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH) or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH4) or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH8) or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_F) or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_H)
- )
- {
- for(s=downlink_starts_fn_mod51.begin();s != downlink_starts_fn_mod51.end(); s++)
- {
- if ((d_downlink_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4)))
- {
- for(int ii=0; ii<4; ii++)
- {
- d_downlink_subslots[*s+ii+51] = subslot;
- }
- subslot++;
- }
- }
- }
- }
-
- std::set<int> distinct_uplink_channels(uplink_channel_types.begin(), uplink_channel_types.end());
- for (it=distinct_uplink_channels.begin(); it != distinct_uplink_channels.end(); it++)
- {
- subslot = 0;
- for(s=uplink_starts_fn_mod51.begin();s != uplink_starts_fn_mod51.end(); s++)
- {
- if ((d_uplink_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4)))
- {
- for(int ii=0; ii<4; ii++)
- {
- d_uplink_subslots[*s+ii] = subslot;
- d_uplink_subslots[*s+ii+51] = subslot;
- }
- subslot++;
- }
- }
-
- if (*it == GSMTAP_CHANNEL_ACCH or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH) or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH4) or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH8) or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_F) or
- *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_H)
- )
- {
- for(s=uplink_starts_fn_mod51.begin();s != uplink_starts_fn_mod51.end(); s++)
- {
- if ((d_uplink_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4)))
- {
- for(int ii=0; ii<4; ii++)
- {
- d_uplink_subslots[*s+ii+51] = subslot;
- }
- subslot++;
- }
- }
- }
- }
-
-
+ std::copy(downlink_starts_fn_mod51.begin(), downlink_starts_fn_mod51.end(), d_downlink_starts_fn_mod51.begin());
+ std::copy(downlink_channel_types.begin(), downlink_channel_types.end(), d_downlink_channel_types.begin());
+ std::copy(downlink_subslots.begin(), downlink_subslots.end(), d_downlink_subslots.begin());
+ std::copy(uplink_starts_fn_mod51.begin(), uplink_starts_fn_mod51.end(), d_uplink_starts_fn_mod51.begin());
+ std::copy(uplink_channel_types.begin(), uplink_channel_types.end(), d_uplink_channel_types.begin());
+ std::copy(uplink_subslots.begin(), uplink_subslots.end(), d_uplink_subslots.begin());
+
message_port_register_in(pmt::mp("bursts"));
set_msg_handler(pmt::mp("bursts"), boost::bind(&universal_ctrl_chans_demapper_impl::filter_ctrl_chans, this, _1));
message_port_register_out(pmt::mp("bursts"));
@@ -205,99 +81,79 @@ namespace gr {
pmt::pmt_t header_plus_burst = pmt::cdr(msg);
gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst);
- uint32_t frame_nr = be32toh(header->frame_number);
- uint32_t fn_mod51 = frame_nr % 51;
-
- bool uplink_burst = (be16toh(header->arfcn) & 0x4000) ? true : false;
-
- if(header->timeslot==d_timeslot){
+ if(header->timeslot==d_timeslot_nr)
+ {
+ int * starts_fn_mod51;
+ int * channel_types;
+ int * subslots;
+ uint32_t * frame_numbers;
+ pmt::pmt_t * bursts;
+
+ uint32_t frame_nr = be32toh(header->frame_number); //get frame number
+ uint32_t fn_mod51 = frame_nr % 51; //frame number modulo 51
+
+ //crate new message
int8_t new_msg[sizeof(gsmtap_hdr)+BURST_SIZE];
gsmtap_hdr * new_hdr = (gsmtap_hdr*)new_msg;
memcpy(new_msg, header, sizeof(gsmtap_hdr)+BURST_SIZE);
pmt::pmt_t msg_binary_blob = pmt::make_blob(new_msg,sizeof(gsmtap_hdr)+BURST_SIZE);
pmt::pmt_t msg_out = pmt::cons(pmt::PMT_NIL, msg_binary_blob);
-
- if(uplink_burst)
- {
- uint32_t fn51_start = d_uplink_starts_fn_mod51[fn_mod51];
- uint32_t fn51_stop = fn51_start + 3;
- uint32_t ch_type = d_uplink_channel_types[fn_mod51];
- if(ch_type != 0)
- {
- new_hdr->sub_type = ch_type;
- }
- new_hdr->sub_slot = d_uplink_subslots[fn_mod51 + (51 * (frame_nr % 2))];
-
- if(fn_mod51>=fn51_start && fn_mod51<=fn51_stop)
- {
- uint32_t ii = fn_mod51 - fn51_start;
- d_uplink_frame_numbers[ii] = frame_nr;
- d_uplink_bursts[ii] = msg_out;
- }
-
- if(fn_mod51==fn51_stop)
- {
- //check for a situation where some bursts were lost
- //in this situation frame numbers won't be consecutive
- bool frames_are_consecutive = true;
- for(int jj=1; jj<4; jj++)
- {
- if((d_uplink_frame_numbers[jj]-d_uplink_frame_numbers[jj-1])!=1)
- {
- frames_are_consecutive = false;
- }
- }
- if(frames_are_consecutive)
- {
- //send bursts to the output
- for(int jj=0; jj<4; jj++)
- {
- message_port_pub(pmt::mp("bursts"), d_uplink_bursts[jj]);
- }
- }
- }
+ //get information if burst is from uplink or downlink
+ bool uplink_burst = (be16toh(header->arfcn) & 0x4000) ? true : false;
+
+ //select right set of configuration and history for uplink or downlink
+ if(uplink_burst) {
+ starts_fn_mod51 = &d_uplink_starts_fn_mod51[0];
+ channel_types = &d_uplink_channel_types[0];
+ subslots = &d_uplink_subslots[0];
+ frame_numbers = d_uplink_frame_numbers;
+ bursts = d_uplink_bursts;
+ } else {
+ starts_fn_mod51 = &d_downlink_starts_fn_mod51[0];
+ channel_types = &d_downlink_channel_types[0];
+ subslots = &d_downlink_subslots[0];
+ frame_numbers = d_downlink_frame_numbers;
+ bursts = d_downlink_bursts;
}
- else
- {
- uint32_t fn51_start = d_downlink_starts_fn_mod51[fn_mod51];
- uint32_t fn51_stop = fn51_start + 3;
- uint32_t ch_type = d_downlink_channel_types[fn_mod51];
+
+ uint32_t fn51_start = starts_fn_mod51[fn_mod51];
+ uint32_t fn51_stop = fn51_start + 3;
+ uint32_t ch_type = channel_types[fn_mod51];
- if(ch_type != 0)
- {
- new_hdr->sub_type = ch_type;
- }
- new_hdr->sub_slot = d_downlink_subslots[fn_mod51 + (51 * (frame_nr % 2))];
-
- if(fn_mod51>=fn51_start && fn_mod51<=fn51_stop)
+ if(ch_type != 0)
+ {
+ new_hdr->sub_type = ch_type;
+ }
+ new_hdr->sub_slot = subslots[fn_mod51 + (51 * (frame_nr % 2))];
+
+ if(fn_mod51>=fn51_start && fn_mod51<=fn51_stop)
+ {
+ uint32_t ii = fn_mod51 - fn51_start;
+ frame_numbers[ii] = frame_nr;
+ bursts[ii] = msg_out;
+ }
+
+ if(fn_mod51==fn51_stop)
+ {
+ //check for a situation where some bursts were lost
+ //in this situation frame numbers won't be consecutive
+ bool frames_are_consecutive = true;
+ for(int jj=1; jj<4; jj++)
{
- uint32_t ii = fn_mod51 - fn51_start;
- d_downlink_frame_numbers[ii] = frame_nr;
- d_downlink_bursts[ii] = msg_out;
+ if((frame_numbers[jj] - frame_numbers[jj-1])!=1)
+ {
+ frames_are_consecutive = false;
+ }
}
-
- if(fn_mod51==fn51_stop)
+ if(frames_are_consecutive)
{
- //check for a situation where some bursts were lost
- //in this situation frame numbers won't be consecutive
- bool frames_are_consecutive = true;
- for(int jj=1; jj<4; jj++)
+ //send bursts to the output
+ for(int jj=0; jj<4; jj++)
{
- if((d_downlink_frame_numbers[jj]-d_downlink_frame_numbers[jj-1])!=1)
- {
- frames_are_consecutive = false;
- }
+ message_port_pub(pmt::mp("bursts"), bursts[jj]);
}
- if(frames_are_consecutive)
- {
- //send bursts to the output
- for(int jj=0; jj<4; jj++)
- {
- message_port_pub(pmt::mp("bursts"), d_downlink_bursts[jj]);
- }
- }
- }
+ }
}
}
}
diff --git a/lib/demapping/universal_ctrl_chans_demapper_impl.h b/lib/demapping/universal_ctrl_chans_demapper_impl.h
index 0316bf4..9545ab6 100644
--- a/lib/demapping/universal_ctrl_chans_demapper_impl.h
+++ b/lib/demapping/universal_ctrl_chans_demapper_impl.h
@@ -29,23 +29,28 @@
namespace gr {
namespace gsm {
+ typedef enum {downlink=0,uplink=1} um_radio_link_direction;
class universal_ctrl_chans_demapper_impl : public universal_ctrl_chans_demapper
{
private:
- unsigned int d_downlink_starts_fn_mod51[51];
- unsigned int d_uplink_starts_fn_mod51[51];
- unsigned int d_downlink_channel_types[51];
- unsigned int d_uplink_channel_types[51];
- unsigned int d_downlink_subslots[102];
- unsigned int d_uplink_subslots[102];
- unsigned int d_timeslot;
- uint32_t d_downlink_frame_numbers[4];
- uint32_t d_uplink_frame_numbers[4];
- pmt::pmt_t d_downlink_bursts[4];
- pmt::pmt_t d_uplink_bursts[4];
+ //configuration of the block
+ unsigned int d_timeslot_nr;
+ std::vector<int> d_downlink_starts_fn_mod51;
+ std::vector<int> d_downlink_channel_types;
+ std::vector<int> d_downlink_subslots;
+
+ std::vector<int> d_uplink_starts_fn_mod51;
+ std::vector<int> d_uplink_channel_types;
+ std::vector<int> d_uplink_subslots;
+
+ //history of the downlink and uplink bursts
+ uint32_t d_downlink_frame_numbers[4];
+ pmt::pmt_t d_downlink_bursts[4];
+ uint32_t d_uplink_frame_numbers[4];
+ pmt::pmt_t d_uplink_bursts[4];
public:
- universal_ctrl_chans_demapper_impl(unsigned int timeslot_nr, const std::vector<int> &downlink_starts_fn_mod51, const std::vector<int> &downlink_channel_types, const std::vector<int> &uplink_starts_fn_mod51, const std::vector<int> &uplink_channel_types);
- ~universal_ctrl_chans_demapper_impl();
+ universal_ctrl_chans_demapper_impl(unsigned int timeslot_nr, const std::vector<int> &downlink_starts_fn_mod51, const std::vector<int> &downlink_channel_types, const std::vector<int> &downlink_subslots, const std::vector<int> &uplink_starts_fn_mod51, const std::vector<int> &uplink_channel_types, const std::vector<int> &uplink_subslots);
+ ~universal_ctrl_chans_demapper_impl();
void filter_ctrl_chans(pmt::pmt_t msg);
};