X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnuradio-core%2Fsrc%2Flib%2Fgeneral%2Fgr_correlate_access_code_bb.cc;h=43dae6c1a2dbd37ab5f0bb8ea76ab3fd4f080e87;hb=ea29b08aeb54227e6628f655ccfdb96fe4d8c378;hp=4656f8c527d2450c445e01997ecb6daeb35bab3c;hpb=18a684bf3dc144c48fc4cc6cc72f5070febd8074;p=debian%2Fgnuradio diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc index 4656f8c5..43dae6c1 100644 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc +++ b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc @@ -6,7 +6,7 @@ * * 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 2, or (at your option) + * 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, @@ -28,6 +28,8 @@ #include #include #include +#include + #define VERBOSE 0 @@ -45,7 +47,7 @@ gr_correlate_access_code_bb::gr_correlate_access_code_bb ( gr_make_io_signature (1, 1, sizeof(char)), gr_make_io_signature (1, 1, sizeof(char))), d_data_reg(0), d_flag_reg(0), d_flag_bit(0), d_mask(0), - d_threshold(threshold), d_flip(0) + d_threshold(threshold) { if (!set_access_code(access_code)){ @@ -88,13 +90,13 @@ gr_correlate_access_code_bb::work (int noutput_items, { const unsigned char *in = (const unsigned char *) input_items[0]; unsigned char *out = (unsigned char *) output_items[0]; - + for (int i = 0; i < noutput_items; i++){ // compute output value unsigned int t = 0; - t |= d_flip ^ (((d_data_reg >> 63) & 0x1) << 0); + t |= ((d_data_reg >> 63) & 0x1) << 0; t |= ((d_flag_reg >> 63) & 0x1) << 1; // flag bit out[i] = t; @@ -106,12 +108,15 @@ gr_correlate_access_code_bb::work (int noutput_items, wrong_bits = (d_data_reg ^ d_access_code) & d_mask; nwrong = gr_count_bits64(wrong_bits); - // test for access code with up to threshold errors or its compelement - new_flag = (nwrong <= d_threshold) || (nwrong >= (64-d_threshold)); + // test for access code with up to threshold errors + new_flag = (nwrong <= d_threshold); -#if 0 +#if VERBOSE if(new_flag) { - printf("%llx ==> %llx : d_flip=%u\n", d_access_code, d_data_reg, d_flip); + fprintf(stderr, "access code found: %llx\n", d_access_code); + } + else { + fprintf(stderr, "%llx ==> %llx\n", d_access_code, d_data_reg); } #endif @@ -120,7 +125,6 @@ gr_correlate_access_code_bb::work (int noutput_items, d_flag_reg = (d_flag_reg << 1); if (new_flag) { d_flag_reg |= d_flag_bit; - d_flip = nwrong >= (64-d_threshold); // flip bits if this is true } }