commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] gnuradio-core/src/lib/general gr_correlate_acce...


From: Thomas W. Rondeau
Subject: [Commit-gnuradio] gnuradio-core/src/lib/general gr_correlate_acce...
Date: Wed, 28 Jun 2006 18:30:38 +0000

CVSROOT:        /sources/gnuradio
Module name:    gnuradio-core
Changes by:     Thomas W. Rondeau <trondeau1122>        06/06/28 18:30:38

Modified files:
        src/lib/general: gr_correlate_access_code_bb.cc 
                         gr_correlate_access_code_bb.h 
                         gr_correlate_access_code_bb.i 

Log message:
        gr_correlate_access_code_bb now checks the conjugate of the access code 
and corrects of a 180 degree phase revesal -- allows for DBPSK, DQPSK, and 
BPSK; not QPSK

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc?cvsroot=gnuradio&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h?cvsroot=gnuradio&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i?cvsroot=gnuradio&r1=1.2&r2=1.3

Patches:
Index: gr_correlate_access_code_bb.cc
===================================================================
RCS file: 
/sources/gnuradio/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gr_correlate_access_code_bb.cc      30 May 2006 05:58:23 -0000      1.3
+++ gr_correlate_access_code_bb.cc      28 Jun 2006 18:30:38 -0000      1.4
@@ -33,11 +33,9 @@
 
 
 gr_correlate_access_code_bb_sptr
-gr_make_correlate_access_code_bb (const std::string &access_code,
-                                 int threshold)
+gr_make_correlate_access_code_bb (const std::string &access_code, int 
threshold)
 {
-  return gr_correlate_access_code_bb_sptr (new gr_correlate_access_code_bb 
(access_code,
-                                                                           
threshold));
+  return gr_correlate_access_code_bb_sptr (new gr_correlate_access_code_bb 
(access_code, threshold));
 }
 
 
@@ -46,8 +44,9 @@
   : gr_sync_block ("correlate_access_code_bb",
                   gr_make_io_signature (1, 1, sizeof(char)),
                   gr_make_io_signature (1, 1, sizeof(char))),
-    d_access_code(0), d_data_reg(0), d_flag_reg(0), d_flag_bit(0), d_mask(0),
-    d_threshold(threshold)
+    d_data_reg(0), d_flag_reg(0), d_flag_bit(0), d_mask(0),
+    d_threshold(threshold), d_rotation(0)
+
 {
   if (!set_access_code(access_code)){
     fprintf(stderr, "gr_correlate_access_code_bb: access_code is > 64 bits\n");
@@ -72,13 +71,15 @@
 
   d_flag_bit = 1LL << (64 - len);      // Where we or-in new flag values.
                                         // new data always goes in 
0x0000000000000001
-  d_access_code = 0;
+  d_access_code[0] = 0;
   for (unsigned i=0; i < 64; i++){
-    d_access_code <<= 1;
+    d_access_code[0] <<= 1;
     if (i < len)
-      d_access_code |= access_code[i] & 1;     // look at LSB only
+      d_access_code[0] |= access_code[i] & 1;  // look at LSB only
   }
 
+  d_access_code[1] = ~d_access_code[0]; // used for non-differential BPSK
+  
   return true;
 }
 
@@ -94,20 +95,44 @@
 
     // compute output value
     unsigned int t = 0;
-    t |= ((d_data_reg >> 63) & 0x1) << 0;      // data bit
+
+    // data bit   
+    switch(d_rotation)
+    {
+      case(0):
+      case(1): t |=  ((d_data_reg >> 63) & 0x1) << 0; break;
+      case(2): t |= !((d_data_reg >> 63) & 0x1) << 0; break;
+      default: throw std::out_of_range ("Access code flag out of range");
+    }
     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 = (d_data_reg ^ d_access_code) & d_mask;
-    unsigned int nwrong = gr_count_bits64(wrong_bits);
-    int new_flag =  nwrong <= d_threshold;
+    unsigned long long wrong_bits = 0;
+    unsigned int nwrong = d_threshold+1, nwrong_temp = 0;
+    int new_flag = 0, new_flag_temp = 0;
+
+    for(unsigned int j = 0; j < 2; j++)
+    {
+      wrong_bits  = (d_data_reg ^ d_access_code[j]) & d_mask;
+      nwrong_temp = gr_count_bits64(wrong_bits);
+      new_flag_temp = nwrong_temp <= d_threshold;
+      if(nwrong_temp < nwrong)
+       nwrong = nwrong_temp;
+      if(new_flag_temp)
+       new_flag = j+1;    // mark which access code correlated closest
+    }
+
+    //if(new_flag) 
+    //  printf("%llx  :  %llx ==> %llx\n", d_access_code[0], d_access_code[1], 
d_data_reg);
 
     // 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_rotation = new_flag;
       d_flag_reg |= d_flag_bit;
+      //printf("\nAccess Code Found, bad bits = %d\n", nwrong);
     }
   }
 

Index: gr_correlate_access_code_bb.h
===================================================================
RCS file: 
/sources/gnuradio/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- gr_correlate_access_code_bb.h       24 May 2006 15:46:16 -0000      1.1
+++ gr_correlate_access_code_bb.h       28 Jun 2006 18:30:38 -0000      1.2
@@ -34,8 +34,7 @@
  * \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);
+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.
@@ -53,10 +52,9 @@
 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);
+  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
+  unsigned long long d_access_code[2]; // 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
@@ -64,10 +62,11 @@
   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
+  unsigned int       d_rotation;        // derotate the phase of the input
+
 
  protected:
-  gr_correlate_access_code_bb(const std::string &access_code, 
-                             int threshold);
+  gr_correlate_access_code_bb(const std::string &access_code, int threshold);
 
  public:
   ~gr_correlate_access_code_bb();

Index: gr_correlate_access_code_bb.i
===================================================================
RCS file: 
/sources/gnuradio/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gr_correlate_access_code_bb.i       30 May 2006 05:58:23 -0000      1.2
+++ gr_correlate_access_code_bb.i       28 Jun 2006 18:30:38 -0000      1.3
@@ -27,9 +27,8 @@
  * \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);
+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.
@@ -47,11 +46,9 @@
 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);
+  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);
+  gr_correlate_access_code_bb(const std::string &access_code, int threshold);
 
  public:
   ~gr_correlate_access_code_bb();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]