From 5ac5c8aca8f75b2a6e2d0aa0a2ecbb1c1f18e481 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 17 Nov 2011 15:16:56 -0800 Subject: [PATCH] Modified for new new tags interface --- src/lib/air_modes_preamble.cc | 16 ++++++++-------- src/lib/air_modes_preamble.h | 2 +- src/lib/air_modes_slicer.cc | 17 ++++------------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/lib/air_modes_preamble.cc b/src/lib/air_modes_preamble.cc index dc85d91..dbb9af2 100644 --- a/src/lib/air_modes_preamble.cc +++ b/src/lib/air_modes_preamble.cc @@ -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 -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; 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_frac_stamp = pmt_to_double(pmt_tuple_ref(gr_tags::get_value(tstamp), 1)); - ts_sample = gr_tags::get_nitems(tstamp); + last_whole_stamp = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(tstamp.value, 0)); + last_frac_stamp = pmt::pmt_to_double(pmt::pmt_tuple_ref(tstamp.value, 1)); + 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; 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); - std::vector tstamp_tags; + std::vector tstamp_tags; 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. if(tstamp_tags.size() > 0) { @@ -175,8 +175,8 @@ int air_modes_preamble::general_work(int noutput_items, //get the timestamp of the preamble double tstamp = 0; - if(d_timestamp) { - tstamp = pmt_to_timestamp(d_timestamp, abs_sample_cnt + i, d_secs_per_sample); + if(d_timestamp.offset != 0) { + tstamp = tag_to_timestamp(d_timestamp, abs_sample_cnt + i, d_secs_per_sample); } //now tag the preamble diff --git a/src/lib/air_modes_preamble.h b/src/lib/air_modes_preamble.h index 03d9bbe..2158a5a 100644 --- a/src/lib/air_modes_preamble.h +++ b/src/lib/air_modes_preamble.h @@ -48,7 +48,7 @@ private: float d_threshold_db; float d_threshold; pmt::pmt_t d_me, d_key; - pmt::pmt_t d_timestamp; + gr_tag_t d_timestamp; double d_secs_per_sample; public: diff --git a/src/lib/air_modes_slicer.cc b/src/lib/air_modes_slicer.cc index 6ee3c1c..9d7c3c1 100644 --- a/src/lib/air_modes_slicer.cc +++ b/src/lib/air_modes_slicer.cc @@ -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? } -//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. //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) { @@ -112,13 +103,13 @@ int air_modes_slicer::work(int noutput_items, 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 - std::vector tags; + std::vector tags; 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")); - std::vector::iterator tag_iter; + std::vector::iterator 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; memset(&rx_packet.data, 0x00, 14 * sizeof(unsigned char)); @@ -163,7 +154,7 @@ int air_modes_slicer::work(int noutput_items, } /******************** 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 *********************/ //increment for the next round