File: msg.h

package info (click to toggle)
hf 0.7.3-4etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 3,684 kB
  • ctags: 3,156
  • sloc: ansic: 26,447; cpp: 4,909; sh: 3,785; makefile: 309
file content (334 lines) | stat: -rw-r--r-- 10,711 bytes parent folder | download | duplicates (2)
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
/*****************************************************************************/

/*
 *      msg.h  --  Messages hfkernel <--> hfterm.
 *
 *      Copyright (C) 1996  Thomas Sailer (sailer@ife.ee.ethz.ch)
 *        Swiss Federal Institute of Technology (ETH), Electronics Lab
 *
 *      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 _MSG_H
#define _MSG_H

extern void *io_process(void *dummy);
extern void *l1_process(void *dummy);
extern void process_sample_msg(unsigned int u);
extern void check_sample_msg_ready(void);

extern pthread_t thr_l2;

/* --------------------------------------------------------------------- */

/*
 * Bittypes
 */

#ifndef HAVE_BITTYPES

#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
typedef int int8_t __attribute__((__mode__(__QI__)));
typedef unsigned int u_int8_t __attribute__((__mode__(__QI__)));
typedef int int16_t __attribute__((__mode__(__HI__)));
typedef unsigned int u_int16_t __attribute__((__mode__(__HI__)));
typedef int int32_t __attribute__((__mode__(__SI__)));
typedef unsigned int u_int32_t __attribute__((__mode__(__SI__)));
typedef int int64_t __attribute__((__mode__(__DI__)));
typedef unsigned int u_int64_t __attribute__((__mode__(__DI__)));
#else
typedef char /* deduced */ int8_t __attribute__((__mode__(__QI__)));
typedef unsigned char /* deduced */ u_int8_t __attribute__((__mode__(__QI__)));
typedef short /* deduced */ int16_t __attribute__((__mode__(__HI__)));
typedef unsigned short /* deduced */ u_int16_t __attribute__((__mode__(__HI__)));
typedef long /* deduced */ int32_t __attribute__((__mode__(__SI__)));
typedef unsigned long /* deduced */ u_int32_t __attribute__((__mode__(__SI__)));
typedef long long /* deduced */ int64_t __attribute__((__mode__(__DI__)));
typedef unsigned long long /* deduced */ u_int64_t __attribute__((__mode__(__DI__)));
#endif

#endif /* !HAVE_BITTYPES */

/* --------------------------------------------------------------------- */
/*
 * the size of the messages is aligned to 32bit quantities
 * to facilitate processing on machines not able to do unaligned accesses
 */

#define HFAPP_MSG_ALIGN(x) (((x)+3)&(~3))
#define HFAPP_MSG_ALIGNED(x) ((((unsigned int)(x))&3)==0)

/* --------------------------------------------------------------------- */

struct hfapp_msg_hdr {
	u_int32_t type;
	u_int32_t len;
	u_int32_t err;
};

struct hfapp_msg {
	struct hfapp_msg_hdr hdr;
	union {
		unsigned char b[256];
		u_int32_t u;

		struct hfapp_msg_general_params {
			u_int16_t beaconpause;
		} generalpar;
		
		struct hfapp_msg_fsk_params {
			u_int16_t freq[2];
		} fpar;

		struct hfapp_msg_cw_params {
			u_int16_t wpm;
			u_int16_t tone;
			unsigned char farnsworth;
			unsigned char dtr;
		} cwpar;

		struct hfapp_msg_rtty_params {
			u_int16_t baud;
			unsigned char rxinvert;
			unsigned char txinvert;
		} rpar;

		struct hfapp_msg_amtor_params {
			unsigned char destcall[4];
			unsigned char selfeccall[4];
			unsigned char mycall[4];
			u_int16_t txdelay;
			u_int16_t retry;
			unsigned char rxinvert;
			unsigned char txinvert;
		} apar;

		struct hfapp_msg_gtor_params {
			unsigned char destcall[10];
			unsigned char mycall[10];
			u_int16_t txdelay;
			u_int16_t retry;
		} gpar;

		struct hfapp_msg_pactor_params {
			unsigned char destcall[8];
			unsigned char mycall[8];
			u_int16_t txdelay;
			u_int16_t retry;
			unsigned char longpath;
			u_int16_t crcpreset[4];
		} ppar;

