summaryrefslogtreecommitdiff
path: root/gr-pager/src
diff options
context:
space:
mode:
authorjcorgan2006-09-30 04:19:28 +0000
committerjcorgan2006-09-30 04:19:28 +0000
commit46234d16039b057bc09a87530afec61e05cce202 (patch)
tree3b3de642c28093512f609206f0a5065e5799967a /gr-pager/src
parente915fef7316364459c87fb314371f6c1720b06e9 (diff)
downloadgnuradio-46234d16039b057bc09a87530afec61e05cce202.tar.gz
gnuradio-46234d16039b057bc09a87530afec61e05cce202.tar.bz2
gnuradio-46234d16039b057bc09a87530afec61e05cce202.zip
Adds alphanumeric and numeric decoding.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3691 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-pager/src')
-rw-r--r--gr-pager/src/pager_flex_parse.cc90
-rw-r--r--gr-pager/src/pager_flex_parse.h4
-rw-r--r--gr-pager/src/pager_flex_sync.cc4
-rw-r--r--gr-pager/src/pageri_flex_modes.cc2
-rw-r--r--gr-pager/src/pageri_flex_modes.h1
5 files changed, 87 insertions, 14 deletions
diff --git a/gr-pager/src/pager_flex_parse.cc b/gr-pager/src/pager_flex_parse.cc
index 7d2b309ff..22ee9eeca 100644
--- a/gr-pager/src/pager_flex_parse.cc
+++ b/gr-pager/src/pager_flex_parse.cc
@@ -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)");
}
diff --git a/gr-pager/src/pager_flex_parse.h b/gr-pager/src/pager_flex_parse.h
index ade88c056..696eedc92 100644
--- a/gr-pager/src/pager_flex_parse.h
+++ b/gr-pager/src/pager_flex_parse.h
@@ -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);
diff --git a/gr-pager/src/pager_flex_sync.cc b/gr-pager/src/pager_flex_sync.cc
index c8012e8bd..c4e5f7c02 100644
--- a/gr-pager/src/pager_flex_sync.cc
+++ b/gr-pager/src/pager_flex_sync.cc
@@ -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)
diff --git a/gr-pager/src/pageri_flex_modes.cc b/gr-pager/src/pageri_flex_modes.cc
index 5988da4a7..b2bb4e29c 100644
--- a/gr-pager/src/pageri_flex_modes.cc
+++ b/gr-pager/src/pageri_flex_modes.cc
@@ -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++)
diff --git a/gr-pager/src/pageri_flex_modes.h b/gr-pager/src/pageri_flex_modes.h
index bf3b8d98e..09e5952b9 100644
--- a/gr-pager/src/pageri_flex_modes.h
+++ b/gr-pager/src/pageri_flex_modes.h
@@ -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,