commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3507 - gnuradio/branches/developers/jcorgan/pager/gr-


From: jcorgan
Subject: [Commit-gnuradio] r3507 - gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib
Date: Fri, 8 Sep 2006 16:37:03 -0600 (MDT)

Author: jcorgan
Date: 2006-09-08 16:37:03 -0600 (Fri, 08 Sep 2006)
New Revision: 3507

Added:
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.cc
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.h
Modified:
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/Makefile.am
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_sync.cc
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_sync.h
Log:
Work in progress.  Completed baud rate shift logic and SYNC2 header
parsing.


Modified: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/Makefile.am     
2006-09-08 22:02:13 UTC (rev 3506)
+++ gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/Makefile.am     
2006-09-08 22:37:03 UTC (rev 3507)
@@ -62,6 +62,7 @@
 _pgr_la_SOURCES = \
     pgr.cc \
     pgr_slicer_fb.cc \
+    pgr_flex_modes.cc \
     pgr_flex_sync.cc
     # Additional source modules here
 

Added: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.cc   
                            (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.cc   
    2006-09-08 22:37:03 UTC (rev 3507)
@@ -0,0 +1,33 @@
+/*
+ * 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "pgr_flex_modes.h"
+
+const flex_mode_t flex_modes[] = 
+{
+    { 0x870C78F3, 1600, 2, true, false, false, false },
+    { 0xB0684F97, 1600, 4, true, true,  false, false },
+//  { 0xUNKNOWN,  3200, 2, true, false, true,  false },
+    { 0xDEA0215F, 3200, 4, true, true,  true,  true },
+    { 0x4C7CB383, 3200, 4, true, true,  true,  true }
+};
+
+const int num_flex_modes = sizeof(flex_modes);


Property changes on: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.h    
                            (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.h    
    2006-09-08 22:37:03 UTC (rev 3507)
@@ -0,0 +1,44 @@
+/*
+ * 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 2, 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef INCLUDED_PGR_FLEX_MODES_H
+#define INCLUDED_PGR_FLEX_MODES_H
+
+#include <gr_types.h>
+
+#define FLEX_SYNC_MARKER 0xA6C6AAAA
+
+typedef struct flex_mode
+{
+    gr_int32     sync;          // Outer synchronization code
+    unsigned int baud;          // Baudrate of SYNC2 and DATA
+    unsigned int levels;        // FSK encoding of SYNC2 and DATA
+    bool         phase_a;       // PHASEA is transmitted
+    bool         phase_b;       // PHASEB is transmitted
+    bool         phase_c;       // PHASEC is transmitted
+    bool         phase_d;       // PHASED is transmitted
+}
+flex_mode_t;
+
+extern const flex_mode_t flex_modes[];
+extern const int num_flex_modes;
+
+#endif // INCLUDED_PGR_FLEX_MODES_H


Property changes on: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_modes.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_sync.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_sync.cc    
    2006-09-08 22:02:13 UTC (rev 3506)
+++ 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_sync.cc    
    2006-09-08 22:37:03 UTC (rev 3507)
@@ -24,21 +24,10 @@
 #endif
 
 #include <pgr_flex_sync.h>
+#include <pgr_flex_modes.h>
 #include <gr_io_signature.h>
 #include <gr_count_bits.h>
 
-#define FLEX_SYNC_MARKER 0xA6C6AAAA
-
-gr_int32 flex_codes[] = 
-{
-    0x870C78F3,     // 1600 bps, 2 level FSK
-    0xB0684F97,     // 1600 bps, 4 level FSK
-    0xDEA0215F,     // 3200 bps, 4 level FSK
-    0x4C7CB383      // 3200 bps, 4 level FSK REFLEX
-};
-
-#define MAX_FLEX_MODE 3
-
 pgr_flex_sync_sptr pgr_make_flex_sync(int rate)
 {
     return pgr_flex_sync_sptr(new pgr_flex_sync(rate));
@@ -53,7 +42,7 @@
     gr_block ("flex_sync",
               gr_make_io_signature (1, 1, sizeof(unsigned char)),
               gr_make_io_signature (1, 1, sizeof(gr_int32))),
-    d_shifters(rate/1600) // Maximum samples per baud
+    d_sync(rate/1600) // Maximum samples per baud
 {
     d_rate = rate;
     enter_idle();
@@ -76,7 +65,7 @@
         return ((end + start)/2 + d_spb/2) % d_spb;
 }
 
-bool pgr_flex_sync::test_sync()
+bool pgr_flex_sync::test_sync(unsigned char sym)
 {
     // 64-bit FLEX sync code:
     // AAAA:BBBBBBBB:CCCC
@@ -90,15 +79,16 @@
     // First we match on the marker field with a hamming distance < 4
     // Then we match on the outer code with a hamming distance < 4
 
-    gr_int64 val = d_shifters[d_index];
+    d_sync[d_index] = (d_sync[d_index] << 1) | (sym < 2);
+    gr_int64 val = d_sync[d_index];
     gr_int32 marker = ((val & 0x0000FFFFFFFF0000ULL)) >> 16;
 
     if (gr_count_bits32(marker^FLEX_SYNC_MARKER) < 4) {
         gr_int32 code = ((val & 0xFFFF000000000000ULL) >> 32) |
                          (val & 0x000000000000FFFFULL);
 
-        for (int i = 0; i < MAX_FLEX_MODE; i++) {
-            if (gr_count_bits32(code^flex_codes[i]) < 4) {
+        for (int i = 0; i < num_flex_modes; i++) {
+            if (gr_count_bits32(code^flex_modes[i].sync) < 4) {
                 d_mode = i;
                 return true;
             }
@@ -110,7 +100,7 @@
         unsigned short low = code & 0x0000FFFF;
         unsigned short syn = high^low;
         if (syn == 0xFFFF)
-            printf("Unknown sync code detected: %08X\n", code);
+            fprintf(stderr, "Unknown sync code detected: %08X\n", code);
     }
 
     return false;
@@ -125,6 +115,7 @@
     d_spb = d_rate/d_baudrate;
     d_index = 0;
     d_count = 0;
+    d_center = 0;
 }
 
 void pgr_flex_sync::enter_syncing()
@@ -139,15 +130,41 @@
     d_center = index_avg(d_start, d_end);
     d_state = ST_SYNC1;
     d_count = 0;
-    printf("SYNC1=%08X COG=%2i ", flex_codes[d_mode], d_center);
+    fprintf(stderr, "SYNC1=%08X\n", flex_modes[d_mode].sync);
 }
 
 void pgr_flex_sync::enter_sync2()
 {
     d_state = ST_SYNC2;
-    // Shift baud rate here if needed
+    d_count = 0;
+
+    d_baudrate = flex_modes[d_mode].baud;
+    d_levels = flex_modes[d_mode].levels;
+    d_spb = d_rate/d_baudrate;
+
+    if (d_baudrate == 3200) {
+        // Oversampling buffer just got halved
+        d_center = d_center/2;
+        d_index = d_index/2-d_spb/2; // We're here at the center of a 1600 
baud bit
+        d_count = -1;                // So this hack gets us in the right 
place for 3200
+    }
 }
 
+void pgr_flex_sync::enter_data()
+{
+    d_state = ST_DATA;
+    d_count = 0;
+    // more stuff here
+}
+
+void pgr_flex_sync::do_multiphase_shift(unsigned char sym)
+{
+    d_phase_a = (d_phase_a << 1) | (sym < 2);
+
+    // Here is where to add logic to manipulate
+    // d_phase_b, _c, and _d based on current FLEX mode
+}
+
 int pgr_flex_sync::general_work(int noutput_items,
     gr_vector_int &ninput_items,
     gr_vector_const_void_star &input_items,
@@ -160,40 +177,54 @@
     int ninputs = ninput_items[0];
 
     while (i++ < ninputs && j < noutput_items) {
-        d_shifters[d_index] = (d_shifters[d_index] << 1) | (*in++ < 2);
-
+        unsigned char sym = *in++;
         switch (d_state) {
             case ST_IDLE:
-                if (test_sync())
+                if (test_sync(sym))
                     enter_syncing();
                 break;
 
             case ST_SYNCING:
-                if (!test_sync()) {
+                if (!test_sync(sym)) {
                     enter_sync1();
                     // Output sync code
-                    *out++ = flex_codes[d_mode]; j++;
+                    *out++ = flex_modes[d_mode].sync; j++;
                 }
                 break;
 
             case ST_SYNC1:
                 if (d_index == d_center) {
-                    // Skip 16 bits of dotting
-                    if (++d_count == 48) {
-                        gr_int32 fiw = (gr_int32)(d_shifters[d_center] & 
0x00000000FFFFFFFFULL);
+                    do_multiphase_shift(sym);
+                    if (++d_count == 48) { // Skip 16 bits of dotting
                         // Output frame information word
-                        *out++ = fiw; j++;
-                        printf("FIW=%08X\n", fiw);
+                        *out++ = d_phase_a; j++;
                         enter_sync2();
                     }
                 }
                 break;
 
             case ST_SYNC2:
-                // Collect sync2 bits here
-                enter_idle();
+                if (d_index == d_center) {
+                    do_multiphase_shift(sym);
+                    // Skip 25 ms = 40 bits @ 1600 bps, 80 @ 3200 bps
+                    if (++d_count == d_baudrate/40) {
+                        enter_data();
+                        break;
+                    }
+                }
                 break;
 
+            case ST_DATA:
+                if (d_index == d_center) {
+                    do_multiphase_shift(sym);
+
+                    // Here is where to start emitting phased codewords
+
+                    if (++d_count == d_baudrate*1760/1000)
+                        enter_idle();
+                }
+                break;
+
             default:
                 assert(0); // memory corruption of d_state if ever gets here
                 break;

Modified: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_sync.h
===================================================================
--- gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_sync.h 
2006-09-08 22:02:13 UTC (rev 3506)
+++ gnuradio/branches/developers/jcorgan/pager/gr-pager/src/lib/pgr_flex_sync.h 
2006-09-08 22:37:03 UTC (rev 3507)
@@ -50,7 +50,8 @@
     void enter_data();
 
     int index_avg(int start, int end);
-    bool test_sync();
+    bool test_sync(unsigned char sym);
+    void do_multiphase_shift(unsigned char sym);
     
     // Simple state machine
     enum state_t { ST_IDLE, ST_SYNCING, ST_SYNC1, ST_SYNC2, ST_DATA };
@@ -68,7 +69,11 @@
     int d_levels;   // Current decoding levels
     int d_spb;      // Current samples per baud
 
-    gr_int64_vector d_shifters; // Trial synchronizers
+    gr_int64_vector d_sync; // Trial synchronizers
+    gr_int32 d_phase_a;     // PHASEA accumulator
+    gr_int32 d_phase_b;     // PHASEB accumulator
+    gr_int32 d_phase_c;     // PHASEB accumulator
+    gr_int32 d_phase_d;     // PHASEB accumulator
 
 public:
     void forecast(int noutput_items, gr_vector_int &inputs_required);





reply via email to

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