summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-03-27 14:29:03 -0700
committerTom Rondeau <tom@trondeau.com>2014-05-17 17:45:12 -0400
commitba2951861b99f59df79022f98f51a12273fe2aa8 (patch)
treec6aea86a1ef99b48a68fdfcf12be45f9bddcf611
parent3bb2c431a547baf97548ec86f89b7a3a770df2cc (diff)
digital: correlate_access_code_tag d_mask was set improperly when access code len = 64.
-rw-r--r--gr-digital/lib/correlate_access_code_bb_impl.cc12
-rw-r--r--gr-digital/lib/correlate_access_code_tag_bb_impl.cc8
-rwxr-xr-xgr-digital/python/digital/qa_correlate_access_code.py14
3 files changed, 16 insertions, 18 deletions
diff --git a/gr-digital/lib/correlate_access_code_bb_impl.cc b/gr-digital/lib/correlate_access_code_bb_impl.cc
index dea831dfbc..532871a407 100644
--- a/gr-digital/lib/correlate_access_code_bb_impl.cc
+++ b/gr-digital/lib/correlate_access_code_bb_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
/*
* Copyright 2004,2006,2010-2012 Free Software Foundation, Inc.
- *
+ *
* This file is part of GNU Radio
- *
+ *
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -97,7 +97,7 @@ namespace gr {
t |= ((d_data_reg >> 63) & 0x1) << 0;
t |= ((d_flag_reg >> 63) & 0x1) << 1; // flag bit
out[i] = t;
-
+
// compute hamming distance between desired access code and current data
unsigned long long wrong_bits = 0;
unsigned int nwrong = d_threshold+1;
@@ -128,6 +128,6 @@ namespace gr {
return noutput_items;
}
-
+
} /* namespace digital */
} /* namespace gr */
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 f6574dd517..31ae6d9282 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,6 @@
#include "correlate_access_code_tag_bb_impl.h"
#include <gnuradio/io_signature.h>
#include <stdexcept>
-//#include <gnuradio/blocks/count_bits.h>
#include <volk/volk.h>
#include <cstdio>
#include <iostream>
@@ -78,8 +77,8 @@ namespace gr {
if(d_len > 64)
return false;
- // set d_len bottom bits to 1.
- d_mask = (1ULL << d_len) - 1;
+ // set len top bits to 1.
+ d_mask = ((~0ULL) >> (64 - d_len)) << (64 - d_len);
d_access_code = 0;
for(unsigned i=0; i < d_len; i++){
@@ -113,7 +112,7 @@ namespace gr {
wrong_bits = (d_data_reg ^ d_access_code) & d_mask;
volk_64u_popcnt(&nwrong, wrong_bits);
- // shift in new data and new flag
+ // shift in new data
d_data_reg = (d_data_reg << 1) | (in[i] & 0x1);
if(nwrong <= d_threshold) {
if(VERBOSE)
@@ -132,4 +131,3 @@ namespace gr {
} /* namespace digital */
} /* namespace gr */
-
diff --git a/gr-digital/python/digital/qa_correlate_access_code.py b/gr-digital/python/digital/qa_correlate_access_code.py
index 198a254da7..d89b457117 100755
--- a/gr-digital/python/digital/qa_correlate_access_code.py
+++ b/gr-digital/python/digital/qa_correlate_access_code.py
@@ -1,24 +1,24 @@
#!/usr/bin/env python
#
# Copyright 2006,2007,2010,2011,2013 Free Software Foundation, Inc.
-#
+#
# This file is part of GNU Radio
-#
+#
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
-#
+#
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
-#
+#
from gnuradio import gr, gr_unittest, digital, blocks
@@ -74,7 +74,7 @@ class test_correlate_access_code(gr_unittest.TestCase):
self.tb.run()
result_data = dst.data()
self.assertEqual(expected_result, result_data)
-
+
def test_003(self):
code = tuple(string_to_1_0_list(default_access_code))
access_code = to_1_0_string(code)
@@ -93,4 +93,4 @@ class test_correlate_access_code(gr_unittest.TestCase):
if __name__ == '__main__':
gr_unittest.run(test_correlate_access_code, "test_correlate_access_code.xml")
-
+