comparison kk-data-provider.c @ 192:f105ac22da05

Fixes
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Mon, 31 Mar 2014 17:03:31 +0200
parents bc980095a24d
children 4b74b81e0c79
comparison
equal deleted inserted replaced
191:0fed60877099 192:f105ac22da05
37 IniText configuration = Ini_New(TRUE); 37 IniText configuration = Ini_New(TRUE);
38 Ini_ReadFromFile(configuration, path); 38 Ini_ReadFromFile(configuration, path);
39 39
40 /* get serial port name configuration */ 40 /* get serial port name configuration */
41 rv = Ini_GetStringIntoBuffer(configuration, "KK", "port", port, sizeof(port)); 41 rv = Ini_GetStringIntoBuffer(configuration, "KK", "port", port, sizeof(port));
42 if (! rv) 42 if (rv < 1)
43 strncpy(port, DEFAULT_PORT, sizeof(port)); 43 strncpy(port, DEFAULT_PORT, sizeof(port));
44 44
45 /* channel number */ 45 /* channel number */
46 rv = Ini_GetInt(configuration, "KK", "nchan", &nchan); 46 rv = Ini_GetInt(configuration, "KK", "nchan", &nchan);
47 if (! rv) 47 if (rv < 1)
48 nchan = DEFAULT_NCHAN; 48 nchan = DEFAULT_NCHAN;
49 49
50 /* enable scrambler */ 50 /* enable scrambler */
51 rv = Ini_GetInt(configuration, "KK", "scrambler", &scrambler); 51 rv = Ini_GetInt(configuration, "KK", "scrambler", &scrambler);
52 if (! rv) 52 if (rv < 1)
53 scrambler = FALSE; 53 scrambler = 0;
54 54
55 /* free */ 55 /* free */
56 Ini_Dispose(configuration); 56 Ini_Dispose(configuration);
57 57
58 /* initialize library */ 58 /* initialize library */
138 } 138 }
139 139
140 /* scrambler */ 140 /* scrambler */
141 cmd = "\x50"; 141 cmd = "\x50";
142 cmd[0] += scrambler; 142 cmd[0] += scrambler;
143 rv = FX_Send("\x50"); 143 rv = FX_Send(cmd);
144 if (! rv) { 144 if (! rv) {
145 SendMessage(mainThreadId, FX_Error()); 145 SendMessage(mainThreadId, FX_Error());
146 goto error; 146 goto error;
147 } 147 }
148 rv = FX_Recv(&resp, TIMEOUT); 148 rv = FX_Recv(&resp, TIMEOUT);
169 if (! resp) { 169 if (! resp) {
170 SendMessage(mainThreadId, FX_Error()); 170 SendMessage(mainThreadId, FX_Error());
171 break; 171 break;
172 } 172 }
173 173
174 if (strneq(resp, "2900", 4)) { 174 /* 2900 with scrambler off or 2910 with scrambler on */
175 if (strneq(resp, "29", 2)) {
175 176
176 /* timestamp */ 177 /* timestamp */
177 gettimeofday(&event.time, NULL); 178 gettimeofday(&event.time, NULL);
178 179
179 /* parse received data */ 180 /* parse received data */
198 /* ignore undocumented packet. it is sent by newer kk counters 199 /* ignore undocumented packet. it is sent by newer kk counters
199 for each data packet. it probably contains a sample count along 200 for each data packet. it probably contains a sample count along
200 with some other information */ 201 with some other information */
201 } else if (strneq(resp, "7020", 4)) { 202 } else if (strneq(resp, "7020", 4)) {
202 /* undocumented packet. it probably reports the header for 203 /* undocumented packet. it probably reports the header for
203 subsequent data packets. match it against expected value */ 204 subsequent data packets */
204 if (strcmp(resp + 6, "$2900")) { 205 SendMessage(mainThreadId, "KK Counter packet header: %s", resp + 7);
205 SendMessage(mainThreadId, "KK Counter: %s", resp);
206 }
207 } else if (strneq(resp, "7F51", 4)) { 206 } else if (strneq(resp, "7F51", 4)) {
208 /* measurement interval synchronized */ 207 /* measurement interval synchronized */
209 SendMessage(mainThreadId, "KK Counter measurement interval synchronized"); 208 SendMessage(mainThreadId, "KK Counter measurement interval synchronized");
210 } else { 209 } else {
211 /* send message to the main thread */ 210 /* send message to the main thread */