19 #include <netinet/in.h>
20 #include <arpa/inet.h>
31 #define MY_NAME "rfmod"
34 static int DevType
= EAGLEII
;
37 static void usage(char *argv
[]);
38 static void ts_output(unsigned char *p
, int total
);
39 static int init_modulator(
51 static void usage(char *argv
[])
53 fprintf(stderr
, "Usage: %s [-v] [-d] [-T deviceType] [-D deviceIndex] [-o timeout] [-S stamp_packets] [-F fequencykHz] [-g gain] [-B bandwidth] [-M transmissionMode] [-C connstellation] [-R codeRate] [-G guardInterval] [-L cellid] [-p port] [-f interface] ip_addr[:port]\n", argv
[0]);
57 static void sigsegv_handler(int sig
, siginfo_t
*si
, void *unused
)
59 logwrite(LOG_ERR
, "Got SIGSEGV at address 0x%08x", (long)si
->si_addr
);
63 static void sigusr1_handler(int sig
, siginfo_t
*si
, void *unused
)
65 logwrite(LOG_ERR
, "Increment log verbosity.");
70 static void sigusr2_handler(int sig
, siginfo_t
*si
, void *unused
)
72 logwrite(LOG_ERR
, "Decrement log verbosity.");
76 int main(int argc
, char *argv
[])
81 int timeout
= 1000; /* 1 second */
82 int stamp
= 1701900; /* 15 minutes for 1891 packets per second */
84 char *remoteaddr
= "";
85 int remoteport
= 1234;
86 struct sched_param schedParam
;
94 int frequency
= 730000;
98 int constellation
= 2;
100 int guardInterval
= 3;
101 int transmissionMode
= 1;
107 int buffer
= 2*1024*1024;
109 openlog(MY_NAME
, LOG_PID
, LOG_LOCAL5
);
110 logwrite(LOG_INFO
, "starting");
112 while ((opt
= getopt(argc
, argv
, "b:dvT:D:S:o:f:p:F:B:C:R:D:G:M:L:g:")) != -1) {
114 /* GENERAL OPTIONS */
116 stamp
= atoi(optarg
);
119 timeout
= atoi(optarg
);
122 logwrite_inc_level();
130 port
= strtol(optarg
, NULL
, 0);
134 DevType
= strtol(optarg
, NULL
, 0);
138 DevNo
= strtol(optarg
, NULL
, 0);
143 gain
= strtol(optarg
, (char **)NULL
, 0);
147 frequency
= strtol(optarg
, (char **)NULL
, 0);
150 bandwidth
= strtol(optarg
, (char **)NULL
, 0);
153 constellation
= strtol(optarg
, (char **)NULL
, 0);
156 codeRate
= strtol(optarg
, (char **)NULL
, 0);
159 guardInterval
= strtol(optarg
, (char **)NULL
, 0);
162 transmissionMode
= strtol(optarg
, (char **)NULL
, 0);
165 cellid
= strtol(optarg
, (char **)NULL
, 0);
170 buffer
= strtol(optarg
, (char **)NULL
, 0);
173 fromIf
= strdup(optarg
);
174 fromIfIndex
= if_nametoindex(fromIf
);
176 logwrite(LOG_ERR
, "Interface '%s' does not exist", fromIf
);
181 fprintf(stderr
, "Bad parameter %c\n", opt
);
186 if (argc
-optind
!= 1) {
187 fprintf(stderr
, "Bad parameters %d\n", argc
-optind
);
188 for (opt
= optind
; opt
< argc
; opt
++) {
189 fprintf(stderr
, "arg %d: %s\n", opt
, argv
[opt
]);
194 optarg
= argv
[optind
];
197 colon
= index(optarg
, ':');
200 remoteaddr
= strndup(optarg
, colon
-optarg
);
201 remoteport
= strtol(colon
+1, NULL
, 0);
207 schedParam
.sched_priority
= sched_get_priority_max(SCHED_RR
)/2-1;
208 if (pthread_setschedparam(pthread_self(), SCHED_RR
, &schedParam
)) {
209 logwrite(LOG_INFO
, "setschedparam failed - running at normal priority");
213 logwrite(LOG_INFO
, "inspec=[%s], remoteaddr=[%s], remoteport=%d", inspec
, remoteaddr
, remoteport
);
214 fd
= socket_open(remoteaddr
, remoteport
, fromIf
, fromIfIndex
, buffer
, timeout
);
216 logwrite(LOG_ERR
, "Open socket %s: %d", inspec
, errno
);
220 fds
.events
= POLLIN
|POLLERR
|POLLHUP
;
224 init_modulator(frequency
, bandwidth
, gain
, constellation
, codeRate
, guardInterval
, transmissionMode
, cellid
);
226 /* now become a daemon */
228 daemonize(NULL
, NULL
);
230 logwrite(LOG_ERR
, "RESTART");
234 sa
.sa_flags
= SA_SIGINFO
| SA_RESTART
;
235 sigemptyset(&sa
.sa_mask
);
236 sa
.sa_sigaction
= sigsegv_handler
;
237 if (sigaction(SIGSEGV
, &sa
, NULL
) == -1) {
238 logwrite(LOG_ERR
, "Failed to set SIGSEGV handler");
240 sa
.sa_flags
= SA_SIGINFO
| SA_RESTART
;
241 sigemptyset(&sa
.sa_mask
);
242 sa
.sa_sigaction
= sigusr1_handler
;
243 if (sigaction(SIGUSR1
, &sa
, NULL
) == -1) {
244 logwrite(LOG_ERR
, "Failed to set SIGUSR1 handler");
246 sa
.sa_flags
= SA_SIGINFO
| SA_RESTART
;
247 sigemptyset(&sa
.sa_mask
);
248 sa
.sa_sigaction
= sigusr2_handler
;
249 if (sigaction(SIGUSR2
, &sa
, NULL
) == -1) {
250 logwrite(LOG_ERR
, "Failed to set SIGUSR2 handler");
260 logwrite(LOG_DEBUG
, "tick");
263 ret
= poll(&fds
, 1, timeout
);
265 if (fds
.revents
& POLLIN
) {
266 unsigned char p
[MAX_PACKET_SIZE
];
268 len
= read(fds
.fd
, p
, sizeof(p
));
270 logwrite(LOG_ERR
, "Receiving from socket %s: %d", inspec
, errno
);
274 if (len
> RTP_HEADROOM
&& p
[RTP_VERSION_OFF
] == 0x80 && p
[RTP_PT_OFF
] == RTP_PT_MP2T
) {
275 static unsigned long good
= 0;
276 uint16_t rseq
= (p
[RTP_SEQ_OFF
] << 8)+p
[RTP_SEQ_OFF
+1];
277 if (seq
>= 0 && seq
!= rseq
) {
278 logwrite(LOG_INFO
, "%s %lu RTP seq %d err: expected %u != received %u", inspec
, good
, rseq
-seq
, seq
, rseq
);
283 seq
= (rseq
+1) & 0xFFFF;
284 /* skip RTP header */
286 memmove(p
, p
+RTP_HEADROOM
, len
);
291 if (fds
.revents
& POLLHUP
) {
292 logwrite(LOG_ERR
, "remote %s died", inspec
);
294 if (fds
.revents
& POLLERR
) {
295 logwrite(LOG_ERR
, "remote %s error", inspec
);
297 } else if (ret
== 0) {
298 logwrite(LOG_INFO
, "Timeout");
299 } else if (errno
!= EINTR
) {
300 logwrite(LOG_ERR
, "poll failed: %d", errno
);
303 logwrite(LOG_NOTICE
, "terminated");
308 static Byte UT100_IQtable
[] = {
309 0x20, 0x49, 0x51, 0x20, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x33, 0x00, 0x00, 0x00, 0x00, 0x5b,
310 0x50, 0xc3, 0x00, 0x00, 0x2d, 0x00, 0xf2, 0xfb, 0x60, 0xea, 0x00, 0x00, 0x11, 0x00, 0x68, 0xfd,
311 0x70, 0x11, 0x01, 0x00, 0x03, 0x00, 0xdd, 0xfe, 0x80, 0x38, 0x01, 0x00, 0x00, 0x00, 0x52, 0x00,
312 0x90, 0x5f, 0x01, 0x00, 0x06, 0x00, 0xa3, 0x01, 0xa0, 0x86, 0x01, 0x00, 0x17, 0x00, 0x06, 0x03,
313 0xb0, 0xad, 0x01, 0x00, 0x1a, 0x00, 0x21, 0x03, 0xc0, 0xd4, 0x01, 0x00, 0x16, 0x00, 0xe1, 0x02,
314 0xd0, 0xfb, 0x01, 0x00, 0x11, 0x00, 0x8f, 0x02, 0xe0, 0x22, 0x02, 0x00, 0x0c, 0x00, 0x34, 0x02,
315 0xf0, 0x49, 0x02, 0x00, 0x09, 0x00, 0xd9, 0x01, 0x00, 0x71, 0x02, 0x00, 0x06, 0x00, 0x7e, 0x01,
316 0x10, 0x98, 0x02, 0x00, 0x04, 0x00, 0x2c, 0x01, 0x20, 0xbf, 0x02, 0x00, 0x02, 0x00, 0xda, 0x00,
317 0x30, 0xe6, 0x02, 0x00, 0x01, 0x00, 0x92, 0x00, 0x40, 0x0d, 0x03, 0x00, 0x01, 0x00, 0x52, 0x00,
318 0x50, 0x34, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x60, 0x5b, 0x03, 0x00, 0x01, 0x00, 0xc9, 0xff,
319 0x70, 0x82, 0x03, 0x00, 0x01, 0x00, 0x93, 0xff, 0x80, 0xa9, 0x03, 0x00, 0x02, 0x00, 0x65, 0xff,
320 0x90, 0xd0, 0x03, 0x00, 0x02, 0x00, 0x38, 0xff, 0xa0, 0xf7, 0x03, 0x00, 0x03, 0x00, 0x13, 0xff,
321 0xb0, 0x1e, 0x04, 0x00, 0x03, 0x00, 0xef, 0xfe, 0xc0, 0x45, 0x04, 0x00, 0x04, 0x00, 0xd4, 0xfe,
322 0xd0, 0x6c, 0x04, 0x00, 0x04, 0x00, 0xc1, 0xfe, 0xe0, 0x93, 0x04, 0x00, 0x05, 0x00, 0xaf, 0xfe,
323 0xf0, 0xba, 0x04, 0x00, 0x05, 0x00, 0xaf, 0xfe, 0x00, 0xe2, 0x04, 0x00, 0x04, 0x00, 0xa6, 0xfe,
324 0x10, 0x09, 0x05, 0x00, 0x04, 0x00, 0xaf, 0xfe, 0x20, 0x30, 0x05, 0x00, 0x04, 0x00, 0xb8, 0xfe,
325 0x30, 0x57, 0x05, 0x00, 0x04, 0x00, 0xc1, 0xfe, 0x40, 0x7e, 0x05, 0x00, 0x04, 0x00, 0xd4, 0xfe,
326 0x50, 0xa5, 0x05, 0x00, 0x03, 0x00, 0xe6, 0xfe, 0x60, 0xcc, 0x05, 0x00, 0x02, 0x00, 0xef, 0xfe,
327 0x70, 0xf3, 0x05, 0x00, 0x02, 0x00, 0x13, 0xff, 0x80, 0x1a, 0x06, 0x00, 0x01, 0x00, 0x1c, 0xff,
328 0x90, 0x41, 0x06, 0x00, 0x01, 0x00, 0x41, 0xff, 0xa0, 0x68, 0x06, 0x00, 0x01, 0x00, 0x53, 0xff,
329 0xb0, 0x8f, 0x06, 0x00, 0x00, 0x00, 0x6e, 0xff, 0xc0, 0xb6, 0x06, 0x00, 0x00, 0x00, 0x8a, 0xff,
330 0xd0, 0xdd, 0x06, 0x00, 0x00, 0x00, 0xa5, 0xff, 0xe0, 0x04, 0x07, 0x00, 0x00, 0x00, 0xb7, 0xff,
331 0xf0, 0x2b, 0x07, 0x00, 0x00, 0x00, 0xc9, 0xff, 0x00, 0x53, 0x07, 0x00, 0x00, 0x00, 0xdc, 0xff,
332 0x10, 0x7a, 0x07, 0x00, 0x00, 0x00, 0xdc, 0xff, 0x20, 0xa1, 0x07, 0x00, 0xff, 0xff, 0xee, 0xff,
333 0x30, 0xc8, 0x07, 0x00, 0x00, 0x00, 0xf7, 0xff, 0x40, 0xef, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
334 0x50, 0x16, 0x08, 0x00, 0xff, 0xff, 0x00, 0x00, 0x60, 0x3d, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
335 0x70, 0x64, 0x08, 0x00, 0xff, 0xff, 0xf7, 0xff, 0x80, 0x8b, 0x08, 0x00, 0xff, 0xff, 0x12, 0x00,
336 0x90, 0xb2, 0x08, 0x00, 0xff, 0xff, 0xf7, 0xff, 0xa0, 0xd9, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00,
337 0xb0, 0x00, 0x09, 0x00, 0x00, 0x00, 0x12, 0x00, 0xc0, 0x27, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
338 0xd0, 0x4e, 0x09, 0x00, 0x00, 0x00, 0x12, 0x00, 0xe0, 0x75, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
339 0xf0, 0x9c, 0x09, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xc4, 0x09, 0x00, 0x00, 0x00, 0xf7, 0xff,
340 0x10, 0xeb, 0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x20, 0x12, 0x0a, 0x00, 0x00, 0x00, 0xf7, 0xff,
341 0x30, 0x39, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x60, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
342 0x50, 0x87, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xae, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
343 0x70, 0xd5, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xfc, 0x0a, 0x00, 0x00, 0x00, 0x09, 0x00,
344 0x90, 0x23, 0x0b, 0x00, 0x00, 0x00, 0xf7, 0xff, 0xa0, 0x4a, 0x0b, 0x00, 0x00, 0x00, 0x09, 0x00,
345 0xb0, 0x71, 0x0b, 0x00, 0x00, 0x00, 0xee, 0xff, 0xc0, 0x98, 0x0b, 0x00, 0x00, 0x00, 0xe5, 0xff,
346 0xd0, 0xbf, 0x0b, 0x00, 0x02, 0x00, 0xee, 0xff, 0xe0, 0xe6, 0x0b, 0x00, 0x00, 0x00, 0xee, 0xff,
347 0xf0, 0x0d, 0x0c, 0x00, 0x02, 0x00, 0xee, 0xff, 0x00, 0x35, 0x0c, 0x00, 0x00, 0x00, 0xee, 0xff,
348 0x10, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0xee, 0xff, 0x20, 0x83, 0x0c, 0x00, 0x01, 0x00, 0xee, 0xff,
349 0x30, 0xaa, 0x0c, 0x00, 0x00, 0x00, 0xe5, 0xff, 0x40, 0xd1, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
350 0x50, 0xf8, 0x0c, 0x00, 0x02, 0x00, 0xe5, 0xff, 0x60, 0x1f, 0x0d, 0x00, 0x00, 0x00, 0xe5, 0xff,
351 0x70, 0x46, 0x0d, 0x00, 0x01, 0x00, 0xe5, 0xff, 0x80, 0x6d, 0x0d, 0x00, 0x00, 0x00, 0xdc, 0xff,
352 0x90, 0x94, 0x0d, 0x00, 0x00, 0x00, 0xe5, 0xff, 0xa0, 0xbb, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
353 0xb0, 0xe2, 0x0d, 0x00, 0x01, 0x00, 0xee, 0xff, 0xc0, 0x09, 0x0e, 0x00, 0x01, 0x00, 0xe5, 0xff,
354 0xd0, 0x30, 0x0e, 0x00, 0x00, 0x00, 0xdc, 0xff, 0xe0, 0x57, 0x0e, 0x00, 0x00, 0x00, 0xe5, 0xff,
355 0xf0, 0x7e, 0x0e, 0x00, 0x00, 0x00, 0xe5, 0xff,
359 static Byte UT200_IQtable
[] = {
360 0x49, 0x44, 0x3a, 0x39, 0x39, 0x39, 0x00, 0x01, 0x56, 0x3a, 0x02, 0x01, 0x00, 0x00, 0x00, 0x5c,
361 0x50, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x60, 0xea, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xff,
362 0x70, 0x11, 0x01, 0x00, 0xff, 0xff, 0x00, 0x00, 0x80, 0x38, 0x01, 0x00, 0xff, 0xff, 0x05, 0x00,
363 0x90, 0x5f, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xa0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00,
364 0xb0, 0xad, 0x01, 0x00, 0xff, 0xff, 0x09, 0x00, 0xc0, 0xd4, 0x01, 0x00, 0xff, 0xff, 0x09, 0x00,
365 0xd0, 0xfb, 0x01, 0x00, 0xff, 0xff, 0x05, 0x00, 0xe0, 0x22, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00,
366 0xf0, 0x49, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x71, 0x02, 0x00, 0xff, 0xff, 0x07, 0x00,
367 0x10, 0x98, 0x02, 0x00, 0xff, 0xff, 0x0e, 0x00, 0x20, 0xbf, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00,
368 0x30, 0xe6, 0x02, 0x00, 0xff, 0xff, 0x09, 0x00, 0x40, 0x0d, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
369 0x50, 0x34, 0x03, 0x00, 0xff, 0xff, 0xce, 0xff, 0x60, 0x5b, 0x03, 0x00, 0x00, 0x00, 0xc5, 0xff,
370 0x70, 0x82, 0x03, 0x00, 0x00, 0x00, 0xce, 0xff, 0x80, 0xa9, 0x03, 0x00, 0xff, 0xff, 0xcc, 0xff,
371 0x90, 0xd0, 0x03, 0x00, 0xff, 0xff, 0xae, 0xff, 0xa0, 0xf7, 0x03, 0x00, 0xff, 0xff, 0xc9, 0xff,
372 0xb0, 0x1e, 0x04, 0x00, 0xff, 0xff, 0xbe, 0xff, 0xc0, 0x45, 0x04, 0x00, 0x00, 0x00, 0xb5, 0xff,
373 0xd0, 0x6c, 0x04, 0x00, 0x00, 0x00, 0xc9, 0xff, 0xe0, 0x93, 0x04, 0x00, 0xff, 0xff, 0xbe, 0xff,
374 0xf0, 0xba, 0x04, 0x00, 0xff, 0xff, 0xf2, 0xff, 0x00, 0xe2, 0x04, 0x00, 0xff, 0xff, 0xf7, 0xff,
375 0x10, 0x09, 0x05, 0x00, 0xff, 0xff, 0xf5, 0xff, 0x20, 0x30, 0x05, 0x00, 0xff, 0xff, 0xf2, 0xff,
376 0x30, 0x57, 0x05, 0x00, 0xfe, 0xff, 0xf7, 0xff, 0x40, 0x7e, 0x05, 0x00, 0xfe, 0xff, 0xec, 0xff,
377 0x50, 0xa5, 0x05, 0x00, 0xff, 0xff, 0xf7, 0xff, 0x60, 0xcc, 0x05, 0x00, 0xff, 0xff, 0xec, 0xff,
378 0x70, 0xf3, 0x05, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x80, 0x1a, 0x06, 0x00, 0xff, 0xff, 0xf0, 0xff,
379 0x90, 0x41, 0x06, 0x00, 0xff, 0xff, 0x2e, 0x00, 0xa0, 0x68, 0x06, 0x00, 0xff, 0xff, 0x3d, 0x00,
380 0xb0, 0x8f, 0x06, 0x00, 0xff, 0xff, 0x37, 0x00, 0xc0, 0xb6, 0x06, 0x00, 0xff, 0xff, 0x42, 0x00,
381 0xd0, 0xdd, 0x06, 0x00, 0xff, 0xff, 0x2e, 0x00, 0xe0, 0x04, 0x07, 0x00, 0xff, 0xff, 0x4b, 0x00,
382 0xf0, 0x2b, 0x07, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x53, 0x07, 0x00, 0xff, 0xff, 0x49, 0x00,
383 0x10, 0x7a, 0x07, 0x00, 0xff, 0xff, 0x5b, 0x00, 0x20, 0xa1, 0x07, 0x00, 0xfe, 0xff, 0x4b, 0x00,
384 0x30, 0xc8, 0x07, 0x00, 0xff, 0xff, 0x4d, 0x00, 0x40, 0xef, 0x07, 0x00, 0x01, 0x00, 0x47, 0x00,
385 0x50, 0x16, 0x08, 0x00, 0xff, 0xff, 0x64, 0x00, 0x60, 0x3d, 0x08, 0x00, 0x00, 0x00, 0x56, 0x00,
386 0x70, 0x64, 0x08, 0x00, 0xff, 0xff, 0x66, 0x00, 0x80, 0x8b, 0x08, 0x00, 0xff, 0xff, 0x52, 0x00,
387 0x90, 0xb2, 0x08, 0x00, 0xfe, 0xff, 0x44, 0x00, 0xa0, 0xd9, 0x08, 0x00, 0xff, 0xff, 0x59, 0x00,
388 0xb0, 0x00, 0x09, 0x00, 0xff, 0xff, 0x56, 0x00, 0xc0, 0x27, 0x09, 0x00, 0xff, 0xff, 0x66, 0x00,
389 0xd0, 0x4e, 0x09, 0x00, 0xff, 0xff, 0x62, 0x00, 0xe0, 0x75, 0x09, 0x00, 0xff, 0xff, 0x94, 0x00,
390 0xf0, 0x9c, 0x09, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0xc4, 0x09, 0x00, 0xfe, 0xff, 0x82, 0x00,
391 0x10, 0xeb, 0x09, 0x00, 0xff, 0xff, 0x52, 0x00, 0x20, 0x12, 0x0a, 0x00, 0xff, 0xff, 0x98, 0x00,
392 0x30, 0x39, 0x0a, 0x00, 0x00, 0x00, 0x59, 0x00, 0x40, 0x60, 0x0a, 0x00, 0x00, 0x00, 0x79, 0x00,
393 0x50, 0x87, 0x0a, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x60, 0xae, 0x0a, 0x00, 0xff, 0xff, 0x9d, 0x00,
394 0x70, 0xd5, 0x0a, 0x00, 0xff, 0xff, 0x8b, 0x00, 0x80, 0xfc, 0x0a, 0x00, 0xff, 0xff, 0xa2, 0x00,
395 0x90, 0x23, 0x0b, 0x00, 0xff, 0xff, 0x64, 0x00, 0xa0, 0x4a, 0x0b, 0x00, 0xff, 0xff, 0x9d, 0x00,
396 0xb0, 0x71, 0x0b, 0x00, 0xff, 0xff, 0x89, 0x00, 0xc0, 0x98, 0x0b, 0x00, 0xff, 0xff, 0x89, 0x00,
397 0xd0, 0xbf, 0x0b, 0x00, 0x00, 0x00, 0x89, 0x00, 0xe0, 0xe6, 0x0b, 0x00, 0xff, 0xff, 0x8b, 0x00,
398 0xf0, 0x0d, 0x0c, 0x00, 0xff, 0xff, 0x9f, 0x00, 0x00, 0x35, 0x0c, 0x00, 0xfe, 0xff, 0x8f, 0x00,
399 0x10, 0x5c, 0x0c, 0x00, 0x01, 0x00, 0x98, 0x00, 0x20, 0x83, 0x0c, 0x00, 0x00, 0x00, 0x84, 0x00,
400 0x30, 0xaa, 0x0c, 0x00, 0xff, 0xff, 0xb1, 0x00, 0x40, 0xd1, 0x0c, 0x00, 0x00, 0x00, 0xb4, 0x00,
401 0x50, 0xf8, 0x0c, 0x00, 0x00, 0x00, 0xad, 0x00, 0x60, 0x1f, 0x0d, 0x00, 0xff, 0xff, 0x9f, 0x00,
402 0x70, 0x46, 0x0d, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x80, 0x6d, 0x0d, 0x00, 0xff, 0xff, 0xb8, 0x00,
403 0x90, 0x94, 0x0d, 0x00, 0xff, 0xff, 0xcd, 0x00, 0xa0, 0xbb, 0x0d, 0x00, 0xff, 0xff, 0xcb, 0x00,
404 0xb0, 0xe2, 0x0d, 0x00, 0xff, 0xff, 0xc6, 0x00, 0xc0, 0x09, 0x0e, 0x00, 0xff, 0xff, 0xda, 0x00,
405 0xd0, 0x30, 0x0e, 0x00, 0xff, 0xff, 0xc8, 0x00, 0xe0, 0x57, 0x0e, 0x00, 0xff, 0xff, 0xd4, 0x00,
406 0xf0, 0x7e, 0x0e, 0x00, 0xfe, 0xff, 0xd1, 0x00, 0xc0, 0xc6, 0x2d, 0x00, 0xfe, 0xff, 0xd1, 0x00,
409 static int init_modulator(
416 int transmissionMode
,
422 Dword dwError
= ERR_NO_ERROR
;
423 MODULATION_PARAM ChannelModulation_Setting
;
425 /* Open handle Power On and Check device information */
426 if((dwError
= g_ITEAPI_TxDeviceInit(DevType
, DevNo
)) != ERR_NO_ERROR
) {
427 printf("g_ITEAPI_TxDeviceInit fail\n");
431 if (DevType
== EAGLEII
) {
432 dwError
= g_ITEAPI_TxSetIQTable(UT200_IQtable
, sizeof(UT200_IQtable
), DevNo
);
434 fprintf(stderr
, "Set IQ Calibration Table fail: 0x%08lx\n", dwError
);
437 dwError
= g_ITEAPI_TxSetIQTable(UT100_IQtable
, sizeof(UT100_IQtable
), DevNo
);
439 fprintf(stderr
, "Set IQ Calibration Table fail: 0x%08lx\n", dwError
);
443 if ((dwError
= g_ITEAPI_TxSetChannel(frequency
, bandwidth
, DevNo
)) != ERR_NO_ERROR
) {
444 fprintf(stderr
, "g_ITEAPI_TxSetChannel error\n");
448 if(g_ITEAPI_TxAdjustOutputGain(gain
, &outgainvalue
, DevNo
) != ERR_NO_ERROR
) {
449 fprintf(stderr
, "g_ITEAPI_TxAdjustOutputGain error\n");
453 ChannelModulation_Setting
.constellation
= constellation
;
454 ChannelModulation_Setting
.highCodeRate
= codeRate
;
455 ChannelModulation_Setting
.interval
= guardInterval
;
456 ChannelModulation_Setting
.transmissionMode
= transmissionMode
;
458 if ((dwError
= g_ITEAPI_TxSetChannelModulation(ChannelModulation_Setting
, DevNo
)) != ERR_NO_ERROR
)
459 fprintf(stderr
, "g_ITEAPI_TxSetChannelModulation error!!, %lu ******\n", dwError
);
461 dwError
= g_ITEAPI_TxGetTPS(&tps
, DevNo
);
463 fprintf(stderr
, "\n****** g_ITEAPI_TxGetTPS error!!, %lu ******\n", dwError
);
467 dwError
= g_ITEAPI_TxSetTPS(tps
, DevNo
);
469 fprintf(stderr
, "\n****** g_ITEAPI_TxSetTPS error!!, %lu ******\n", dwError
);
472 g_ITEAPI_TxSetModeEnable(True
, DevNo
);
473 g_ITEAPI_StartTransfer(DevNo
);
478 static void ts_output(unsigned char *p
, int total
)
481 len
= g_ITEAPI_TxSendTSData(p
, total
, DevNo
);
484 if (errno
== EWOULDBLOCK
|| errno
== EAGAIN
) {
485 logwrite(LOG_ERR
, "Blocking write");
488 logwrite(LOG_ERR
, "Sending failed: %", errno
);