From 7f3f3666b81ea813780c44a27aae81d602af221c Mon Sep 17 00:00:00 2001 From: piotr Date: Tue, 8 Jul 2014 16:47:53 +0200 Subject: Little changes commited from all files. Cleanup in the lib directory - files moved associated with different blocks moved to associated directories. --- lib/CMakeLists.txt | 40 ++++++++++++++++---------------- lib/burst_printer/bursts_printer_impl.cc | 2 +- lib/burst_printer/bursts_printer_impl.h | 2 +- lib/receiver/gsm_constants.h | 1 + lib/receiver/receiver_config.h | 5 ++-- lib/receiver/receiver_impl.cc | 28 ++++++++++++---------- lib/receiver/receiver_impl.h | 1 + 7 files changed, 42 insertions(+), 37 deletions(-) (limited to 'lib') diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 99207d8..a07a876 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -22,14 +22,14 @@ ######################################################################## include(GrPlatform) #define LIB_SUFFIX -include_directories(${Boost_INCLUDE_DIR}) +include_directories(${Boost_INCLUDE_DIR} receiver burst_printer) link_directories(${Boost_LIBRARY_DIRS}) list(APPEND gsm_sources - receiver_impl.cc - receiver_config.cc + receiver/receiver_impl.cc + receiver/receiver_config.cc viterbi_detector.cc sch.c - bursts_printer_impl.cc + burst_printer/bursts_printer_impl.cc ) add_library(gnuradio-gsm SHARED ${gsm_sources}) @@ -52,24 +52,24 @@ install(TARGETS gnuradio-gsm ######################################################################## # Build and register unit test ######################################################################## -include(GrTest) +#include(GrTest) -include_directories(${CPPUNIT_INCLUDE_DIRS}) +#include_directories(${CPPUNIT_INCLUDE_DIRS}) -list(APPEND test_gsm_sources - ${CMAKE_CURRENT_SOURCE_DIR}/test_gsm.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gsm.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_receiver.cc -) +#list(APPEND test_gsm_sources +# ${CMAKE_CURRENT_SOURCE_DIR}/test_gsm.cc +# ${CMAKE_CURRENT_SOURCE_DIR}/qa_gsm.cc +# ${CMAKE_CURRENT_SOURCE_DIR}/qa_receiver.cc +#) -add_executable(test-gsm ${test_gsm_sources}) +#add_executable(test-gsm ${test_gsm_sources}) -target_link_libraries( - test-gsm - ${GNURADIO_RUNTIME_LIBRARIES} - ${Boost_LIBRARIES} - ${CPPUNIT_LIBRARIES} - gnuradio-gsm -) +#target_link_libraries( +# test-gsm +# ${GNURADIO_RUNTIME_LIBRARIES} +# ${Boost_LIBRARIES} +# ${CPPUNIT_LIBRARIES} +# gnuradio-gsm +#) -GR_ADD_TEST(test_gsm test-gsm) +#GR_ADD_TEST(test_gsm test-gsm) diff --git a/lib/burst_printer/bursts_printer_impl.cc b/lib/burst_printer/bursts_printer_impl.cc index ba4ff4c..dbb7023 100644 --- a/lib/burst_printer/bursts_printer_impl.cc +++ b/lib/burst_printer/bursts_printer_impl.cc @@ -55,7 +55,7 @@ namespace gr { for(int ii=0; ii(burst_elements[ii]) << " "; + std::cout << std::setprecision(1) << static_cast(burst_elements[ii]) << ""; } std::cout << std::endl; } diff --git a/lib/burst_printer/bursts_printer_impl.h b/lib/burst_printer/bursts_printer_impl.h index 932c8c7..81e8be6 100644 --- a/lib/burst_printer/bursts_printer_impl.h +++ b/lib/burst_printer/bursts_printer_impl.h @@ -32,7 +32,7 @@ namespace gr { private: void bursts_print(pmt::pmt_t burst); std::set d_c0_channels; - + public: bursts_printer_impl(); ~bursts_printer_impl(); diff --git a/lib/receiver/gsm_constants.h b/lib/receiver/gsm_constants.h index 964c1cf..0308d96 100644 --- a/lib/receiver/gsm_constants.h +++ b/lib/receiver/gsm_constants.h @@ -16,6 +16,7 @@ #define USEFUL_BITS 142 //(2*(DATA_BITS+STEALING_BIT) + N_TRAIN_BITS ) #define FCCH_BITS USEFUL_BITS #define BURST_SIZE (USEFUL_BITS+2*TAIL_BITS) +#define PROCESSED_CHUNK BURST_SIZE+2*GUARD_PERIOD #define SCH_DATA_LEN 39 #define TS_BITS (TAIL_BITS+USEFUL_BITS+TAIL_BITS+GUARD_BITS) //a full TS (156 bits) diff --git a/lib/receiver/receiver_config.h b/lib/receiver/receiver_config.h index b7ba43a..2014a5b 100644 --- a/lib/receiver/receiver_config.h +++ b/lib/receiver/receiver_config.h @@ -95,9 +95,8 @@ class burst_counter d_timeslot_nr(timeslot_nr), d_offset_fractional(0.0), d_offset_integer(0.0) { - double first_sample_position = (get_frame_nr() * 8 + timeslot_nr) * TS_BITS; - d_offset_integer = floor(first_sample_position); - d_offset_fractional = first_sample_position - floor(first_sample_position); + d_offset_integer = 0; + d_offset_fractional = 0; } burst_counter & operator++(int); diff --git a/lib/receiver/receiver_impl.cc b/lib/receiver/receiver_impl.cc index 6e92c2d..f718f99 100644 --- a/lib/receiver/receiver_impl.cc +++ b/lib/receiver/receiver_impl.cc @@ -38,6 +38,7 @@ #include #include #include +//#include "plotting/plotting.hpp" #define SYNC_SEARCH_RANGE 30 @@ -78,12 +79,13 @@ receiver_impl::receiver_impl(feval_dd * tuner, int osr, int arfcn) d_signal_dbm(-120) { int i; - set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR)); //don't send samples to the receiver until there are at least samples for one - // burst and two gurad periods (one gurard period is an arbitrary overlap) + //set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR)); //don't send samples to the receiver until there are at least samples for one + set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR)); // burst and two gurad periods (one gurard period is an arbitrary overlap) gmsk_mapper(SYNC_BITS, N_SYNC_BITS, d_sch_training_seq, gr_complex(0.0, -1.0)); for (i = 0; i < TRAIN_SEQ_NUM; i++) { gr_complex startpoint = (train_seq[i][0]==0) ? gr_complex(1.0, 0.0) : gr_complex(-1.0, 0.0); //if first bit of the seqeunce ==0 first symbol ==1 + //if first bit of the seqeunce ==1 first symbol ==-1 gmsk_mapper(train_seq[i], N_TRAIN_BITS, d_norm_training_seq[i], startpoint); } message_port_register_out(pmt::mp("bursts")); @@ -113,7 +115,8 @@ receiver_impl::work(int noutput_items, if (find_fcch_burst(input, noutput_items)) //find frequency correction burst in the input buffer { //set_frequency(d_freq_offset); //if fcch search is successful set frequency offset - COUT("Freq offset " << d_freq_offset); + DCOUT("Freq offset " << d_freq_offset); + DCOUT("PPM: " << d_freq_offset/940e6); d_state = next_fcch_search; } else @@ -125,13 +128,14 @@ receiver_impl::work(int noutput_items, case next_fcch_search: //this state is used because it takes some time (a bunch of buffered samples) { DCOUT("NEXT FCCH search"); - float prev_freq_offset = d_freq_offset; //before previous set_frequqency cause change + d_prev_freq_offset = d_freq_offset; //before previous set_frequqency cause change if (find_fcch_burst(input, noutput_items)) { - if (abs(prev_freq_offset - d_freq_offset) > FCCH_MAX_FREQ_OFFSET) + if (abs(d_prev_freq_offset - d_freq_offset) > FCCH_MAX_FREQ_OFFSET) { //set_frequency(d_freq_offset); //call set_frequncy only frequency offset change is greater than some value - DCOUT("Freq offset " << d_freq_offset); + //COUT("Freq offset " << d_freq_offset); + DCOUT("PPM: " << d_freq_offset/940); } d_state = sch_search; } @@ -162,7 +166,7 @@ receiver_impl::work(int noutput_items, d_burst_nr.set(t1, t2, t3, 0); //set counter of bursts value d_burst_nr++; - consume_each(burst_start + BURST_SIZE * d_OSR); //consume samples up to next guard period + consume_each(burst_start + BURST_SIZE * d_OSR + 4*d_OSR); //consume samples up to next guard period d_state = synchronized; } else @@ -210,7 +214,7 @@ receiver_impl::work(int noutput_items, double sum = std::accumulate(d_freq_offset_vals.begin(), d_freq_offset_vals.end(), 0); double mean_offset = sum / d_freq_offset_vals.size(); //compute mean d_freq_offset_vals.clear(); - DCOUT("mean offset" << mean_offset); + DCOUT("mean offset" << mean_offset/940); if (abs(mean_offset) > FCCH_MAX_FREQ_OFFSET) { //d_freq_offset -= mean_offset; //and adjust frequency if it have changed beyond @@ -244,7 +248,7 @@ receiver_impl::work(int noutput_items, d_freq_offset_vals.clear(); d_freq_offset=0; //set_frequency(0); - DCOUT("Re-Synchronization"); + DCOUT("Re-Synchronization!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } } } @@ -288,7 +292,6 @@ receiver_impl::work(int noutput_items, } d_burst_nr++; //go to next burst - to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset(); //consume samples of the burst up to next guard period //and add offset which is introduced by //0.25 fractional part of a guard period @@ -447,7 +450,8 @@ bool receiver_impl::find_fcch_burst(const gr_complex *input, const int nitems) //compute frequency offset double phase_offset = best_sum / FCCH_HITS_NEEDED; double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI); - d_freq_offset -= freq_offset; + //d_freq_offset -= freq_offset; + d_freq_offset = freq_offset; DCOUT("freq_offset: " << d_freq_offset); end = true; @@ -544,7 +548,7 @@ int receiver_impl::get_sch_chan_imp_resp(const gr_complex *input, gr_complex * c correlation_buffer.push_back(correlation); power_buffer.push_back(std::pow(abs(correlation), 2)); } - + //plot(power_buffer); //compute window energies vector_float::iterator iter = power_buffer.begin(); bool loop_end = false; diff --git a/lib/receiver/receiver_impl.h b/lib/receiver/receiver_impl.h index b8b8b68..42e6d01 100644 --- a/lib/receiver/receiver_impl.h +++ b/lib/receiver/receiver_impl.h @@ -60,6 +60,7 @@ namespace gr { //@{ unsigned d_fcch_start_pos; ///< position of the first sample of the fcch burst float d_freq_offset; ///< frequency offset of the received signal + float d_prev_freq_offset; //!!! //@} std::list d_freq_offset_vals; -- cgit v1.2.3