annotate rvinterf/etmsync/readcal.c @ 465:003e48f8ebe1

rvinterf/etmsync/fsnew.c: cast 0 to (char *) for execl sentinel I generally don't use NULL and use plain 0 instead, based on a "NULL considered harmful" discussion on the classiccmp mailing list many aeons ago (I couldn't find it, and I reason that it must have been 2005 or earlier), but a recent complaint by a packager sent me searching, and I found this: https://ewontfix.com/11/ While I don't give a @#$% about "modern" systems and code-nazi tools, I realized that passing a plain 0 as a pointer sentinel in execl is wrong because it will break on systems where pointers are longer than the plain int type. Again, I don't give a @#$% about the abomination of x86_64 and the like, but if anyone ever manages to port my code to something like a PDP-11 (16-bit int, 32-bit long and pointers), then passing a plain 0 as a function argument where a pointer is expected most definitely won't work: if the most natural stack slot and SP alignment unit is 16 bits, fitting an int, with longs and pointers taking up two such slots, then the call stack will be totally wrong with a plain 0 passed for a pointer. Casting the 0 to (char *) ought to be the most kosher solution for the most retro systems possible.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 11 Feb 2019 00:00:19 +0000
parents e40bb5a6c6b9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
278
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This utility reads the RF calibration data out of a TI-based GSM device
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * using the L1TM protocol over RVTMUX. Warning: invasive tms 1 and rfpw 7
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * commands are issued to the target in order to select the band of interest!
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/file.h>
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <string.h>
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <strings.h>
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <unistd.h>
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "tm3.h"
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "l1tm.h"
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include "localtypes.h"
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include "exitcodes.h"
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int compal_mode;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 extern char *socket_pathname;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /* macro for encoding std and band in rfpw 7 command */
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 #define RFPW_STD_BAND(std,band) ((std) | ((band) << 8))
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 static struct band {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 char *argname;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 char *filename;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 unsigned rfpw_std_band;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 } bands[] = {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 {"900", "900", RFPW_STD_BAND(6, 0)},
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {"1800", "1800", RFPW_STD_BAND(6, 1)},
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 {"1900", "1900", RFPW_STD_BAND(8, 1)},
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {"850", "850", RFPW_STD_BAND(8, 0)},
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 {"1900s", "1900", RFPW_STD_BAND(3, 0)},
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 {"850s", "850", RFPW_STD_BAND(7, 0)},
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 {0, 0, 0}
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 };
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 static void
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 write_out_file(filename, data, size)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 char *filename;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 u_char *data;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 int fd;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 if (fd < 0) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 perror(filename);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 exit(ERROR_UNIX);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 write(fd, data, size);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 close(fd);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 copy_afcdac()
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 u16 datum;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 u_char bytes[2];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 int rc;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 rc = do_rfpr(INITIAL_AFC_DAC, &datum);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 exit(rc);
279
36ae854536e8 fc-readcal: fixed bug in the shifting of afcdac
Mychaela Falconia <falcon@freecalypso.org>
parents: 278
diff changeset
66 datum <<= 3;
278
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 bytes[0] = datum;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 bytes[1] = datum >> 8;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 write_out_file("afcdac", bytes, 2);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 copy_afcparams()
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 u_char table[24];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 int rc;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 rc = do_rftr(AFC_PARAMS, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 write_out_file("afcparams", table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 copy_rx_agcparams(bandname)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 char *bandname;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 u_char table[8];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 char filename[32];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 int rc;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 rc = do_rftr(RX_AGC_PARAMS, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 sprintf(filename, "rx/agcparams.%s", bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 write_out_file(filename, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 copy_rx_calchan(bandname)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 char *bandname;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 u_char table[40];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 char filename[32];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 int rc;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 rc = do_rftr(RX_CAL_CHAN, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 sprintf(filename, "rx/calchan.%s", bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 write_out_file(filename, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 copy_tx_levels(bandname)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 char *bandname;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 u_char table[128];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 char filename[32];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 int rc;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 rc = do_rftr(TX_LEVELS, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 sprintf(filename, "tx/levels.%s", bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 write_out_file(filename, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 copy_tx_calchan(bandname)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 char *bandname;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 u_char table[128];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 char filename[32];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 int rc;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 rc = do_rftr(TX_CAL_CHAN, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 sprintf(filename, "tx/calchan.%s", bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 write_out_file(filename, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 copy_tx_ramps(bandname)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 char *bandname;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 u_char table[512];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 char filename[32];
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 int rc, i;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 for (i = 0; i < 16; i++) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 rc = do_ttr(i, table + i * 32);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 sprintf(filename, "tx/ramps.%s", bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 write_out_file(filename, table, sizeof table);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 process_band(bandname)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 char *bandname;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 int rc;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 rc = host_mkdir("rx");
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 copy_rx_agcparams(bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 if (!compal_mode)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 copy_rx_calchan(bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 rc = host_mkdir("tx");
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 copy_tx_levels(bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 if (!compal_mode)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 copy_tx_calchan(bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 copy_tx_ramps(bandname);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 single_op_main(argc, argv)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 char **argv;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 int rc;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 char **ap;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 struct band *tp;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 if (argc < 2) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 fprintf(stderr,
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 "usage: fc-readcal [options] output-dir band...\n");
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 exit(ERROR_USAGE);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 if (chdir(argv[0]) < 0) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 perror(argv[0]);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 exit(ERROR_UNIX);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 rc = do_tms(1);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 for (ap = argv + 1; *ap; ap++) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 if (!strcmp(*ap, "afc")) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 copy_afcdac();
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 copy_afcparams();
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 continue;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 for (tp = bands; tp->argname; tp++)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 if (!strcmp(*ap, tp->argname))
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 break;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 if (!tp->argname) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 fprintf(stderr, "error: unknown band name \"%s\"\n",
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 *ap);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 exit(ERROR_USAGE);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 rc = do_rfpw(STD_BAND_FLAG, tp->rfpw_std_band);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 if (rc)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 exit(rc);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 process_band(tp->filename);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 exit(0);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 main(argc, argv)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 char **argv;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 extern int optind;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 extern char *optarg;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 int c, sopt = 0;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 while ((c = getopt(argc, argv, "B:cl:p:s:w:")) != EOF)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 switch (c) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 case 'B':
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 rvinterf_Bopt = optarg;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 continue;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 case 'c':
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 compal_mode++;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 continue;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 case 'l':
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 rvinterf_lopt = optarg;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 continue;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 case 'p':
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 rvinterf_ttyport = optarg;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 continue;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 case 's':
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 socket_pathname = optarg;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 sopt++;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 continue;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 case 'w':
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 rvinterf_wopt = optarg;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 continue;
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 case '?':
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 default:
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 /* error msg already printed */
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 exit(ERROR_USAGE);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 if (rvinterf_ttyport) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 if (sopt) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 fprintf(stderr,
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 "%s error: -p and -s options are mutually exclusive\n",
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 argv[0]);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 exit(ERROR_USAGE);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 if (compal_mode && !rvinterf_Bopt)
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 rvinterf_Bopt = "57600";
423
e40bb5a6c6b9 rvinterf clients: implemented 30 ms delay for batch ops with -p
Mychaela Falconia <falcon@freecalypso.org>
parents: 279
diff changeset
258 launch_rvinterf(1);
278
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 } else {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 fprintf(stderr,
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 argv[0]);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 exit(ERROR_USAGE);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 connect_local_socket();
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 }
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 return single_op_main(argc - optind, argv + optind);
31d056f37647 fc-readcal written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 }