summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2011-07-21 23:35:03 -0400
committerTom Rondeau <trondeau@vt.edu>2011-07-21 23:35:03 -0400
commita444c2a5cf19333f981d007be7f6ecb96f85bb6a (patch)
treeb1d8698841d4dcafae36c418e1fb5fe1470db897 /gnuradio-core/src
parentbe7f6400a03e0294aee51b084899b38ed0e83180 (diff)
digital: moving correlate_access_code to gr-digital.
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/guile/tests/general_ctors.test6
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am3
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc133
-rw-r--r--gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h83
-rw-r--r--gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i60
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/Makefile.am1
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py83
8 files changed, 0 insertions, 371 deletions
diff --git a/gnuradio-core/src/guile/tests/general_ctors.test b/gnuradio-core/src/guile/tests/general_ctors.test
index 26233b253d..06cd395330 100644
--- a/gnuradio-core/src/guile/tests/general_ctors.test
+++ b/gnuradio-core/src/guile/tests/general_ctors.test
@@ -100,12 +100,6 @@
;;; ./general/gr_copy.h
(pass-if (true? (gr:copy 1)))
-;;; ./general/gr_correlate_access_code_bb.h
-(pass-if (true? (gr:correlate-access-code-bb "foo" 0)))
-(pass-if-throw "confirm throw correlate-access-code-bb" #t
- (true? (gr:correlate-access-code-bb
- "00000000000000000000000000000000000000000000000000000000000000000" 0)))
-
;;; ./general/gr_cpfsk_bc.h
(pass-if (true? (gr:cpfsk-bc 1 1 1)))
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index f3244d4dbb..ed6717c4d8 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -53,7 +53,6 @@ libgeneral_la_SOURCES = \
gr_complex_to_xxx.cc \
gr_conjugate_cc.cc \
gr_copy.cc \
- gr_correlate_access_code_bb.cc \
gr_count_bits.cc \
gr_cpfsk_bc.cc \
gr_crc32.cc \
@@ -204,7 +203,6 @@ grinclude_HEADERS = \
gr_complex_to_xxx.h \
gr_conjugate_cc.h \
gr_copy.h \
- gr_correlate_access_code_bb.h \
gr_count_bits.h \
gr_cpfsk_bc.h \
gr_crc32.h \
@@ -372,7 +370,6 @@ swiginclude_HEADERS = \
gr_complex_to_xxx.i \
gr_conjugate_cc.i \
gr_copy.i \
- gr_correlate_access_code_bb.i \
gr_cpfsk_bc.i \
gr_crc32.i \
gr_ctcss_squelch_ff.i \
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 37e304481c..d4bad60b84 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -105,7 +105,6 @@
#include <gr_test_types.h>
#include <gr_test.h>
#include <gr_unpack_k_bits_bb.h>
-#include <gr_correlate_access_code_bb.h>
#include <gr_diff_phasor_cc.h>
#include <gr_diff_encoder_bb.h>
#include <gr_diff_decoder_bb.h>
@@ -225,7 +224,6 @@
%include "gr_test_types.h"
%include "gr_test.i"
%include "gr_unpack_k_bits_bb.i"
-%include "gr_correlate_access_code_bb.i"
%include "gr_diff_phasor_cc.i"
%include "gr_diff_encoder_bb.i"
%include "gr_diff_decoder_bb.i"
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
deleted file mode 100644
index 15f6734111..0000000000
--- a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2006,2010 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gr_correlate_access_code_bb.h>
-#include <gr_io_signature.h>
-#include <stdexcept>
-#include <gr_count_bits.h>
-#include <cstdio>
-
-
-#define VERBOSE 0
-
-
-gr_correlate_access_code_bb_sptr
-gr_make_correlate_access_code_bb (const std::string &access_code, int threshold)
-{
- return gnuradio::get_initial_sptr(new gr_correlate_access_code_bb (access_code, threshold));
-}
-
-
-gr_correlate_access_code_bb::gr_correlate_access_code_bb (
- const std::string &access_code, int threshold)
- : gr_sync_block ("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)
-
-{
- if (!set_access_code(access_code)){
- fprintf(stderr, "gr_correlate_access_code_bb: access_code is > 64 bits\n");
- throw std::out_of_range ("access_code is > 64 bits");
- }
-}
-
-gr_correlate_access_code_bb::~gr_correlate_access_code_bb ()
-{
-}
-
-bool
-gr_correlate_access_code_bb::set_access_code(
- const std::string &access_code)
-{
- unsigned len = access_code.length(); // # of bytes in string
- if (len > 64)
- return false;
-
- // set len top bits to 1.
- d_mask = ((~0ULL) >> (64 - len)) << (64 - len);
-
- d_flag_bit = 1LL << (64 - len); // Where we or-in new flag values.
- // new data always goes in 0x0000000000000001
- d_access_code = 0;
- for (unsigned i=0; i < 64; i++){
- d_access_code <<= 1;
- if (i < len)
- d_access_code |= access_code[i] & 1; // look at LSB only
- }
-
- return true;
-}
-
-int
-gr_correlate_access_code_bb::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_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_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;
- int new_flag = 0;
-
- 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
- new_flag = (nwrong <= d_threshold);
-
-#if VERBOSE
- if(new_flag) {
- fprintf(stderr, "access code found: %llx\n", d_access_code);
- }
- else {
- fprintf(stderr, "%llx ==> %llx\n", d_access_code, d_data_reg);
- }
-#endif
-
- // shift in new data and new flag
- d_data_reg = (d_data_reg << 1) | (in[i] & 0x1);
- d_flag_reg = (d_flag_reg << 1);
- if (new_flag) {
- d_flag_reg |= d_flag_bit;
- }
- }
-
- return noutput_items;
-}
-
diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h
deleted file mode 100644
index 581713c147..0000000000
--- a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2006 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.
- */
-
-#ifndef INCLUDED_GR_CORRELATE_ACCESS_CODE_BB_H
-#define INCLUDED_GR_CORRELATE_ACCESS_CODE_BB_H
-
-#include <gr_sync_block.h>
-#include <string>
-
-class gr_correlate_access_code_bb;
-typedef boost::shared_ptr<gr_correlate_access_code_bb> gr_correlate_access_code_bb_sptr;
-
-/*!
- * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100"
- * \param threshold maximum number of bits that may be wrong
- */
-gr_correlate_access_code_bb_sptr
-gr_make_correlate_access_code_bb (const std::string &access_code, int threshold);
-
-/*!
- * \brief Examine input for specified access code, one bit at a time.
- * \ingroup sync_blk
- *
- * input: stream of bits, 1 bit per input byte (data in LSB)
- * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit)
- *
- * Each output byte contains two valid bits, the data bit, and the
- * flag bit. The LSB (bit 0) is the data bit, and is the original
- * input data, delayed 64 bits. Bit 1 is the
- * flag bit and is 1 if the corresponding data bit is the first data
- * bit following the access code. Otherwise the flag bit is 0.
- */
-class gr_correlate_access_code_bb : public gr_sync_block
-{
- friend gr_correlate_access_code_bb_sptr
- gr_make_correlate_access_code_bb (const std::string &access_code, int threshold);
- private:
- unsigned long long d_access_code; // access code to locate start of packet
- // access code is left justified in the word
- unsigned long long d_data_reg; // used to look for access_code
- unsigned long long d_flag_reg; // keep track of decisions
- unsigned long long d_flag_bit; // mask containing 1 bit which is location of new flag
- unsigned long long d_mask; // masks access_code bits (top N bits are set where
- // N is the number of bits in the access code)
- unsigned int d_threshold; // how many bits may be wrong in sync vector
-
- protected:
- gr_correlate_access_code_bb(const std::string &access_code, int threshold);
-
- public:
- ~gr_correlate_access_code_bb();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
-
- /*!
- * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100"
- */
- bool set_access_code (const std::string &access_code);
-};
-
-#endif /* INCLUDED_GR_CORRELATE_ACCESS_CODE_BB_H */
diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i
deleted file mode 100644
index bec4282f12..0000000000
--- a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,correlate_access_code_bb);
-
-/*!
- * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100"
- * \param threshold maximum number of bits that may be wrong
- */
-gr_correlate_access_code_bb_sptr
-gr_make_correlate_access_code_bb (const std::string &access_code, int threshold)
- throw(std::out_of_range);
-
-/*!
- * \brief Examine input for specified access code, one bit at a time.
- * \ingroup block
- *
- * input: stream of bits, 1 bit per input byte (data in LSB)
- * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit)
- *
- * Each output byte contains two valid bits, the data bit, and the
- * flag bit. The LSB (bit 0) is the data bit, and is the original
- * input data, delayed 64 bits. Bit 1 is the
- * flag bit and is 1 if the corresponding data bit is the first data
- * bit following the access code. Otherwise the flag bit is 0.
- */
-class gr_correlate_access_code_bb : public gr_sync_block
-{
- friend gr_correlate_access_code_bb_sptr
- gr_make_correlate_access_code_bb (const std::string &access_code, int threshold);
- protected:
- gr_correlate_access_code_bb(const std::string &access_code, int threshold);
-
- public:
- ~gr_correlate_access_code_bb();
-
- /*!
- * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100"
- */
- bool set_access_code (const std::string &access_code);
-};
diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am
index 640baf6f77..7bf1c0827e 100644
--- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am
@@ -51,7 +51,6 @@ noinst_PYTHON = \
qa_classify.py \
qa_complex_to_xxx.py \
qa_copy.py \
- qa_correlate_access_code.py \
qa_delay.py \
qa_dc_blocker.py \
qa_diff_encoder.py \
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py b/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py
deleted file mode 100755
index b3575f4e6b..0000000000
--- a/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2006,2007,2010 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
-import math
-
-default_access_code = '\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC'
-
-def string_to_1_0_list(s):
- r = []
- for ch in s:
- x = ord(ch)
- for i in range(8):
- t = (x >> i) & 0x1
- r.append(t)
-
- return r
-
-def to_1_0_string(L):
- return ''.join(map(lambda x: chr(x + ord('0')), L))
-
-class test_correlate_access_code(gr_unittest.TestCase):
-
- def setUp(self):
- self.tb = gr.top_block()
-
- def tearDown(self):
- self.tb = None
-
- def test_001(self):
- pad = (0,) * 64
- # 0 0 0 1 0 0 0 1
- src_data = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0,) * 7
- expected_result = pad + (1, 0, 1, 1, 3, 1, 0, 1, 1, 2) + (0,) * 6
- src = gr.vector_source_b (src_data)
- op = gr.correlate_access_code_bb("1011", 0)
- dst = gr.vector_sink_b ()
- self.tb.connect (src, op, dst)
- self.tb.run ()
- result_data = dst.data ()
- self.assertEqual (expected_result, result_data)
-
-
- def test_002(self):
- code = tuple(string_to_1_0_list(default_access_code))
- access_code = to_1_0_string(code)
- pad = (0,) * 64
- #print code
- #print access_code
- src_data = code + (1, 0, 1, 1) + pad
- expected_result = pad + code + (3, 0, 1, 1)
- src = gr.vector_source_b (src_data)
- op = gr.correlate_access_code_bb(access_code, 0)
- dst = gr.vector_sink_b ()
- self.tb.connect (src, op, dst)
- self.tb.run ()
- result_data = dst.data ()
- self.assertEqual (expected_result, result_data)
-
-
-
-if __name__ == '__main__':
- gr_unittest.run(test_correlate_access_code, "test_correlate_access_code.xml")
-