diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/decoding/control_channels_decoder_impl.cc | 23 | ||||
-rw-r--r-- | lib/demapping/get_bcch_or_ccch_bursts_impl.cc | 5 | ||||
-rw-r--r-- | lib/demapping/universal_ctrl_chans_demapper_impl.cc | 7 | ||||
-rw-r--r-- | lib/misc_utils/bursts_printer_impl.cc | 13 | ||||
-rw-r--r-- | lib/misc_utils/message_printer_impl.cc | 15 | ||||
-rw-r--r-- | lib/receiver/receiver_impl.cc | 33 | ||||
-rw-r--r-- | lib/receiver/receiver_impl.h | 2 |
7 files changed, 51 insertions, 47 deletions
diff --git a/lib/decoding/control_channels_decoder_impl.cc b/lib/decoding/control_channels_decoder_impl.cc index a5ac83c..404796f 100644 --- a/lib/decoding/control_channels_decoder_impl.cc +++ b/lib/decoding/control_channels_decoder_impl.cc @@ -26,6 +26,8 @@ #include <gsm/gsmtap.h> #include "control_channels_decoder_impl.h" +#define DATA_BYTES 23 + namespace gr { namespace gsm { @@ -80,8 +82,8 @@ namespace gr { //reorganize data for(int ii = 0; ii < 4; ii++) { - pmt::pmt_t burst_content = pmt::cdr(d_bursts[ii]); - int8_t * burst_bits = (int8_t *)pmt::blob_data(burst_content); + pmt::pmt_t header_plus_burst = pmt::cdr(d_bursts[ii]); + int8_t * burst_bits = (int8_t *)(pmt::blob_data(header_plus_burst))+sizeof(gsmtap_hdr); for(int jj = 0; jj < 57; jj++) { @@ -131,16 +133,17 @@ namespace gr { } //send message with header of the first burst - pmt::pmt_t header_blob = pmt::car(d_bursts[0]); - gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob); + pmt::pmt_t first_header_plus_burst = pmt::cdr(d_bursts[0]); + gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(first_header_plus_burst); header->type = GSMTAP_TYPE_UM; - int8_t * header_content = (int8_t *)pmt::blob_data(header_blob); - - int8_t header_plus_data[16+23]; - memcpy(header_plus_data, header_content, 16); - memcpy(header_plus_data+16, outmsg, 23); - pmt::pmt_t msg_binary_blob = pmt::make_blob(header_plus_data,23+16); + int8_t * header_content = (int8_t *)header; + + int8_t header_plus_data[sizeof(gsmtap_hdr)+DATA_BYTES]; + memcpy(header_plus_data, header_content, sizeof(gsmtap_hdr)); + memcpy(header_plus_data+sizeof(gsmtap_hdr), outmsg, DATA_BYTES); + + pmt::pmt_t msg_binary_blob = pmt::make_blob(header_plus_data,DATA_BYTES+sizeof(gsmtap_hdr)); pmt::pmt_t msg_out = pmt::cons(pmt::PMT_NIL, msg_binary_blob); message_port_pub(pmt::mp("msgs"), msg_out); diff --git a/lib/demapping/get_bcch_or_ccch_bursts_impl.cc b/lib/demapping/get_bcch_or_ccch_bursts_impl.cc index e9d3316..78d4280 100644 --- a/lib/demapping/get_bcch_or_ccch_bursts_impl.cc +++ b/lib/demapping/get_bcch_or_ccch_bursts_impl.cc @@ -59,9 +59,8 @@ namespace gr { void get_bcch_or_ccch_bursts_impl::filter_ccch(pmt::pmt_t msg) { - pmt::pmt_t header_blob = pmt::car(msg); - pmt::pmt_t content = pmt::cdr(msg); - gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob); + 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; diff --git a/lib/demapping/universal_ctrl_chans_demapper_impl.cc b/lib/demapping/universal_ctrl_chans_demapper_impl.cc index ea9a06e..75fa6f7 100644 --- a/lib/demapping/universal_ctrl_chans_demapper_impl.cc +++ b/lib/demapping/universal_ctrl_chans_demapper_impl.cc @@ -88,11 +88,10 @@ namespace gr { void universal_ctrl_chans_demapper_impl::filter_ctrl_chans(pmt::pmt_t msg) { - pmt::pmt_t header_blob = pmt::car(msg); - pmt::pmt_t content = pmt::cdr(msg); - gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob); - uint32_t frame_nr = be32toh(header->frame_number); + 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; uint32_t fn51_start = d_starts_fn_mod51[fn_mod51]; uint32_t fn51_stop = fn51_start + 3; diff --git a/lib/misc_utils/bursts_printer_impl.cc b/lib/misc_utils/bursts_printer_impl.cc index 3e7d843..e428163 100644 --- a/lib/misc_utils/bursts_printer_impl.cc +++ b/lib/misc_utils/bursts_printer_impl.cc @@ -36,16 +36,15 @@ namespace gr { boost::mutex printer_mutex; void bursts_printer_impl::bursts_print(pmt::pmt_t msg) { - pmt::pmt_t burst = pmt::cdr(msg); - int8_t * burst_elements = (int8_t *)pmt::blob_data(burst); - size_t burst_len=pmt::blob_length(burst); - - pmt::pmt_t header_blob = pmt::car(msg); - gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob); + pmt::pmt_t header_plus_burst = pmt::cdr(msg); + gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst); + int8_t * burst = (int8_t *)(pmt::blob_data(header_plus_burst))+sizeof(gsmtap_hdr); + size_t burst_len=pmt::blob_length(header_plus_burst)-sizeof(gsmtap_hdr); + for(int ii=0; ii<burst_len; ii++) { - std::cout << std::setprecision(1) << static_cast<int>(burst_elements[ii]) << ""; + std::cout << std::setprecision(1) << static_cast<int>(burst[ii]) << ""; } std::cout << std::endl; } diff --git a/lib/misc_utils/message_printer_impl.cc b/lib/misc_utils/message_printer_impl.cc index 0e55233..5a9e6db 100644 --- a/lib/misc_utils/message_printer_impl.cc +++ b/lib/misc_utils/message_printer_impl.cc @@ -31,16 +31,15 @@ namespace gr { void message_printer_impl::message_print(pmt::pmt_t msg) { - pmt::pmt_t message = pmt::cdr(msg); - uint8_t * message_elements = (uint8_t *)pmt::blob_data(message); - size_t message_len=pmt::blob_length(message); - -// pmt::pmt_t header_blob = pmt::car(msg); - gsmtap_hdr * header = (gsmtap_hdr *)message_elements; + pmt::pmt_t message_plus_header_blob = pmt::cdr(msg); + uint8_t * message_plus_header = (uint8_t *)pmt::blob_data(message_plus_header_blob); + size_t message_plus_header_len=pmt::blob_length(message_plus_header_blob); + + gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header; - for(int ii=(header->hdr_len*4); ii<message_len; ii++) + for(int ii=sizeof(gsmtap_hdr); ii<message_plus_header_len; ii++) { - printf(" %02x", message_elements[ii]); + printf(" %02x", message_plus_header[ii]); } std::cout << std::endl; } diff --git a/lib/receiver/receiver_impl.cc b/lib/receiver/receiver_impl.cc index e5fa136..964634c 100644 --- a/lib/receiver/receiver_impl.cc +++ b/lib/receiver/receiver_impl.cc @@ -228,7 +228,7 @@ receiver_impl::work(int noutput_items, const unsigned last_sample = first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR; double freq_offset_tmp = compute_freq_offset(input, first_sample, last_sample); //extract frequency offset from it - send_burst(d_burst_nr, fc_fb, b_type, input_nr); + send_burst(d_burst_nr, fc_fb, GSMTAP_BURST_FCCH, input_nr); pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(freq_offset_tmp-d_freq_offset_setting),pmt::mp("synchronized")); message_port_pub(pmt::mp("measurements"), msg); @@ -240,7 +240,7 @@ receiver_impl::work(int noutput_items, d_c0_burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response detect_burst(input, &channel_imp_resp[0], d_c0_burst_start, output_binary); //MLSE detection of bits - send_burst(d_burst_nr, output_binary, b_type, input_nr); + send_burst(d_burst_nr, output_binary, GSMTAP_BURST_SCH, input_nr); if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //and decode SCH data { // d_burst_nr.set(t1, t2, t3, 0); //but only to check if burst_start value is correct @@ -266,7 +266,7 @@ receiver_impl::work(int noutput_items, float normal_corr_max; //if it's normal burst d_c0_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, d_bcc); //get channel impulse response for given training sequence number - d_bcc detect_burst(input, &channel_imp_resp[0], d_c0_burst_start, output_binary); //MLSE detection of bits - send_burst(d_burst_nr, output_binary, b_type, input_nr); + send_burst(d_burst_nr, output_binary, GSMTAP_BURST_NORMAL, input_nr); break; } case dummy_or_normal: @@ -281,19 +281,19 @@ receiver_impl::work(int noutput_items, { d_c0_burst_start = normal_burst_start; detect_burst(input, &channel_imp_resp[0], normal_burst_start, output_binary); - send_burst(d_burst_nr, output_binary, b_type, input_nr); + send_burst(d_burst_nr, output_binary, GSMTAP_BURST_NORMAL, input_nr); } else { d_c0_burst_start = dummy_burst_start; - send_burst(d_burst_nr, dummy_burst, b_type, input_nr); + send_burst(d_burst_nr, dummy_burst, GSMTAP_BURST_DUMMY, input_nr); } break; } case rach_burst: break; case dummy: - send_burst(d_burst_nr, dummy_burst, b_type, input_nr); + send_burst(d_burst_nr, dummy_burst, GSMTAP_BURST_DUMMY, input_nr); break; case normal_or_noise: { @@ -330,7 +330,7 @@ receiver_impl::work(int noutput_items, // if(abs(d_c0_burst_start-burst_start)<=2){ //unused check/filter based on timing if((normal_corr_max/sqrt(signal_pwr))>=0.9){ detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); - send_burst(d_burst_nr, output_binary, b_type, input_nr); + send_burst(d_burst_nr, output_binary, GSMTAP_BURST_NORMAL, input_nr); } } break; @@ -816,22 +816,27 @@ int receiver_impl::get_norm_chan_imp_resp(const gr_complex *input, gr_complex * } -void receiver_impl::send_burst(burst_counter burst_nr, const unsigned char * burst_binary, burst_type b_type, unsigned int input_nr) +void receiver_impl::send_burst(burst_counter burst_nr, const unsigned char * burst_binary, uint8_t burst_type, unsigned int input_nr) { boost::scoped_ptr<gsmtap_hdr> tap_header(new gsmtap_hdr()); - + tap_header->version = GSMTAP_VERSION; tap_header->hdr_len = sizeof(gsmtap_hdr)/4; tap_header->type = GSMTAP_TYPE_UM_BURST; tap_header->timeslot = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr()); tap_header->frame_number = htobe32(d_burst_nr.get_frame_nr()); - tap_header->sub_type = static_cast<uint8_t>(b_type); - tap_header->arfcn = d_cell_allocation[input_nr]; + tap_header->sub_type = burst_type; + std::cout << static_cast<int>(tap_header->sub_type) << std::endl; + tap_header->arfcn = htobe16(d_cell_allocation[input_nr]) ; tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm); tap_header->snr_db = 0; - pmt::pmt_t header_blob=pmt::make_blob(tap_header.get(),sizeof(gsmtap_hdr)); - pmt::pmt_t burst_binary_blob=pmt::make_blob(burst_binary,BURST_SIZE); - pmt::pmt_t msg = pmt::cons(header_blob, burst_binary_blob); + + int8_t header_plus_burst[sizeof(gsmtap_hdr)+BURST_SIZE]; + memcpy(header_plus_burst, tap_header.get(), sizeof(gsmtap_hdr)); + memcpy(header_plus_burst+sizeof(gsmtap_hdr), burst_binary, BURST_SIZE); + + pmt::pmt_t blob_header_plus_burst = pmt::make_blob(header_plus_burst,sizeof(gsmtap_hdr)+BURST_SIZE); + pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob_header_plus_burst); if(input_nr==0){ message_port_pub(pmt::mp("C0"), msg); diff --git a/lib/receiver/receiver_impl.h b/lib/receiver/receiver_impl.h index 2b7e9cf..769d279 100644 --- a/lib/receiver/receiver_impl.h +++ b/lib/receiver/receiver_impl.h @@ -191,7 +191,7 @@ namespace gr { * @param burst_binary - content of the burst * @b_type - type of the burst */ - void send_burst(burst_counter burst_nr, const unsigned char * burst_binary, burst_type b_type, unsigned int input_nr); + void send_burst(burst_counter burst_nr, const unsigned char * burst_binary, uint8_t burst_type, unsigned int input_nr); /** * Configures burst types in different channels |