gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const float *in = (const float *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
// get the lowest count of items of the input and output buffer
int ninput_noutput_min = std::min(noutput_items, ninput_items[0]);
// create a vector of type tag_t which can hold the tag information of found tags
std::vector<tag_t> tags;
// store the distance between the first sample in the input buffer and the tag
int nitems_read_tag_delta = 0;
int tag_offset = 0;
int ninput_items_tag_offset_delta = 0;
if (d_tag_found)
{
std::cout << "Tag found before - get the remaining data" << std::endl;
// there was one tag already in the previous call of the work-function
// copy the remaining data into the array
int tmp = d_read_counter;
for (int i = 0; i < ninput_items[0]; i++)
{
/* check if the iteration variable "i" is equal to the max count of samples per symbol
* or if the counter variable "d_read_counter" is equal the max count of samples per symbol
*/
if ((i == d_samples_per_symbol) || (d_read_counter == d_samples_per_symbol))
{
// reset the d_read_counter
d_read_counter = 0;
d_ready_for_correlation = true;
std::cout << "********* !!!READY FOR CORRELATION!!! *********" << std::endl;
// leave the for-loop because the necessary amount of data is available for correlation
break;
}
else{
// store the samples in the vector for correlation
d_vppm_symbol_samples[i + tmp] = in[i];
d_read_counter++;
}
} // end for-loop
std::cout << "d_tag_found=true d_read_counter: " << d_read_counter << std::endl;
}
else // no tag found yet
{
// get all tags that are stored in the sample stream
get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + ninput_items[0], d_lengthtag);
// check if tags were found in the bunch of samples in input buffer
if (tags.size() > 0)
{
d_tag_found = true;
// There was a tag in the sample stream!
std::cout << "Tag found - move on!!" << std::endl;
std::cout << "count of tags: " << tags.size() << std::endl; // this line prints the count of tags that were found
// store the offset between the first sample of the input stream and the tag
tag_offset = tags[0].offset;
// the delta between ID of tag.offset and first item of input_buffer
nitems_read_tag_delta = tag_offset - nitems_read(0);
// get the count of samples that can be copied from the tag until the end of the current input buffer samples
ninput_items_tag_offset_delta = ninput_items[0] - (nitems_read_tag_delta);
// copy all items after the tag
for (int i = 0; i < ninput_items_tag_offset_delta; i++)
{
if (i == d_samples_per_symbol) //((i == d_samples_per_symbol) || (d_read_counter == d_samples_per_symbol))
{
//reset variables and exit the loop
d_read_counter = 0;
std::cout << "********* !!! first attempt READY FOR CORRELATION!!! *********" << std::endl;
d_ready_for_correlation = true;
// leave the for-loop
// next step will be to calculate the correlation
break;
}
else
{
d_vppm_symbol_samples[i] = in[i + tag_offset];
d_read_counter++;
}
if (i == (ninput_items_tag_offset_delta - 1))
{
std::cout << "Not enough samples yet. Continue with the next call of the work function!" << std::endl;
}
}
std::cout << "d_tag_found=false d_read_counter: " << d_read_counter << std::endl;
} // loop for processing the found tags
}
// skip code.....
// end skip code....
}
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const float *in = (const float *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
// get the lowest count of items of the input and output buffer
int ninput_noutput_min = std::min(noutput_items, ninput_items[0]);
// create a vector of type tag_t which can hold the tag information of found tags
std::vector<tag_t> tags;
// store the distance between the first sample in the input buffer and the tag
int nitems_read_tag_delta = 0;
int tag_offset = 0;
int ninput_items_tag_offset_delta = 0;
if (d_tag_found)
{
std::cout << "Tag found before - get the remaining data" << std::endl;
// there was one tag already in the previous call of the work-function
// copy the remaining data into the array
int tmp = d_read_counter;
for (int i = 0; i < ninput_items[0]; i++)
{
/* check if the iteration variable "i" is equal to the max count of samples per symbol
* or if the counter variable "d_read_counter" is equal the max count of samples per symbol
*/
if ((i == d_samples_per_symbol) || (d_read_counter == d_samples_per_symbol))
{
// reset the d_read_counter
d_read_counter = 0;
d_ready_for_correlation = true;
std::cout << "********* !!!READY FOR CORRELATION!!! *********" << std::endl;
// leave the for-loop because the necessary amount of data is available for correlation
break;
}
else{
// store the samples in the vector for correlation
d_vppm_symbol_samples[i + tmp] = in[i];
d_read_counter++;
}
} // end for-loop
std::cout << "d_tag_found=true d_read_counter: " << d_read_counter << std::endl;
}
else // no tag found yet
{
// get all tags that are stored in the sample stream
get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + ninput_items[0], d_lengthtag);
// check if tags were found in the bunch of samples in input buffer
if (tags.size() > 0)
{
d_tag_found = true;
// There was a tag in the sample stream!
std::cout << "Tag found - move on!!" << std::endl;
std::cout << "count of tags: " << tags.size() << std::endl; // this line prints the count of tags that were found
// store the offset between the first sample of the input stream and the tag
tag_offset = tags[0].offset;
// the delta between ID of tag.offset and first item of input_buffer
nitems_read_tag_delta = tag_offset - nitems_read(0);
// get the count of samples that can be copied from the tag until the end of the current input buffer samples
ninput_items_tag_offset_delta = ninput_items[0] - (nitems_read_tag_delta);
// copy all items after the tag
for (int i = 0; i < ninput_items_tag_offset_delta; i++)
{
if (i == d_samples_per_symbol) //((i == d_samples_per_symbol) || (d_read_counter == d_samples_per_symbol))
{
//reset variables and exit the loop
d_read_counter = 0;
std::cout << "********* !!! first attempt READY FOR CORRELATION!!! *********" << std::endl;
d_ready_for_correlation = true;
// leave the for-loop
// next step will be to calculate the correlation
break;
}
else
{
d_vppm_symbol_samples[i] = in[i + tag_offset];
d_read_counter++;
}
if (i == (ninput_items_tag_offset_delta - 1))
{
std::cout << "Not enough samples yet. Continue with the next call of the work function!" << std::endl;
}
}
std::cout << "d_tag_found=false d_read_counter: " << d_read_counter << std::endl;
} // loop for processing the found tags
}
// skip code.....
// end skip code....
}
No comments:
Post a Comment