		struct hfapp_msg_mt63_params {
			u_int16_t bandwidth; 
			u_int16_t integration;
			unsigned char cwcall[10];
			u_int16_t doubleinterleave;
		} mt63par;

		struct hfapp_msg_mixer_params {
			int32_t src;
			int32_t igain;
			int32_t ogain;
		} mpar;
	} data;
};

/* --------------------------------------------------------------------- */

#define FSK 1
#define MT63 2

/* --------------------------------------------------------------------- */

#define HFAPP_MSG_DATA_TRANSMIT      1
#define HFAPP_MSG_DATA_TRANSMIT_BIN  2
#define HFAPP_MSG_DATA_SEND          3
#define HFAPP_MSG_DATA_RECEIVE       4
#define HFAPP_MSG_DATA_MONITOR       5
#define HFAPP_MSG_DATA_STATUS        6

#define HFAPP_MSG_DATA_SEND_EOF     20
#define HFAPP_MSG_SEND_TEST 	    25

#define HFAPP_MSG_SET_GENERALPAR    40

#define HFAPP_MSG_SET_CWPAR 	    50
#define HFAPP_MSG_MODE_CW_RX 	    51
#define HFAPP_MSG_MODE_CW_TX 	    52
#define HFAPP_MSG_CW_ELBUG_DIT 	    55
#define HFAPP_MSG_CW_ELBUG_DAH 	    56
#define HFAPP_MSG_CW_ELBUG_TUNE	    57
#define HFAPP_MSG_CW_ELBUG_PAUSE    58
#define HFAPP_MSG_STATE_CW_RX 	    60
#define HFAPP_MSG_STATE_CW_TX 	    61

#define HFAPP_MSG_REQ_SAMPLES      100
#define HFAPP_MSG_ACK_SAMPLES      101

#define HFAPP_MSG_SET_FSKPAR       150
#define HFAPP_MSG_SET_MIXERPAR     160

#define HFAPP_MSG_KEEPALIVE        200

#define HFAPP_MSG_MODE_QRT         300
#define HFAPP_MSG_MODE_IRS         301
#define HFAPP_MSG_MODE_ISS         302
#define HFAPP_MSG_MODE_SPEEDUP     303
#define HFAPP_MSG_STATE_QRT        310

#define HFAPP_MSG_CASE_UPPER       350
#define HFAPP_MSG_CASE_LOWER       351
#define HFAPP_MSG_CASE_FIGURE      352

#define HFAPP_MSG_START_STANDBY    	400
#define HFAPP_MSG_START_PACTOR_STANDBY  401

#define HFAPP_MSG_STATE_STANDBY    	450
#define HFAPP_MSG_STATE_PACTOR_STANDBY  451

#define HFAPP_MSG_START_PACTOR_ARQ 500
#define HFAPP_MSG_START_PACTOR_FEQ 501
#define HFAPP_MSG_SET_PACTORPAR    510

#define HFAPP_MSG_STATE_PACTOR_ARQ_MASTERCONNECT  550
#define HFAPP_MSG_STATE_PACTOR_ARQ_SLAVECONNECT   551
#define HFAPP_MSG_STATE_PACTOR_ARQ_DISCONNECT     552
#define HFAPP_MSG_STATE_PACTOR_FEC_CONNECT        553
#define HFAPP_MSG_STATE_PACTOR_ISS                555
#define HFAPP_MSG_STATE_PACTOR_IRS                556
#define HFAPP_MSG_STATE_PACTOR_SPEED100           557
#define HFAPP_MSG_STATE_PACTOR_SPEED200           558

#define HFAPP_MSG_START_AMTOR_ARQ     600
#define HFAPP_MSG_START_AMTOR_COLFEQ  601
#define HFAPP_MSG_START_AMTOR_SELFEQ  602
#define HFAPP_MSG_SET_AMTORPAR        610

#define HFAPP_MSG_STATE_AMTOR_ARQ_MASTERCONNECT  650
#define HFAPP_MSG_STATE_AMTOR_ARQ_SLAVECONNECT   651
#define HFAPP_MSG_STATE_AMTOR_ARQ_DISCONNECT     652
#define HFAPP_MSG_STATE_AMTOR_FEC_CONNECT        653
#define HFAPP_MSG_STATE_AMTOR_FEC_DISCONNECT     654
#define HFAPP_MSG_STATE_AMTOR_SELFEC_RX          655
#define HFAPP_MSG_STATE_AMTOR_COLFEC_RX          656
#define HFAPP_MSG_STATE_AMTOR_ISS                657
#define HFAPP_MSG_STATE_AMTOR_IRS                658

