1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
/*
* Copyright 2004,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., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <pager_flex_parse.h>
#include <pageri_bch3221.h>
#include <gr_io_signature.h>
pager_flex_parse_sptr pager_make_flex_parse()
{
return pager_flex_parse_sptr(new pager_flex_parse());
}
pager_flex_parse::pager_flex_parse() :
gr_sync_block("flex_parse",
gr_make_io_signature(1, 1, sizeof(gr_int32)),
gr_make_io_signature(0, 0, 0))
{
d_count = 0;
}
int pager_flex_parse::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_int32 *in = (const gr_int32 *)input_items[0];
int i = 0;
while (i < noutput_items) {
// Accumulate one whole frame's worth of data words (88 of them)
d_datawords[d_count] = *in++; i++;
if (++d_count == 88) {
parse_data();
d_count = 0;
}
}
return i;
}
/* FLEX data frames (that is, 88 data words per phase recovered after sync,
symbol decoding, dephasing, deinterleaving, error correction, and conversion
from codewords to data words) start with a block information word containing
indices of the page address field and page vector fields.
*/
void pager_flex_parse::parse_capcode(gr_int32 aw1, gr_int32 aw2)
{
d_laddr = (aw1 < 0x008001L) ||
(aw1 > 0x1E0000L) ||
(aw1 > 0x1E7FFEL);
if (d_laddr)
d_capcode = aw1+((aw2^0x001FFFFF)<<15)+0x1F9000; // Don't ask
else
d_capcode = aw1-0x8000;
}
void pager_flex_parse::parse_data()
{
// Block information word is the first data word in frame
gr_int32 biw = d_datawords[0];
// Nothing to see here, please move along
if (biw == 0 || biw == 0x001FFFFF)
return;
// Vector start index is bits 15-10
// Address start address is bits 9-8, plus one for offset
int voffset = (biw >> 10) & 0x3f;
int aoffset = ((biw >> 8) & 0x03) + 1;
// printf("BIW=%08X A=%i V=%i\n", biw, aoffset, voffset);
// Iterate through pages and dispatch to appropriate handler
for (int i = aoffset; i < voffset; i++) {
int j = voffset+i-aoffset; // Start of vector field for address @ i
if (d_datawords[i] == 0x00000000 ||
d_datawords[i] == 0x001FFFFF)
continue; // Idle codewords, invalid address
parse_capcode(d_datawords[i], d_datawords[i+1]);
if (d_laddr)
i++;
if (d_capcode < 0) // Invalid address, skip
continue;
// Parse vector information word for address @ offset 'i'
gr_int32 viw = d_datawords[j];
d_type = (page_type_t)((viw >> 4) & 0x00000007);
int mw1 = (viw >> 7) & 0x00000007F;
int len = (viw >> 14) & 0x0000007F;
if (is_numeric_page(d_type))
len &= 0x07;
int mw2 = mw1+len;
if (mw1 == 0 && mw2 == 0)
continue; // Invalid VIW
if (is_tone_page(d_type))
mw1 = mw2 = 0;
if (mw1 > 87 || mw2 > 87)
continue; // Invalid offsets
printf("%09i: ", d_capcode);
if (is_alphanumeric_page(d_type))
parse_alphanumeric(mw1, mw2-1);
else if (is_numeric_page(d_type))
parse_numeric(mw1, mw2);
else if (is_tone_page(d_type))
parse_tone_only();
else
parse_unknown(mw1, mw2);
printf("\n");
}
}
void pager_flex_parse::parse_alphanumeric(int mw1, int mw2)
{
printf("ALPHA");
for (int i = mw1; i < mw2; i++) {
}
}
void pager_flex_parse::parse_numeric(int mw1, int mw2)
{
printf("NUMERIC");
}
void pager_flex_parse::parse_tone_only()
{
printf("TONE");
}
void pager_flex_parse::parse_unknown(int mw1, int mw2)
{
printf("UNKNOWN");
}
|