[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/24: Simplify correlate_access_code_tag_b
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/24: Simplify correlate_access_code_tag_bb and fix bug leading to false trigger. |
Date: |
Tue, 18 Mar 2014 17:51:40 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit c2c7c15bdd18406041244cebdcdb3823ca1a1326
Author: Nick Foster <address@hidden>
Date: Thu Mar 13 10:22:01 2014 -0700
Simplify correlate_access_code_tag_bb and fix bug leading to false
trigger.
---
.../lib/correlate_access_code_tag_bb_impl.cc | 36 +++++++++++++---------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
index 0d64caa..478dadc 100644
--- a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
+++ b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
@@ -27,7 +27,8 @@
#include "correlate_access_code_tag_bb_impl.h"
#include <gnuradio/io_signature.h>
#include <stdexcept>
-#include <gnuradio/blocks/count_bits.h>
+//#include <gnuradio/blocks/count_bits.h>
+#include <volk/volk.h>
#include <cstdio>
#include <iostream>
@@ -75,16 +76,18 @@ namespace gr {
{
d_len = access_code.length(); // # of bytes in string
if(d_len > 64)
- return false;
+ return false;
- // set len top bits to 1.
- d_mask = ((~0ULL) >> (64 - d_len)) << (64 - d_len);
+ // set d_len bottom bits to 1.
+ d_mask = (1 << d_len) - 1;
d_access_code = 0;
- for(unsigned i=0; i < 64; i++){
- d_access_code <<= 1;
- if(i < d_len)
- d_access_code |= access_code[i] & 1; // look at LSB only
+ for(unsigned i=0; i < d_len; i++){
+ d_access_code = (d_access_code << 1) | (access_code[i] & 1);
+ }
+ if(VERBOSE) {
+ std::cout << "Access code: " << std::hex << d_access_code <<
std::dec << std::endl;
+ std::cout << "Mask: " << std::hex << d_mask << std::dec << std::endl;
}
return true;
@@ -100,16 +103,19 @@ namespace gr {
uint64_t abs_out_sample_cnt = nitems_written(0);
- for(int i = 0; i < noutput_items; i++) {
+ int size = noutput_items-d_len;
+ if(size<=0) return 0;
+
+ for(int i = 0; i < size; i++) {
out[i] = in[i];
// compute hamming distance between desired access code and current data
- unsigned long long wrong_bits = 0;
- unsigned int nwrong = d_threshold+1;
+ uint64_t wrong_bits = 0;
+ uint64_t nwrong = d_threshold+1;
int new_flag = 0;
wrong_bits = (d_data_reg ^ d_access_code) & d_mask;
- nwrong = gr::blocks::count_bits64(wrong_bits);
+ volk_64u_popcnt(&nwrong, wrong_bits);
// test for access code with up to threshold errors
new_flag = (nwrong <= d_threshold);
@@ -120,15 +126,15 @@ namespace gr {
if(VERBOSE)
std::cerr << "writing tag at sample " << abs_out_sample_cnt + i <<
std::endl;
add_item_tag(0, //stream ID
- abs_out_sample_cnt + i - 64 + d_len, //sample
+ abs_out_sample_cnt + i, //sample
d_key, //frame info
- pmt::pmt_t(), //data (unused)
+ pmt::from_long(nwrong), //data (unused)
d_me //block src id
);
}
}
- return noutput_items;
+ return size;
}
} /* namespace digital */
- [Commit-gnuradio] [gnuradio] 06/24: qtgui: Adding a Number sink with options to set autoscale, layout style, colors, averaging., (continued)
- [Commit-gnuradio] [gnuradio] 06/24: qtgui: Adding a Number sink with options to set autoscale, layout style, colors, averaging., git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 04/24: Simplify some more., git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 03/24: Move correlate_access_code_tag_bb to non-deprecated GRC category and deprecate the older correlate_access_code_bb., git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 20/24: Merge remote-tracking branch 'skoslowski/grc_show_missing_blocks', git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 09/24: grc: tabbed PropsDialog, git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 19/24: Merge remote-tracking branch 'gnuradio-wg-grc/grc_pygtk_backw_compat_fixes', git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 12/24: grc: special colors for missing blocks, git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 18/24: qtgui: fixes number sink to handle Python/C++ exposure (see: 6a78af5919133 and d9dbb6b489deb), git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 22/24: qtgui: fixing up a few minor details; include file and ability to set accumulate checkable on startup., git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 10/24: Merge branch 'qtgui_numsink', git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 02/24: Simplify correlate_access_code_tag_bb and fix bug leading to false trigger.,
git <=
- [Commit-gnuradio] [gnuradio] 23/24: Merge remote-tracking branch 'mbant/doxygen-updates', git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 16/24: qtgui: fixed number display for qwt 5.2, 6.0, and 6.1., git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 08/24: gr-qtgui: Expose the qwidget() method in the public interface, git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 21/24: Merge remote-tracking branch 'bistromath/corr_tag', git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 24/24: Merge branch 'maint', git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 01/24: docs: Updated Doxy files, added search bar, git, 2014/03/18
- [Commit-gnuradio] [gnuradio] 13/24: qtgui: adding a 'config' tab to qtgui sinks to set display/line config options (style, width, colors, etc.), git, 2014/03/18