Timestamps work.
This commit is contained in:
parent
eb18bdc308
commit
72248eaecf
@ -55,6 +55,7 @@ air_modes_slicer::air_modes_slicer(int channel_rate, gr_msg_queue_sptr queue) :
|
|||||||
d_samples_per_symbol = d_samples_per_chip * 2;
|
d_samples_per_symbol = d_samples_per_chip * 2;
|
||||||
d_check_width = 120 * d_samples_per_symbol; //how far you will have to look ahead
|
d_check_width = 120 * d_samples_per_symbol; //how far you will have to look ahead
|
||||||
d_queue = queue;
|
d_queue = queue;
|
||||||
|
d_secs_per_sample = 1.0 / channel_rate;
|
||||||
|
|
||||||
set_output_multiple(1+d_check_width * 2); //how do you specify buffer size for sinks?
|
set_output_multiple(1+d_check_width * 2); //how do you specify buffer size for sinks?
|
||||||
}
|
}
|
||||||
@ -158,29 +159,30 @@ int air_modes_slicer::work(int noutput_items,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/******************** BEGIN TIMESTAMP BS ******************/
|
/******************** BEGIN TIMESTAMP BS ******************/
|
||||||
|
rx_packet.timestamp_secs = 0;
|
||||||
|
rx_packet.timestamp_frac = 0;
|
||||||
|
|
||||||
uint64_t abs_sample_cnt = nitems_read(0);
|
uint64_t abs_sample_cnt = nitems_read(0);
|
||||||
std::vector<pmt::pmt_t> tags;
|
std::vector<pmt::pmt_t> tags;
|
||||||
|
uint64_t timestamp_secs, timestamp_sample, timestamp_delta;
|
||||||
|
double timestamp_frac;
|
||||||
|
|
||||||
//printf("nitems_read: %i", abs_sample_cnt);
|
|
||||||
pmt::pmt_t timestamp = pmt::mp(pmt::mp(0), pmt::mp(0)); //so we don't barf if there isn't one
|
pmt::pmt_t timestamp = pmt::mp(pmt::mp(0), pmt::mp(0)); //so we don't barf if there isn't one
|
||||||
|
|
||||||
get_tags_in_range(tags, 0, abs_sample_cnt, abs_sample_cnt + i);
|
get_tags_in_range(tags, 0, abs_sample_cnt, abs_sample_cnt + i, pmt::pmt_string_to_symbol("packet_time_stamp"));
|
||||||
//tags.back() is the most recent timestamp, then.
|
//tags.back() is the most recent timestamp, then.
|
||||||
if(tags.size() > 0) {
|
if(tags.size() > 0) {
|
||||||
std::sort(tags.begin(), tags.end(), pmtcompare);
|
//if nobody but the USRP is producing timestamps this isn't necessary
|
||||||
|
//std::sort(tags.begin(), tags.end(), pmtcompare);
|
||||||
do {
|
timestamp = tags.back();
|
||||||
timestamp = tags.back();
|
|
||||||
tags.pop_back();
|
|
||||||
} while(!pmt::pmt_eqv(gr_tags::get_key(timestamp), pmt::pmt_string_to_symbol("time"))); //only interested in timestamps
|
|
||||||
|
|
||||||
uint64_t timestamp_secs = pmt_to_uint64(pmt_tuple_ref(timestamp, 0));
|
timestamp_secs = pmt_to_uint64(pmt_tuple_ref(gr_tags::get_value(timestamp), 0));
|
||||||
double timestamp_frac = pmt_to_double(pmt_tuple_ref(timestamp, 1));
|
timestamp_frac = pmt_to_double(pmt_tuple_ref(gr_tags::get_value(timestamp), 1));
|
||||||
uint64_t timestamp_sample = gr_tags::get_nitems(timestamp);
|
timestamp_sample = gr_tags::get_nitems(timestamp);
|
||||||
//now we have to offset the timestamp based on the current sample number
|
//now we have to offset the timestamp based on the current sample number
|
||||||
uint64_t timestamp_delta = (abs_sample_cnt + i) - timestamp_sample;
|
timestamp_delta = (abs_sample_cnt + i) - timestamp_sample;
|
||||||
|
|
||||||
timestamp_frac += timestamp_delta * (1.0 / (d_samples_per_chip * d_chip_rate));
|
timestamp_frac += timestamp_delta * d_secs_per_sample;
|
||||||
if(timestamp_frac > 1.0) {
|
if(timestamp_frac > 1.0) {
|
||||||
timestamp_frac -= 1.0;
|
timestamp_frac -= 1.0;
|
||||||
timestamp_secs++;
|
timestamp_secs++;
|
||||||
@ -189,10 +191,6 @@ int air_modes_slicer::work(int noutput_items,
|
|||||||
rx_packet.timestamp_secs = timestamp_secs;
|
rx_packet.timestamp_secs = timestamp_secs;
|
||||||
rx_packet.timestamp_frac = timestamp_frac;
|
rx_packet.timestamp_frac = timestamp_frac;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
rx_packet.timestamp_secs = 0;
|
|
||||||
rx_packet.timestamp_frac = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************* END TIMESTAMP BS *********************/
|
/******************* END TIMESTAMP BS *********************/
|
||||||
|
|
||||||
@ -287,7 +285,8 @@ int air_modes_slicer::work(int noutput_items,
|
|||||||
}
|
}
|
||||||
|
|
||||||
d_payload << " " << std::setw(6) << rx_packet.parity << " " << std::dec << rx_packet.reference_level
|
d_payload << " " << std::setw(6) << rx_packet.parity << " " << std::dec << rx_packet.reference_level
|
||||||
<< " " << rx_packet.timestamp_secs << " " << rx_packet.timestamp_frac;
|
<< " " << rx_packet.timestamp_secs
|
||||||
|
<< " " << std::setprecision(10) << std::setw(10) << rx_packet.timestamp_frac;
|
||||||
|
|
||||||
gr_message_sptr msg = gr_make_message_from_string(std::string(d_payload.str()));
|
gr_message_sptr msg = gr_make_message_from_string(std::string(d_payload.str()));
|
||||||
d_queue->handle(msg);
|
d_queue->handle(msg);
|
||||||
|
@ -45,6 +45,7 @@ private:
|
|||||||
int d_chip_rate;
|
int d_chip_rate;
|
||||||
int d_samples_per_chip;
|
int d_samples_per_chip;
|
||||||
int d_samples_per_symbol;
|
int d_samples_per_symbol;
|
||||||
|
double d_secs_per_sample;
|
||||||
gr_msg_queue_sptr d_queue;
|
gr_msg_queue_sptr d_queue;
|
||||||
std::ostringstream d_payload;
|
std::ostringstream d_payload;
|
||||||
|
|
||||||
|
@ -31,14 +31,13 @@ class modes_output_print(modes_parse.modes_parse):
|
|||||||
|
|
||||||
def parse(self, message):
|
def parse(self, message):
|
||||||
[msgtype, shortdata, longdata, parity, ecc, reference, time_secs, time_frac] = message.split()
|
[msgtype, shortdata, longdata, parity, ecc, reference, time_secs, time_frac] = message.split()
|
||||||
time_secs = long(time_secs)
|
|
||||||
time_frac = float(time_frac)
|
|
||||||
|
|
||||||
shortdata = long(shortdata, 16)
|
shortdata = long(shortdata, 16)
|
||||||
longdata = long(longdata, 16)
|
longdata = long(longdata, 16)
|
||||||
parity = long(parity, 16)
|
parity = long(parity, 16)
|
||||||
ecc = long(ecc, 16)
|
ecc = long(ecc, 16)
|
||||||
reference = float(reference)
|
reference = float(reference)
|
||||||
|
time_secs = long(time_secs)
|
||||||
|
time_frac = float(time_frac)
|
||||||
|
|
||||||
msgtype = int(msgtype)
|
msgtype = int(msgtype)
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ class modes_output_print(modes_parse.modes_parse):
|
|||||||
output = "No handler for message type " + str(msgtype) + " from %x" % ecc
|
output = "No handler for message type " + str(msgtype) + " from %x" % ecc
|
||||||
|
|
||||||
if reference == 0.0:
|
if reference == 0.0:
|
||||||
refdb = 0.0
|
refdb = -150.0
|
||||||
else:
|
else:
|
||||||
refdb = 10.0*math.log10(reference)
|
refdb = 10.0*math.log10(reference)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user