Adds alphanumeric and numeric decoding.
authorjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Sat, 30 Sep 2006 04:19:28 +0000 (04:19 +0000)
committerjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Sat, 30 Sep 2006 04:19:28 +0000 (04:19 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3691 221aa14e-8319-0410-a670-987f0aec2ac5

gr-pager/src/pager_flex_parse.cc
gr-pager/src/pager_flex_parse.h
gr-pager/src/pager_flex_sync.cc
gr-pager/src/pageri_flex_modes.cc
gr-pager/src/pageri_flex_modes.h

index 7d2b309ffc8490a29a2243fc07763e7752a5fe66..22ee9eecade29aa552ecdbcd206551f618857260 100644 (file)
@@ -26,6 +26,7 @@
 #include <pager_flex_parse.h>
 #include <pageri_bch3221.h>
 #include <gr_io_signature.h>
+#include <ctype.h>
 
 pager_flex_parse_sptr pager_make_flex_parse()
 {
@@ -91,7 +92,7 @@ void pager_flex_parse::parse_data()
     int voffset = (biw >> 10) & 0x3f;
     int aoffset = ((biw >> 8) & 0x03) + 1;
     
-//  printf("BIW=%08X A=%i V=%i\n", biw, aoffset, voffset);
+    //printf("BIW:%08X AW:%02i-%02i\n", biw, aoffset, voffset);
 
     // Iterate through pages and dispatch to appropriate handler
     for (int i = aoffset; i < voffset; i++) {
@@ -127,41 +128,108 @@ void pager_flex_parse::parse_data()
        if (mw1 > 87 || mw2 > 87)
            continue;                           // Invalid offsets
 
-       printf("%09i: ", d_capcode);
+       printf("%010i: ", d_capcode);
 
        if (is_alphanumeric_page(d_type))
-           parse_alphanumeric(mw1, mw2-1);
+           parse_alphanumeric(mw1, mw2-1, j);
        else if (is_numeric_page(d_type))
-           parse_numeric(mw1, mw2);
+           parse_numeric(mw1, mw2, j);
        else if (is_tone_page(d_type))
            parse_tone_only();
        else
            parse_unknown(mw1, mw2);
 
        printf("\n");
+       fflush(stdout);
     }
 }
 
-void pager_flex_parse::parse_alphanumeric(int mw1, int mw2)
+void pager_flex_parse::parse_alphanumeric(int mw1, int mw2, int j)
 {
-    printf("ALPHA");
 
-    for (int i = mw1; i < mw2; i++) {
+    int frag;
+    bool cont;
+    
+    if (!d_laddr) {
+       frag = (d_datawords[mw1] >> 11) & 0x03;
+       cont = (d_datawords[mw1] >> 10) & 0x01;
+       mw1++;
+    }
+    else {
+       frag = (d_datawords[j+1] >> 11) & 0x03;
+       cont = (d_datawords[j+1] >> 10) & 0x01;
+       mw2--;
+    }    
+
+    printf("%c F:%i C:%i|", d_type == FLEX_SECURE ? 'S' : 'A',
+       frag, cont);
+
+    for (int i = mw1; i <= mw2; i++) {
+       gr_int32 dw = d_datawords[i];
        
+       if (i > mw1 || frag != 0x03) {
+           unsigned char ch0 = dw & 0x7F;
+           if (ch0 != 0x03)    // Fill
+               putchar(isprint(ch0) ? ch0 : '.');
+       }
+       
+       unsigned char ch1 = (dw >> 7) & 0x7F;
+       if (ch1 != 0x03)        // Fill
+           putchar(isprint(ch1) ? ch1 : '.');
+       
+       unsigned char ch2 = (dw >> 14) & 0x7F;
+       if (ch2 != 0x03)        // Fill
+           putchar(isprint(ch2) ? ch2: '.');
     }
 }
 
-void pager_flex_parse::parse_numeric(int mw1, int mw2)
+void pager_flex_parse::parse_numeric(int mw1, int mw2, int j)
 {
-    printf("NUMERIC");
+    printf("N        |");
+
+    // Get first dataword from message field or from second
+    // vector word if long address
+    gr_int32 dw;
+    if (!d_laddr) {
+       dw = d_datawords[mw1];
+       mw1++;
+       mw2++;
+    }
+    else {
+       dw = d_datawords[j+1];
+    }
+
+    unsigned char digit = 0;
+    int count = 4;
+    if (d_type == FLEX_NUMBERED_NUMERIC)
+       count += 10;    // Skip 10 header bits for numbered numeric pages
+    else
+       count += 2;     // Otherwise skip 2
+    
+    for (int i = mw1; i <= mw2; i++) {
+       for (int k = 0; k < 21; k++) {
+           // Shift LSB from data word into digit
+           digit = (digit >> 1) & 0x0F;
+           if (dw & 0x01)
+               digit ^= 0x08;
+           dw >>= 1;
+           if (--count == 0) {
+               if (digit != 0x0C) // Fill
+                   putchar(flex_bcd[digit]);
+               count = 4;
+           }
+       }
+       
+       dw = d_datawords[i];
+    }
 }
 
 void pager_flex_parse::parse_tone_only()
 {
-    printf("TONE");
+    printf("T        |");
 }
 
 void pager_flex_parse::parse_unknown(int mw1, int mw2)
 {
-    printf("UNKNOWN");
+    printf("U        |(unparsed)");
 }
index ade88c056b5d1ca595a20113ad82bbfbe1717b04..696eedc92d9d8bb28a21d6a9151f3ecf540c22cd 100644 (file)
@@ -51,8 +51,8 @@ private:
 
     void parse_data();                   // Handle a frame's worth of data
     void parse_capcode(gr_int32 aw1, gr_int32 aw2);     
-    void parse_alphanumeric(int mw1, int mw2);
-    void parse_numeric(int mw1, int mw2);
+    void parse_alphanumeric(int mw1, int mw2, int j);
+    void parse_numeric(int mw1, int mw2, int j);
     void parse_tone_only();
     void parse_unknown(int mw1, int mw2);
     
index c8012e8bdd68361391602dbb7abcb4008742d170..c4e5f7c02fff8d55cbbf8c6dd4114bfa4e2adba5 100644 (file)
@@ -141,7 +141,7 @@ void pager_flex_sync::enter_sync1()
     d_end = d_index;
     d_center = index_avg(d_start, d_end); // Center of goodness
     d_count = 0;
-//  printf("SYNC1=%08X ", flex_modes[d_mode].sync);
+    //printf("SYNC1:%08X ", flex_modes[d_mode].sync);
 }
 
 void pager_flex_sync::enter_sync2()
@@ -188,6 +188,8 @@ void pager_flex_sync::parse_fiw()
     // Bits 16-11 are some sort of marker, usually identical across
     // many frames but sometimes changes between frames or modes
     d_unknown1 = (d_fiw >> 11) & 0x3F;
+
+    //printf("CYC:%02i FRM:%03i\n", d_cycle, d_frame);
 }
 
 int pager_flex_sync::output_symbol(unsigned char sym)
index 5988da4a7ed0f3324a9d721efe4b5ac2003bd517..b2bb4e29ccc752fa9dae4b3ca60668c0d1e96909 100644 (file)
@@ -32,6 +32,8 @@ const flex_mode_t flex_modes[] =
 
 const int num_flex_modes = sizeof(flex_modes)/sizeof(flex_modes[0]);
 
+unsigned char flex_bcd[17] = "0123456789 U -][";
+
 int find_flex_mode(gr_int32 sync_code)
 {
     for (int i = 0; i < num_flex_modes; i++)
index bf3b8d98e67ae69e5aea4700cbc3248c74ced7ef..09e5952b9f815a82def21c74732508101ec26694 100644 (file)
@@ -37,6 +37,7 @@ flex_mode_t;
 extern const flex_mode_t flex_modes[];
 extern const int num_flex_modes;
 int find_flex_mode(gr_int32 sync_code);
+extern unsigned char flex_bcd[];
 
 typedef enum {
     FLEX_SECURE,