All tags, all the time. Still some weirdness with set_history() that requires using the check widths in the framer & slicer.
This commit is contained in:
parent
cd394e1863
commit
f8966f0d10
@ -40,7 +40,7 @@ air_modes_framer_sptr air_make_modes_framer(int channel_rate)
|
|||||||
air_modes_framer::air_modes_framer(int channel_rate) :
|
air_modes_framer::air_modes_framer(int channel_rate) :
|
||||||
gr_sync_block ("modes_framer",
|
gr_sync_block ("modes_framer",
|
||||||
gr_make_io_signature (1, 1, sizeof(float)), //stream 0 is received data
|
gr_make_io_signature (1, 1, sizeof(float)), //stream 0 is received data
|
||||||
gr_make_io_signature (1, 1, sizeof(unsigned char))) //output is [0, 1, 2]: [no frame, short frame, long frame]
|
gr_make_io_signature (1, 1, sizeof(float))) //raw samples passed back out
|
||||||
{
|
{
|
||||||
//initialize private data here
|
//initialize private data here
|
||||||
d_chip_rate = 2000000; //2Mchips per second
|
d_chip_rate = 2000000; //2Mchips per second
|
||||||
@ -49,6 +49,11 @@ air_modes_framer::air_modes_framer(int channel_rate) :
|
|||||||
d_check_width = 120 * d_samples_per_symbol; //gotta be able to look at two long frame lengths at a time
|
d_check_width = 120 * d_samples_per_symbol; //gotta be able to look at two long frame lengths at a time
|
||||||
//in the event that FRUIT occurs near the end of the first frame
|
//in the event that FRUIT occurs near the end of the first frame
|
||||||
//set_history(d_check_width*2);
|
//set_history(d_check_width*2);
|
||||||
|
|
||||||
|
std::stringstream str;
|
||||||
|
str << name() << unique_id();
|
||||||
|
d_me = pmt::pmt_string_to_symbol(str.str());
|
||||||
|
d_key = pmt::pmt_string_to_symbol("frame_info");
|
||||||
}
|
}
|
||||||
|
|
||||||
int air_modes_framer::work(int noutput_items,
|
int air_modes_framer::work(int noutput_items,
|
||||||
@ -57,8 +62,8 @@ int air_modes_framer::work(int noutput_items,
|
|||||||
{
|
{
|
||||||
//do things!
|
//do things!
|
||||||
const float *inraw = (const float *) input_items[0];
|
const float *inraw = (const float *) input_items[0];
|
||||||
//float *outraw = (float *) output_items[0];
|
float *outraw = (float *) output_items[0];
|
||||||
unsigned char *outattrib = (unsigned char *) output_items[0];
|
//unsigned char *outattrib = (unsigned char *) output_items[0];
|
||||||
int size = noutput_items - d_check_width*2;
|
int size = noutput_items - d_check_width*2;
|
||||||
float reference_level;
|
float reference_level;
|
||||||
framer_packet_type packet_attrib;
|
framer_packet_type packet_attrib;
|
||||||
@ -68,7 +73,7 @@ int air_modes_framer::work(int noutput_items,
|
|||||||
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<pmt::pmt_t>::iterator tag_iter;
|
||||||
|
|
||||||
memset(outattrib, 0x00, size * sizeof(unsigned char));
|
memcpy(outraw, inraw, size * sizeof(float));
|
||||||
|
|
||||||
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 = gr_tags::get_nitems(*tag_iter) - abs_sample_cnt;
|
||||||
@ -106,7 +111,13 @@ int air_modes_framer::work(int noutput_items,
|
|||||||
get_tags_in_range(fruit_tags, 0, abs_sample_cnt+i+1, abs_sample_cnt+i+lookahead, pmt::pmt_string_to_symbol("preamble_found"));
|
get_tags_in_range(fruit_tags, 0, abs_sample_cnt+i+1, abs_sample_cnt+i+lookahead, pmt::pmt_string_to_symbol("preamble_found"));
|
||||||
if(fruit_tags.size() > 0) packet_attrib = Fruited_Packet;
|
if(fruit_tags.size() > 0) packet_attrib = Fruited_Packet;
|
||||||
|
|
||||||
outattrib[i] = packet_attrib;
|
//insert tag here
|
||||||
|
add_item_tag(0, //stream ID
|
||||||
|
nitems_written(0)+i, //sample
|
||||||
|
d_key, //preamble_found
|
||||||
|
pmt::pmt_from_long((long)packet_attrib),
|
||||||
|
d_me //block src id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -44,6 +44,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;
|
||||||
|
pmt::pmt_t d_me, d_key;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int work (int noutput_items,
|
int work (int noutput_items,
|
||||||
|
@ -51,7 +51,7 @@ air_modes_preamble::air_modes_preamble(int channel_rate, float threshold_db) :
|
|||||||
str << name() << unique_id();
|
str << name() << unique_id();
|
||||||
d_me = pmt::pmt_string_to_symbol(str.str());
|
d_me = pmt::pmt_string_to_symbol(str.str());
|
||||||
d_key = pmt::pmt_string_to_symbol("preamble_found");
|
d_key = pmt::pmt_string_to_symbol("preamble_found");
|
||||||
//set_history(d_check_width);
|
set_history(d_check_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
int air_modes_preamble::work(int noutput_items,
|
int air_modes_preamble::work(int noutput_items,
|
||||||
@ -64,7 +64,7 @@ int air_modes_preamble::work(int noutput_items,
|
|||||||
|
|
||||||
float *outraw = (float *) output_items[0];
|
float *outraw = (float *) output_items[0];
|
||||||
|
|
||||||
int size = noutput_items - d_check_width;
|
int size = noutput_items;// - d_check_width;
|
||||||
int pulse_offsets[4];
|
int pulse_offsets[4];
|
||||||
float bit_energies[4];
|
float bit_energies[4];
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ air_modes_slicer_sptr air_make_modes_slicer(int channel_rate, gr_msg_queue_sptr
|
|||||||
|
|
||||||
air_modes_slicer::air_modes_slicer(int channel_rate, gr_msg_queue_sptr queue) :
|
air_modes_slicer::air_modes_slicer(int channel_rate, gr_msg_queue_sptr queue) :
|
||||||
gr_sync_block ("modes_slicer",
|
gr_sync_block ("modes_slicer",
|
||||||
gr_make_io_signature2 (2, 2, sizeof(float), sizeof(unsigned char)), //stream 0 is received data, stream 1 is binary preamble detector output
|
gr_make_io_signature (1, 1, sizeof(float)), //stream 0 is received data, stream 1 is binary preamble detector output
|
||||||
gr_make_io_signature (0, 0, 0) )
|
gr_make_io_signature (0, 0, 0) )
|
||||||
{
|
{
|
||||||
//initialize private data here
|
//initialize private data here
|
||||||
@ -74,19 +74,24 @@ int air_modes_slicer::work(int noutput_items,
|
|||||||
{
|
{
|
||||||
//do things!
|
//do things!
|
||||||
const float *inraw = (const float *) input_items[0];
|
const float *inraw = (const float *) input_items[0];
|
||||||
const unsigned char *inattrib = (const unsigned char *) input_items[1];
|
|
||||||
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
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < size; i++) {
|
std::vector<pmt::pmt_t> tags;
|
||||||
if(inattrib[i] == framer_packet_type(Short_Packet) || inattrib[i] == framer_packet_type(Long_Packet)) { //if there's a packet starting here....
|
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("frame_info"));
|
||||||
|
std::vector<pmt::pmt_t>::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;
|
||||||
modes_packet rx_packet;
|
modes_packet rx_packet;
|
||||||
|
framer_packet_type packet_type = framer_packet_type(pmt::pmt_to_long(gr_tags::get_value(*tag_iter)));
|
||||||
|
|
||||||
int packet_length = 112;
|
int packet_length;
|
||||||
if(inattrib[i] == framer_packet_type(Short_Packet)) packet_length = 56;
|
packet_length = packet_type == framer_packet_type(Short_Packet) ? 56 : 112;
|
||||||
|
|
||||||
rx_packet.type = framer_packet_type(inattrib[i]);
|
rx_packet.type = packet_type;
|
||||||
memset(&rx_packet.data, 0x00, 14 * sizeof(unsigned char));
|
memset(&rx_packet.data, 0x00, 14 * sizeof(unsigned char));
|
||||||
memset(&rx_packet.lowconfbits, 0x00, 24 * sizeof(unsigned char));
|
memset(&rx_packet.lowconfbits, 0x00, 24 * sizeof(unsigned char));
|
||||||
rx_packet.numlowconf = 0;
|
rx_packet.numlowconf = 0;
|
||||||
@ -143,7 +148,6 @@ int air_modes_slicer::work(int noutput_items,
|
|||||||
else confidence = 0;
|
else confidence = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//put the data into the packet
|
//put the data into the packet
|
||||||
if(slice) {
|
if(slice) {
|
||||||
rx_packet.data[j/8] += 1 << (7-(j%8));
|
rx_packet.data[j/8] += 1 << (7-(j%8));
|
||||||
@ -193,7 +197,6 @@ int air_modes_slicer::work(int noutput_items,
|
|||||||
/******************* END TIMESTAMP BS *********************/
|
/******************* END TIMESTAMP BS *********************/
|
||||||
|
|
||||||
//increment for the next round
|
//increment for the next round
|
||||||
i += packet_length * d_samples_per_symbol;
|
|
||||||
|
|
||||||
//here you might want to traverse the whole packet and if you find all 0's, just toss it. don't know why these packets turn up, but they pass ECC.
|
//here you might want to traverse the whole packet and if you find all 0's, just toss it. don't know why these packets turn up, but they pass ECC.
|
||||||
bool zeroes = 1;
|
bool zeroes = 1;
|
||||||
@ -252,7 +255,6 @@ int air_modes_slicer::work(int noutput_items,
|
|||||||
//now we have a complete packet with confidence data, let's print it to the message queue
|
//now we have a complete packet with confidence data, let's print it to the message queue
|
||||||
//here, rather than send the entire packet, since we've already done parity checking and ECC in C++, we'll
|
//here, rather than send the entire packet, since we've already done parity checking and ECC in C++, we'll
|
||||||
//send just the data (no confidence bits), separated into fields for easier parsing.
|
//send just the data (no confidence bits), separated into fields for easier parsing.
|
||||||
|
|
||||||
//we'll replicate some data by sending the message type as the first field, followed by the first 8+24=32 bits of the packet, followed by
|
//we'll replicate some data by sending the message type as the first field, followed by the first 8+24=32 bits of the packet, followed by
|
||||||
//56 long packet data bits if applicable (zero-padded if not), followed by parity
|
//56 long packet data bits if applicable (zero-padded if not), followed by parity
|
||||||
|
|
||||||
@ -285,12 +287,10 @@ 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_secs
|
||||||
<< " " << std::setprecision(10) << std::setw(10) << rx_packet.timestamp_frac;
|
<< " " << 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -97,27 +97,12 @@ class adsb_rx_block (gr.top_block):
|
|||||||
self.framer = air.modes_framer(rate)
|
self.framer = air.modes_framer(rate)
|
||||||
self.slicer = air.modes_slicer(rate, queue)
|
self.slicer = air.modes_slicer(rate, queue)
|
||||||
|
|
||||||
#self.nullsink = gr.file_sink(gr.sizeof_gr_complex, "/dev/null")
|
|
||||||
|
|
||||||
#self.connect(self.u, self.nullsink)
|
|
||||||
|
|
||||||
# self.connect(self.u, self.demod, self.filter)
|
|
||||||
# self.connect(self.filter, self.avg)
|
|
||||||
# self.connect(self.filter, (self.preamble, 0))
|
|
||||||
# self.connect(self.avg, (self.preamble, 1))
|
|
||||||
# self.connect(self.filter, (self.framer, 0))
|
|
||||||
# self.connect(self.preamble, (self.framer, 1))
|
|
||||||
# self.connect(self.filter, (self.slicer, 0))
|
|
||||||
# self.connect(self.framer, (self.slicer, 1))
|
|
||||||
|
|
||||||
#use this flowgraph instead to omit the filter
|
|
||||||
self.connect(self.u, self.demod)
|
self.connect(self.u, self.demod)
|
||||||
self.connect(self.demod, self.avg)
|
self.connect(self.demod, self.avg)
|
||||||
self.connect(self.demod, (self.preamble, 0))
|
self.connect(self.demod, (self.preamble, 0))
|
||||||
self.connect(self.avg, (self.preamble, 1))
|
self.connect(self.avg, (self.preamble, 1))
|
||||||
self.connect((self.preamble, 0), (self.framer, 0))
|
self.connect((self.preamble, 0), (self.framer, 0))
|
||||||
self.connect(self.demod, (self.slicer, 0))
|
self.connect(self.framer, self.slicer)
|
||||||
self.connect(self.framer, (self.slicer, 1))
|
|
||||||
|
|
||||||
def tune(self, freq):
|
def tune(self, freq):
|
||||||
result = self.u.set_center_freq(freq, 0)
|
result = self.u.set_center_freq(freq, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user