#define HFAPP_MSG_START_RTTY_TX       700
#define HFAPP_MSG_START_RTTY_RX       701
#define HFAPP_MSG_SET_RTTYPAR         710

#define HFAPP_MSG_STATE_RTTY_TX       750
#define HFAPP_MSG_STATE_RTTY_RX       751

#define HFAPP_MSG_START_GTOR_ARQ      800
#define HFAPP_MSG_SET_GTORPAR         810

#define HFAPP_MSG_STATE_GTOR_ARQ_MASTERCONNECT  850
#define HFAPP_MSG_STATE_GTOR_ARQ_SLAVECONNECT   851
#define HFAPP_MSG_STATE_GTOR_ARQ_DISCONNECT     852
#define HFAPP_MSG_STATE_GTOR_ISS                855
#define HFAPP_MSG_STATE_GTOR_IRS                856
#define HFAPP_MSG_STATE_GTOR_SPEED100           857
#define HFAPP_MSG_STATE_GTOR_SPEED200           858
#define HFAPP_MSG_STATE_GTOR_SPEED300           859

#define HFAPP_MSG_START_MT63_RX			900
#define HFAPP_MSG_START_MT63_TX			901
#define HFAPP_MSG_START_MT63_500_RX		902
#define HFAPP_MSG_START_MT63_500_TX		903
#define HFAPP_MSG_START_MT63_1000_RX		904
#define HFAPP_MSG_START_MT63_1000_TX		905
#define HFAPP_MSG_START_MT63_2000_RX		906
#define HFAPP_MSG_START_MT63_2000_TX		907

#define HFAPP_MSG_SET_MT63PAR		        910

#define HFAPP_MSG_STATE_MT63_RX			950
#define HFAPP_MSG_STATE_MT63_TX			951
#define HFAPP_MSG_STATE_MT63_500_RX		952
#define HFAPP_MSG_STATE_MT63_500_TX		953
#define HFAPP_MSG_STATE_MT63_1000_RX		954
#define HFAPP_MSG_STATE_MT63_1000_TX		955
#define HFAPP_MSG_STATE_MT63_2000_RX		956
#define HFAPP_MSG_STATE_MT63_2000_TX		957

/* --------------------------------------------------------------------- */

#define ERR_NOERR                 0
#define ERR_TOOBIG                1
#define ERR_RESOURCE              2
#define ERR_TIMEOUT               3

/* --------------------------------------------------------------------- */

#define SEV_FATAL    LOG_CRIT
#define SEV_ERROR    LOG_ERR
#define SEV_WARNING  LOG_WARNING
#define SEV_NOTICE   LOG_NOTICE
#define SEV_INFO     LOG_INFO


/* --------------------------------------------------------------------- */

#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))

/* --------------------------------------------------------------------- */

#define KBD_CHAR  0xff
#define KBD_BIN   0x100
#define KBD_EOF   0xffff

/* --------------------------------------------------------------------- */

extern void errprintf(int severity, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
extern void errstr(int severity, const char *st);

extern void start_l2_thread();
extern unsigned short kbd_get(void);
extern void kbd_ack(void);
extern void kbd_negack(void);
extern void kbd_back(void);
extern void kbd_clear_and_fill(const unsigned char *data, unsigned int length);
extern void bufprintf(unsigned int which, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
extern void bufwrite(unsigned int which, const unsigned char *data, unsigned int datalen);
extern void send_short_msg(u_int32_t type, u_int32_t err);
extern void send_msg(struct hfapp_msg *msg);

/* --------------------------------------------------------------------- */

#ifndef HAVE_VSNPRINTF

#include <stdarg.h>

extern int snprintf(char *buf, size_t len, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
extern int vsnprintf(char *buf, size_t len, const char *fmt, va_list ap);

#endif

/* --------------------------------------------------------------------- */

extern int modefamily;
extern int mt63_bandwidth;

/* --------------------------------------------------------------------- */

#endif /* _MSG_H */