forked from EliasOenal/multimon-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultimon.h
251 lines (209 loc) · 7.16 KB
/
multimon.h
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
* multimon.h -- Monitor for many different modulation formats
*
* Copyright (C) 1996
* Thomas Sailer ([email protected], [email protected])
*
* Added eas parts - A. Maitland Bottoms 27 June 2000
*
* Copyright (C) 2012
* Elias Oenal ([email protected])
*
* This program 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 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* ---------------------------------------------------------------------- */
#ifndef _MULTIMON_H
#define _MULTIMON_H
#include <stdint.h>
#ifdef _MSC_VER
#include "msvc_support.h"
#endif
/* ---------------------------------------------------------------------- */
extern const float costabf[0x400];
#define COS(x) costabf[(((x)>>6)&0x3ffu)]
#define SIN(x) COS((x)+0xc000)
/* ---------------------------------------------------------------------- */
enum
{
POCSAG_MODE_AUTO = 0,
POCSAG_MODE_NUMERIC = 1,
POCSAG_MODE_ALPHA = 2,
POCSAG_MODE_SKYPER = 3,
};
struct l2_state_clipfsk {
unsigned char rxbuf[512];
unsigned char *rxptr;
uint32_t rxstate;
uint32_t rxbitstream;
uint32_t rxbitbuf;
};
struct l2_pocsag_rx {
unsigned char rx_sync; // sync status
unsigned char rx_word; // word counter
unsigned char rx_bit; // bit counter, counts 32bits
char func; // POCSAG function (eg 3 for text)
uint32_t adr; // POCSAG address
unsigned char buffer[512];
uint32_t numnibbles;
} ;
struct demod_state {
const struct demod_param *dem_par;
union {
struct l2_state_clipfsk clipfsk;
struct l2_state_uart {
unsigned char rxbuf[512*100];
unsigned char *rxptr;
uint32_t rxstate;
uint32_t rxbitstream;
uint32_t rxbitbuf;
} uart;
struct l2_state_hdlc {
unsigned char rxbuf[512];
unsigned char *rxptr;
uint32_t rxstate;
uint32_t rxbitstream;
uint32_t rxbitbuf;
} hdlc;
struct l2_state_pocsag {
uint32_t rx_data;
struct l2_pocsag_rx rx[2];
} pocsag;
} l2;
union {
struct l1_state_poc5 {
uint32_t dcd_shreg;
uint32_t sphase;
uint32_t subsamp;
} poc5;
struct l1_state_poc12 {
uint32_t dcd_shreg;
uint32_t sphase;
uint32_t subsamp;
} poc12;
struct l1_state_poc24 {
uint32_t dcd_shreg;
uint32_t sphase;
} poc24;
struct l1_state_eas {
unsigned int dcd_shreg;
unsigned int sphase;
unsigned int lasts;
unsigned int subsamp;
} eas;
struct l1_state_ufsk12 {
unsigned int dcd_shreg;
unsigned int sphase;
unsigned int subsamp;
} ufsk12;
struct l1_state_clipfsk {
unsigned int dcd_shreg;
unsigned int sphase;
uint32_t subsamp;
} clipfsk;
struct l1_state_afsk12 {
uint32_t dcd_shreg;
uint32_t sphase;
uint32_t lasts;
uint32_t subsamp;
} afsk12;
struct l1_state_afsk24 {
unsigned int dcd_shreg;
unsigned int sphase;
unsigned int lasts;
} afsk24;
struct l1_state_hapn48 {
unsigned int shreg;
unsigned int sphase;
float lvllo, lvlhi;
} hapn48;
struct l1_state_fsk96 {
unsigned int dcd_shreg;
unsigned int sphase;
unsigned int descram;
} fsk96;
struct l1_state_dtmf {
unsigned int ph[8];
float energy[4];
float tenergy[4][16];
int blkcount;
int lastch;
} dtmf;
struct l1_state_zvei {
unsigned int ph[16];
float energy[4];
float tenergy[4][32];
int blkcount;
int lastch;
} zvei;
#ifndef NO_X11
struct l1_state_scope {
int datalen;
int dispnum;
float data[512];
} scope;
#endif
} l1;
};
struct demod_param {
const char *name;
unsigned int samplerate;
unsigned int overlap;
void (*init)(struct demod_state *s);
void (*demod)(struct demod_state *s, float *buffer, int length);
void (*de_init)(void);
};
/* ---------------------------------------------------------------------- */
extern const struct demod_param demod_poc5;
extern const struct demod_param demod_poc12;
extern const struct demod_param demod_poc24;
extern const struct demod_param demod_eas;
extern const struct demod_param demod_ufsk1200;
extern const struct demod_param demod_clipfsk;
extern const struct demod_param demod_afsk1200;
extern const struct demod_param demod_afsk2400;
extern const struct demod_param demod_afsk2400_2;
extern const struct demod_param demod_afsk2400_3;
extern const struct demod_param demod_hapn4800;
extern const struct demod_param demod_fsk9600;
extern const struct demod_param demod_dtmf;
extern const struct demod_param demod_zvei;
#ifndef NO_X11
extern const struct demod_param demod_scope;
#endif
#ifdef NO_X11
#define ALL_DEMOD &demod_poc5, &demod_poc12, &demod_poc24, &demod_eas, &demod_ufsk1200, &demod_clipfsk, \
&demod_afsk1200, &demod_afsk2400, &demod_afsk2400_2, &demod_afsk2400_3, &demod_hapn4800, \
&demod_fsk9600, &demod_dtmf, &demod_zvei
#else
#define ALL_DEMOD &demod_poc5, &demod_poc12, &demod_poc24, &demod_eas, &demod_ufsk1200, &demod_clipfsk, \
&demod_afsk1200, &demod_afsk2400, &demod_afsk2400_2, &demod_afsk2400_3, &demod_hapn4800, \
&demod_fsk9600, &demod_dtmf, &demod_zvei, &demod_scope
#endif
/* ---------------------------------------------------------------------- */
void verbprintf(int verb_level, const char *fmt, ...);
void hdlc_init(struct demod_state *s);
void hdlc_rxbit(struct demod_state *s, int bit);
void uart_init(struct demod_state *s);
void uart_rxbit(struct demod_state *s, int bit);
void clip_init(struct demod_state *s);
void clip_rxbit(struct demod_state *s, int bit);
void pocsag_init(struct demod_state *s);
void pocsag_rxbit(struct demod_state *s, int32_t bit);
void pocsag_de_init(void);
void xdisp_terminate(int cnum);
int xdisp_start(void);
int xdisp_update(int cnum, float *f);
/* ---------------------------------------------------------------------- */
#endif /* _MULTIMON_H */