2 * Copyright 2004,2006 Free Software Foundation, Inc.
4 * This file is part of GNU Radio
6 * GNU Radio is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * GNU Radio is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Radio; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street,
19 * Boston, MA 02110-1301, USA.
26 #include <pager_flex_parse.h>
27 #include <pageri_bch3221.h>
28 #include <gr_io_signature.h>
30 pager_flex_parse_sptr pager_make_flex_parse()
32 return pager_flex_parse_sptr(new pager_flex_parse());
35 pager_flex_parse::pager_flex_parse() :
36 gr_sync_block("flex_parse",
37 gr_make_io_signature(1, 1, sizeof(gr_int32)),
38 gr_make_io_signature(0, 0, 0))
43 int pager_flex_parse::work(int noutput_items,
44 gr_vector_const_void_star &input_items,
45 gr_vector_void_star &output_items)
47 const gr_int32 *in = (const gr_int32 *)input_items[0];
50 while (i < noutput_items) {
51 // Accumulate one whole frame's worth of data words (88 of them)
52 d_datawords[d_count] = *in++; i++;
53 if (++d_count == 88) {
62 /* FLEX data frames (that is, 88 data words per phase recovered after sync,
63 symbol decoding, dephasing, deinterleaving, error correction, and conversion
64 from codewords to data words) start with a block information word containing
65 indices of the page address field and page vector fields.
68 void pager_flex_parse::parse_capcode(gr_int32 aw1, gr_int32 aw2)
70 d_laddr = (aw1 < 0x008001L) ||
75 d_capcode = aw1+((aw2^0x001FFFFF)<<15)+0x1F9000; // Don't ask
77 d_capcode = aw1-0x8000;
80 void pager_flex_parse::parse_data()
82 // Block information word is the first data word in frame
83 gr_int32 biw = d_datawords[0];
85 // Nothing to see here, please move along
86 if (biw == 0 || biw == 0x001FFFFF)
89 // Vector start index is bits 15-10
90 // Address start address is bits 9-8, plus one for offset
91 int voffset = (biw >> 10) & 0x3f;
92 int aoffset = ((biw >> 8) & 0x03) + 1;
94 // printf("BIW=%08X A=%i V=%i\n", biw, aoffset, voffset);
96 // Iterate through pages and dispatch to appropriate handler
97 for (int i = aoffset; i < voffset; i++) {
98 int j = voffset+i-aoffset; // Start of vector field for address @ i
100 if (d_datawords[i] == 0x00000000 ||
101 d_datawords[i] == 0x001FFFFF)
102 continue; // Idle codewords, invalid address
104 parse_capcode(d_datawords[i], d_datawords[i+1]);
108 if (d_capcode < 0) // Invalid address, skip
111 // Parse vector information word for address @ offset 'i'
112 gr_int32 viw = d_datawords[j];
113 d_type = (page_type_t)((viw >> 4) & 0x00000007);
114 int mw1 = (viw >> 7) & 0x00000007F;
115 int len = (viw >> 14) & 0x0000007F;
117 if (is_numeric_page(d_type))
121 if (mw1 == 0 && mw2 == 0)
122 continue; // Invalid VIW
124 if (is_tone_page(d_type))
127 if (mw1 > 87 || mw2 > 87)
128 continue; // Invalid offsets
130 printf("%09i: ", d_capcode);
132 if (is_alphanumeric_page(d_type))
133 parse_alphanumeric(mw1, mw2-1);
134 else if (is_numeric_page(d_type))
135 parse_numeric(mw1, mw2);
136 else if (is_tone_page(d_type))
139 parse_unknown(mw1, mw2);
145 void pager_flex_parse::parse_alphanumeric(int mw1, int mw2)
149 for (int i = mw1; i < mw2; i++) {
154 void pager_flex_parse::parse_numeric(int mw1, int mw2)
159 void pager_flex_parse::parse_tone_only()
164 void pager_flex_parse::parse_unknown(int mw1, int mw2)