Removed boost timer from clock_offset_control to avoid race conditions.
The time is now tracked by the receiver based on samples count and send through the 'measurements' interface to the clock_offset_control. clock_offset_control takes time into account during fcch_search.
This commit is contained in:
parent
f8c7e83298
commit
32c2116d88
|
@ -1,3 +1,4 @@
|
|||
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* @file
|
||||
|
@ -45,8 +46,7 @@ clock_offset_control::make(float fc)
|
|||
clock_offset_control_impl::clock_offset_control_impl(float fc)
|
||||
: gr::block("clock_offset_control",
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(0, 0, 0)),
|
||||
d_timer(d_io_service)
|
||||
gr::io_signature::make(0, 0, 0))
|
||||
|
||||
{
|
||||
message_port_register_in(pmt::mp("measurements"));
|
||||
|
@ -60,8 +60,9 @@ clock_offset_control_impl::clock_offset_control_impl(float fc)
|
|||
d_first_measurement = true;
|
||||
d_counter = 0;
|
||||
d_last_state = "";
|
||||
|
||||
d_timer.async_wait(boost::bind(&clock_offset_control_impl::timed_reset, this));
|
||||
d_current_time = 0;
|
||||
d_last_fcch_time = 0;
|
||||
d_first_time = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -81,6 +82,21 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
|
|||
if(pmt::is_tuple(msg))
|
||||
{
|
||||
std::string key = pmt::symbol_to_string(pmt::tuple_ref(msg,0));
|
||||
if(key == "current_time")
|
||||
{
|
||||
d_current_time = pmt::to_double(pmt::tuple_ref(msg,1));
|
||||
if(d_first_time==true)
|
||||
{
|
||||
d_last_fcch_time = d_current_time;
|
||||
d_first_time = false;
|
||||
}
|
||||
else
|
||||
if((d_current_time - d_last_fcch_time) > 0.5 && d_last_state == "fcch_search")
|
||||
{
|
||||
timed_reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
if(key == "freq_offset")
|
||||
{
|
||||
float freq_offset = pmt::to_double(pmt::tuple_ref(msg,1));
|
||||
|
@ -89,7 +105,7 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
|
|||
d_last_state = state;
|
||||
if(abs(ppm) > 100) //safeguard against flawed measurements
|
||||
{
|
||||
ppm = 0; //!!! do poprawki ten warunek
|
||||
ppm=0;
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -97,13 +113,12 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
|
|||
{
|
||||
pmt::pmt_t msg_ppm = pmt::from_double(ppm);
|
||||
message_port_pub(pmt::intern("ppm"), msg_ppm);
|
||||
d_timer.cancel();
|
||||
d_timer.async_wait(boost::bind(&clock_offset_control_impl::timed_reset, this));
|
||||
d_last_fcch_time = d_current_time;
|
||||
}
|
||||
else
|
||||
if (state == "synchronized")
|
||||
{
|
||||
d_timer.cancel();
|
||||
d_last_fcch_time = d_current_time;
|
||||
if(d_first_measurement)
|
||||
{
|
||||
d_ppm_estimate = ppm;
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include <grgsm/receiver/clock_offset_control.h>
|
||||
#include <string>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
namespace gr {
|
||||
namespace gsm {
|
||||
|
@ -40,8 +38,9 @@ namespace gr {
|
|||
bool d_first_measurement;
|
||||
int d_counter;
|
||||
std::string d_last_state;
|
||||
boost::asio::io_service d_io_service;
|
||||
boost::asio::deadline_timer d_timer;
|
||||
float d_current_time;
|
||||
float d_last_fcch_time;
|
||||
bool d_first_time;
|
||||
|
||||
void process_measurement(pmt::pmt_t msg);
|
||||
void timed_reset();
|
||||
|
|
|
@ -75,7 +75,8 @@ receiver_impl::receiver_impl(int osr, const std::vector<int> &cell_allocation, c
|
|||
d_failed_sch(0),
|
||||
d_signal_dbm(-120),
|
||||
d_tseq_nums(tseq_nums),
|
||||
d_cell_allocation(cell_allocation)
|
||||
d_cell_allocation(cell_allocation),
|
||||
d_last_time(0.0)
|
||||
{
|
||||
int i;
|
||||
//don't send samples to the receiver until there are at least samples for one
|
||||
|
@ -111,6 +112,14 @@ receiver_impl::work(int noutput_items,
|
|||
uint64_t start = nitems_read(0);
|
||||
uint64_t stop = start + noutput_items;
|
||||
|
||||
float current_time = static_cast<float>(start)/(GSM_SYMBOL_RATE*d_OSR);
|
||||
if((current_time - d_last_time) > 0.1)
|
||||
{
|
||||
pmt::pmt_t msg = pmt::make_tuple(pmt::mp("current_time"),pmt::from_double(current_time));
|
||||
message_port_pub(pmt::mp("measurements"), msg);
|
||||
d_last_time = current_time;
|
||||
}
|
||||
|
||||
pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
|
||||
get_tags_in_range(freq_offset_tags, 0, start, stop, key);
|
||||
bool freq_offset_tag_in_fcch = false;
|
||||
|
|
|
@ -47,6 +47,8 @@ namespace gr {
|
|||
gr_complex d_sch_training_seq[N_SYNC_BITS]; ///<encoded training sequence of a SCH burst
|
||||
gr_complex d_norm_training_seq[TRAIN_SEQ_NUM][N_TRAIN_BITS]; ///<encoded training sequences of a normal and dummy burst
|
||||
|
||||
float d_last_time;
|
||||
|
||||
/** Counts samples consumed by the receiver
|
||||
*
|
||||
* It is used in beetween find_fcch_burst and reach_sch_burst calls.
|
||||
|
|
Loading…
Reference in New Issue