Correctly use zero offset for devices that don't issue proper timestamp

tags.
This commit is contained in:
Nick Foster 2015-07-09 13:08:00 -07:00
parent 953a7ddded
commit 2c9ef501b8

View File

@ -98,10 +98,18 @@ static double correlate_preamble(const float *in, int samples_per_chip) {
} }
static pmt::pmt_t tag_to_timestamp(gr::tag_t tstamp, uint64_t abs_sample_cnt, int rate) { static pmt::pmt_t tag_to_timestamp(gr::tag_t tstamp, uint64_t abs_sample_cnt, int rate) {
uint64_t last_whole_stamp;
double last_frac_stamp;
pmt::pmt_t tstime = pmt::make_tuple(pmt::from_uint64(0), pmt::from_double(0)); pmt::pmt_t tstime = pmt::make_tuple(pmt::from_uint64(0), pmt::from_double(0));
if(tstamp.key == NULL) return tstime; if(tstamp.key == NULL
if(!pmt::is_symbol(tstamp.key)) return tstime; || !pmt::is_symbol(tstamp.key)
if(pmt::symbol_to_string(tstamp.key) != "rx_time") return tstime; || pmt::symbol_to_string(tstamp.key) != "rx_time") {
last_whole_stamp = 0;
last_frac_stamp = 0;
} else {
last_whole_stamp = pmt::to_uint64(pmt::tuple_ref(tstamp.value, 0));
last_frac_stamp = pmt::to_double(pmt::tuple_ref(tstamp.value, 1));
}
//the timestamp tag has tstamp.offset, the sample index of the timestamp tag //the timestamp tag has tstamp.offset, the sample index of the timestamp tag
//also tstamp.value, a pmt pair with (uint64, double) representing int and //also tstamp.value, a pmt pair with (uint64, double) representing int and
@ -113,8 +121,6 @@ static pmt::pmt_t tag_to_timestamp(gr::tag_t tstamp, uint64_t abs_sample_cnt, in
// int((abs_sample_cnt - tstamp.offset)/sps) is the integer offset // int((abs_sample_cnt - tstamp.offset)/sps) is the integer offset
// (abs_sample_cnt - tstamp.offset)/sps is the fractional offset // (abs_sample_cnt - tstamp.offset)/sps is the fractional offset
uint64_t last_whole_stamp = pmt::to_uint64(pmt::tuple_ref(tstamp.value, 0));
double last_frac_stamp = pmt::to_double(pmt::tuple_ref(tstamp.value, 1));
uint64_t int_offset = int(abs_sample_cnt - tstamp.offset)/rate; uint64_t int_offset = int(abs_sample_cnt - tstamp.offset)/rate;
double frac_offset = ((abs_sample_cnt - tstamp.offset) % rate) / double(rate); double frac_offset = ((abs_sample_cnt - tstamp.offset) % rate) / double(rate);