Modified for new new tags interface

This commit is contained in:
Nick Foster 2011-11-17 15:16:56 -08:00
parent 7a4f703e2b
commit 5ac5c8aca8
3 changed files with 13 additions and 22 deletions

View File

@ -79,15 +79,15 @@ static double correlate_preamble(const float *in, int samples_per_chip) {
} }
//todo: make it return a pair of some kind, otherwise you can lose precision //todo: make it return a pair of some kind, otherwise you can lose precision
static double pmt_to_timestamp(pmt::pmt_t tstamp, uint64_t abs_sample_cnt, double secs_per_sample) { static double tag_to_timestamp(gr_tag_t tstamp, uint64_t abs_sample_cnt, double secs_per_sample) {
uint64_t ts_sample, last_whole_stamp; uint64_t ts_sample, last_whole_stamp;
double last_frac_stamp; double last_frac_stamp;
if(pmt::pmt_symbol_to_string(gr_tags::get_key(tstamp)) != "timestamp") return 0; if(pmt::pmt_symbol_to_string(tstamp.key) != "timestamp") return 0;
last_whole_stamp = pmt_to_uint64(pmt_tuple_ref(gr_tags::get_value(tstamp), 0)); last_whole_stamp = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(tstamp.value, 0));
last_frac_stamp = pmt_to_double(pmt_tuple_ref(gr_tags::get_value(tstamp), 1)); last_frac_stamp = pmt::pmt_to_double(pmt::pmt_tuple_ref(tstamp.value, 1));
ts_sample = gr_tags::get_nitems(tstamp); ts_sample = tstamp.offset;
//std::cout << "HEY WE GOT A STAMP AT " << ticks << " TICKS AT SAMPLE " << ts_sample << " ABS SAMPLE CNT IS " << abs_sample_cnt << std::endl; //std::cout << "HEY WE GOT A STAMP AT " << ticks << " TICKS AT SAMPLE " << ts_sample << " ABS SAMPLE CNT IS " << abs_sample_cnt << std::endl;
return double(abs_sample_cnt * secs_per_sample) + last_whole_stamp + last_frac_stamp; return double(abs_sample_cnt * secs_per_sample) + last_whole_stamp + last_frac_stamp;
} }
@ -110,7 +110,7 @@ int air_modes_preamble::general_work(int noutput_items,
}; };
uint64_t abs_sample_cnt = nitems_read(0); uint64_t abs_sample_cnt = nitems_read(0);
std::vector<pmt::pmt_t> tstamp_tags; std::vector<gr_tag_t> tstamp_tags;
get_tags_in_range(tstamp_tags, 0, abs_sample_cnt, abs_sample_cnt + ninputs, pmt::pmt_string_to_symbol("timestamp")); get_tags_in_range(tstamp_tags, 0, abs_sample_cnt, abs_sample_cnt + ninputs, pmt::pmt_string_to_symbol("timestamp"));
//tags.back() is the most recent timestamp, then. //tags.back() is the most recent timestamp, then.
if(tstamp_tags.size() > 0) { if(tstamp_tags.size() > 0) {
@ -175,8 +175,8 @@ int air_modes_preamble::general_work(int noutput_items,
//get the timestamp of the preamble //get the timestamp of the preamble
double tstamp = 0; double tstamp = 0;
if(d_timestamp) { if(d_timestamp.offset != 0) {
tstamp = pmt_to_timestamp(d_timestamp, abs_sample_cnt + i, d_secs_per_sample); tstamp = tag_to_timestamp(d_timestamp, abs_sample_cnt + i, d_secs_per_sample);
} }
//now tag the preamble //now tag the preamble

View File

@ -48,7 +48,7 @@ private:
float d_threshold_db; float d_threshold_db;
float d_threshold; float d_threshold;
pmt::pmt_t d_me, d_key; pmt::pmt_t d_me, d_key;
pmt::pmt_t d_timestamp; gr_tag_t d_timestamp;
double d_secs_per_sample; double d_secs_per_sample;
public: public:

View File

@ -59,15 +59,6 @@ air_modes_slicer::air_modes_slicer(int channel_rate, gr_msg_queue_sptr queue) :
set_output_multiple(1+d_check_width); //how do you specify buffer size for sinks? set_output_multiple(1+d_check_width); //how do you specify buffer size for sinks?
} }
//FIXME i'm sure this exists in gr
static bool pmtcompare(pmt::pmt_t x, pmt::pmt_t y)
{
uint64_t t_x, t_y;
t_x = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(x, 0));
t_y = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(y, 0));
return t_x < t_y;
}
//this slicer is courtesy of Lincoln Labs. supposedly it is more resistant to mode A/C FRUIT. //this slicer is courtesy of Lincoln Labs. supposedly it is more resistant to mode A/C FRUIT.
//see http://adsb.tc.faa.gov/WG3_Meetings/Meeting8/Squitter-Lon.pdf //see http://adsb.tc.faa.gov/WG3_Meetings/Meeting8/Squitter-Lon.pdf
static slice_result_t slicer(const float bit0, const float bit1, const float ref) { static slice_result_t slicer(const float bit0, const float bit1, const float ref) {
@ -112,13 +103,13 @@ int air_modes_slicer::work(int noutput_items,
const float *in = (const float *) input_items[0]; const float *in = (const float *) input_items[0];
int size = noutput_items - d_check_width; //since it's a sync block, i assume that it runs with ninput_items = noutput_items int size = noutput_items - d_check_width; //since it's a sync block, i assume that it runs with ninput_items = noutput_items
std::vector<pmt::pmt_t> tags; std::vector<gr_tag_t> tags;
uint64_t abs_sample_cnt = nitems_read(0); uint64_t abs_sample_cnt = nitems_read(0);
get_tags_in_range(tags, 0, abs_sample_cnt, abs_sample_cnt + size, pmt::pmt_string_to_symbol("preamble_found")); get_tags_in_range(tags, 0, abs_sample_cnt, abs_sample_cnt + size, pmt::pmt_string_to_symbol("preamble_found"));
std::vector<pmt::pmt_t>::iterator tag_iter; std::vector<gr_tag_t>::iterator tag_iter;
for(tag_iter = tags.begin(); tag_iter != tags.end(); tag_iter++) { for(tag_iter = tags.begin(); tag_iter != tags.end(); tag_iter++) {
uint64_t i = gr_tags::get_nitems(*tag_iter) - abs_sample_cnt; uint64_t i = tag_iter->offset - abs_sample_cnt;
modes_packet rx_packet; modes_packet rx_packet;
memset(&rx_packet.data, 0x00, 14 * sizeof(unsigned char)); memset(&rx_packet.data, 0x00, 14 * sizeof(unsigned char));
@ -163,7 +154,7 @@ int air_modes_slicer::work(int noutput_items,
} }
/******************** BEGIN TIMESTAMP BS ******************/ /******************** BEGIN TIMESTAMP BS ******************/
rx_packet.timestamp = pmt_to_double(gr_tags::get_value(*tag_iter)); rx_packet.timestamp = pmt_to_double(tag_iter->value);
/******************* END TIMESTAMP BS *********************/ /******************* END TIMESTAMP BS *********************/
//increment for the next round //increment for the next round