05fc2031c3bc2cd067d7d8ce2eab7eab626373d5
[fw/altos] / altoslib / AltosConfigData.java
1 /*
2  * Copyright © 2011 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 package org.altusmetrum.altoslib_11;
20
21 import java.util.*;
22 import java.text.*;
23 import java.util.concurrent.*;
24
25 public class AltosConfigData implements Iterable<String> {
26
27         /* Version information */
28         public String   manufacturer;
29         public String   product;
30         public int      serial;
31         public int      flight;
32         public int      log_format;
33         public int      log_space;
34         public String   version;
35         public int      altitude_32;
36
37         /* Strings returned */
38         public LinkedList<String>       __lines;
39
40         /* Config information */
41         /* HAS_FLIGHT*/
42         public int      main_deploy;
43         public int      apogee_delay;
44         public int      apogee_lockout;
45
46         /* HAS_RADIO */
47         public int      radio_frequency;
48         public String   callsign;
49         public int      radio_enable;
50         public int      radio_calibration;
51         public int      telemetry_rate;
52         /* Old HAS_RADIO values */
53         public int      radio_channel;
54         public int      radio_setting;
55
56         /* HAS_ACCEL */
57         public int      accel_cal_plus, accel_cal_minus;
58         public int      pad_orientation;
59
60         /* HAS_LOG */
61         public int      flight_log_max;
62         public int      log_fixed;
63
64         /* HAS_IGNITE */
65         public int      ignite_mode;
66
67         /* HAS_AES */
68         public String   aes_key;
69
70         /* AO_PYRO_NUM */
71         public AltosPyro[]      pyros;
72         public int              npyro;
73         public int              pyro;
74         public double           pyro_firing_time;
75
76         /* HAS_APRS */
77         public int              aprs_interval;
78         public int              aprs_ssid;
79         public int              aprs_format;
80
81         /* HAS_BEEP */
82         public int              beep;
83
84         /* Storage info replies */
85         public int      storage_size;
86         public int      storage_erase_unit;
87
88         /* Log listing replies */
89         public int      stored_flight;
90
91         /* HAS_TRACKER */
92         public int      tracker_motion;
93         public int      tracker_interval;
94
95         /* HAS_GYRO */
96         public int      accel_zero_along, accel_zero_across, accel_zero_through;
97
98         /* ms5607 data */
99         public int      ms5607_reserved;
100         public int      ms5607_sens;
101         public int      ms5607_off;
102         public int      ms5607_tcs;
103         public int      ms5607_tco;
104         public int      ms5607_tref;
105         public int      ms5607_tempsens;
106         public int      ms5607_crc;
107
108         public static String get_string(String line, String label) throws  ParseException {
109                 if (line.startsWith(label)) {
110                         String  quoted = line.substring(label.length()).trim();
111
112                         if (quoted.startsWith("\""))
113                                 quoted = quoted.substring(1);
114                         if (quoted.endsWith("\""))
115                                 quoted = quoted.substring(0,quoted.length()-1);
116                         return quoted;
117                 }
118                 throw new ParseException("mismatch", 0);
119         }
120
121         public static int get_int(String line, String label) throws NumberFormatException, ParseException {
122                 if (line.startsWith(label)) {
123                         String tail = line.substring(label.length()).trim();
124                         String[] tokens = tail.split("\\s+");
125                         if (tokens.length > 0)
126                                 return  Integer.parseInt(tokens[0]);
127                 }
128                 throw new ParseException("mismatch", 0);
129         }
130
131         public static int[] get_values(String line, String label) throws NumberFormatException, ParseException {
132                 if (line.startsWith(label)) {
133                         String tail = line.substring(label.length()).trim();
134                         String[] tokens = tail.split("\\s+");
135                         if (tokens.length > 1) {
136                                 int[]   values = new int[2];
137                                 values[0] = Integer.parseInt(tokens[0]);
138                                 values[1] = Integer.parseInt(tokens[1]);
139                                 return values;
140                         }
141                 }
142                 throw new ParseException("mismatch", 0);
143         }
144
145         public Iterator<String> iterator() {
146                 return __lines.iterator();
147         }
148
149         public int log_space() {
150                 if (log_space > 0)
151                         return log_space;
152
153                 if (storage_size > 0) {
154                         int     space = storage_size;
155
156                         if (storage_erase_unit > 0 && use_flash_for_config())
157                                 space -= storage_erase_unit;
158
159                         if (space > 0)
160                                 return space;
161                 }
162                 return 0;
163         }
164
165         public int log_available() {
166                 switch (log_format) {
167                 case AltosLib.AO_LOG_FORMAT_TINY:
168                         if (stored_flight == 0)
169                                 return 1;
170                         return 0;
171                 case AltosLib.AO_LOG_FORMAT_TELEMETRY:
172                 case AltosLib.AO_LOG_FORMAT_TELESCIENCE:
173                         return 1;
174                 default:
175                         if (flight_log_max <= 0)
176                                 return 1;
177                         int     log_max = flight_log_max * 1024;
178                         int     log_space = log_space();
179                         int     log_used;
180
181                         if (stored_flight <= 0)
182                                 log_used = 0;
183                         else
184                                 log_used = stored_flight * log_max;
185                         int     log_avail;
186
187                         if (log_used >= log_space)
188                                 log_avail = 0;
189                         else
190                                 log_avail = (log_space - log_used) / log_max;
191
192                         return log_avail;
193                 }
194         }
195
196         public boolean has_monitor_battery() {
197                 if (product.startsWith("TeleBT"))
198                         return true;
199                 return false;
200         }
201
202         int[] parse_version(String v) {
203                 String[] parts = v.split("\\.");
204                 int r[] = new int[parts.length];
205
206                 for (int i = 0; i < parts.length; i++) {
207                         try {
208                                 r[i] = (int) AltosLib.fromdec(parts[i]);
209                         } catch (NumberFormatException n) {
210                                 r[i] = 0;
211                         }
212                 }
213
214                 return r;
215         }
216
217         public boolean altitude_32() {
218                 return altitude_32 == 1;
219         }
220
221         public int compare_version(String other) {
222                 int[]   me = parse_version(version);
223                 int[]   them = parse_version(other);
224
225                 int     l = Math.min(me.length, them.length);
226
227                 for (int i = 0; i < l; i++) {
228                         int     d = me[i] - them[i];
229                         if (d != 0)
230                                 return d;
231                 }
232                 if (me.length > l)
233                         return 1;
234                 if (them.length > l)
235                         return -1;
236                 return 0;
237         }
238
239         public void reset() {
240                 __lines = new LinkedList<String>();
241
242                 manufacturer = null;
243                 product = null;
244                 serial = AltosLib.MISSING;
245                 flight = AltosLib.MISSING;
246                 log_format = AltosLib.AO_LOG_FORMAT_UNKNOWN;
247                 log_space = AltosLib.MISSING;
248                 version = "unknown";
249
250                 main_deploy = AltosLib.MISSING;
251                 apogee_delay = AltosLib.MISSING;
252                 apogee_lockout = AltosLib.MISSING;
253
254                 radio_frequency = AltosLib.MISSING;
255                 callsign = null;
256                 radio_enable = AltosLib.MISSING;
257                 radio_calibration = AltosLib.MISSING;
258                 radio_channel = AltosLib.MISSING;
259                 radio_setting = AltosLib.MISSING;
260                 telemetry_rate = AltosLib.MISSING;
261
262                 accel_cal_plus = AltosLib.MISSING;
263                 accel_cal_minus = AltosLib.MISSING;
264                 pad_orientation = AltosLib.MISSING;
265
266                 flight_log_max = AltosLib.MISSING;
267                 log_fixed = AltosLib.MISSING;
268                 ignite_mode = AltosLib.MISSING;
269
270                 aes_key = null;
271
272                 pyro = 0;
273                 npyro = 0;
274                 pyros = null;
275                 pyro_firing_time = AltosLib.MISSING;
276
277                 aprs_interval = AltosLib.MISSING;
278                 aprs_ssid = AltosLib.MISSING;
279                 aprs_format = AltosLib.MISSING;
280
281                 beep = AltosLib.MISSING;
282
283                 tracker_motion = AltosLib.MISSING;
284                 tracker_interval = AltosLib.MISSING;
285
286                 storage_size = AltosLib.MISSING;
287                 storage_erase_unit = AltosLib.MISSING;
288                 stored_flight = AltosLib.MISSING;
289
290                 accel_zero_along = AltosLib.MISSING;
291                 accel_zero_across = AltosLib.MISSING;
292                 accel_zero_through = AltosLib.MISSING;
293         }
294
295         public void parse_line(String line) {
296                 __lines.add(line);
297                 /* Version replies */
298                 try { manufacturer = get_string(line, "manufacturer"); } catch (Exception e) {}
299                 try { product = get_string(line, "product"); } catch (Exception e) {}
300                 try { serial = get_int(line, "serial-number"); } catch (Exception e) {}
301                 try { flight = get_int(line, "current-flight"); } catch (Exception e) {}
302                 try { log_format = get_int(line, "log-format"); } catch (Exception e) {}
303                 try { log_space = get_int(line, "log-space"); } catch (Exception e) {}
304                 try { altitude_32 = get_int(line, "altitude-32"); } catch (Exception e) {}
305                 try { version = get_string(line, "software-version"); } catch (Exception e) {}
306
307                 /* Version also contains MS5607 info, which we ignore here */
308
309                 try { ms5607_reserved = get_int(line, "ms5607 reserved:"); } catch (Exception e) {}
310                 try { ms5607_sens = get_int(line, "ms5607 sens:"); } catch (Exception e) {}
311                 try { ms5607_off = get_int(line, "ms5607 off:"); } catch (Exception e) {}
312                 try { ms5607_tcs = get_int(line, "ms5607 tcs:"); } catch (Exception e) {}
313                 try { ms5607_tco = get_int(line, "ms5607 tco:"); } catch (Exception e) {}
314                 try { ms5607_tref = get_int(line, "ms5607 tref:"); } catch (Exception e) {}
315                 try { ms5607_tempsens = get_int(line, "ms5607 tempsens:"); } catch (Exception e) {}
316                 try { ms5607_crc = get_int(line, "ms5607 crc:"); } catch (Exception e) {}
317
318                 /* Config show replies */
319
320                 /* HAS_FLIGHT */
321                 try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {}
322                 try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {}
323                 try { apogee_lockout = get_int(line, "Apogee lockout:"); } catch (Exception e) {}
324
325                 /* HAS_RADIO */
326                 try {
327                         radio_frequency = get_int(line, "Frequency:");
328                         if (radio_frequency < 0)
329                                 radio_frequency = 434550;
330                 } catch (Exception e) {}
331                 try { callsign = get_string(line, "Callsign:"); } catch (Exception e) {}
332                 try { radio_enable = get_int(line, "Radio enable:"); } catch (Exception e) {}
333                 try { radio_calibration = get_int(line, "Radio cal:"); } catch (Exception e) {}
334                 try { telemetry_rate = get_int(line, "Telemetry rate:"); } catch (Exception e) {}
335
336                 /* Old HAS_RADIO values */
337                 try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {}
338                 try { radio_setting = get_int(line, "Radio setting:"); } catch (Exception e) {}
339
340                 /* HAS_ACCEL */
341                 try {
342                         if (line.startsWith("Accel cal")) {
343                                 String[] bits = line.split("\\s+");
344                                 if (bits.length >= 6) {
345                                         accel_cal_plus = Integer.parseInt(bits[3]);
346                                         accel_cal_minus = Integer.parseInt(bits[5]);
347                                 }
348                         }
349                 } catch (Exception e) {}
350                 try { pad_orientation = get_int(line, "Pad orientation:"); } catch (Exception e) {}
351
352                 /* HAS_LOG */
353                 try { flight_log_max = get_int(line, "Max flight log:"); } catch (Exception e) {}
354                 try { log_fixed = get_int(line, "Log fixed:"); } catch (Exception e) {}
355
356                 /* HAS_IGNITE */
357                 try { ignite_mode = get_int(line, "Ignite mode:"); } catch (Exception e) {}
358
359                 /* HAS_AES */
360                 try { aes_key = get_string(line, "AES key:"); } catch (Exception e) {}
361
362                 /* AO_PYRO_NUM */
363                 try {
364                         npyro = get_int(line, "Pyro-count:");
365                         pyros = new AltosPyro[npyro];
366                         pyro = 0;
367                 } catch (Exception e) {}
368                 if (npyro > 0) {
369                         try {
370                                 AltosPyro p = new AltosPyro(pyro, line);
371                                 if (pyro < npyro)
372                                         pyros[pyro++] = p;
373                         } catch (Exception e) {}
374                 }
375                 try { pyro_firing_time = get_int(line, "Pyro time:") / 100.0; } catch (Exception e) {}
376
377                 /* HAS_APRS */
378                 try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {}
379                 try { aprs_ssid = get_int(line, "APRS SSID:"); } catch (Exception e) {}
380                 try { aprs_format = get_int(line, "APRS format:"); } catch (Exception e) {}
381
382                 /* HAS_BEEP */
383                 try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {}
384
385                 /* HAS_TRACKER */
386                 try {
387                         int[] values = get_values(line, "Tracker setting:");
388                         tracker_motion = values[0];
389                         tracker_interval = values[1];
390                 } catch (Exception e) {}
391
392                 /* Storage info replies */
393                 try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {}
394                 try { storage_erase_unit = get_int(line, "Storage erase unit:"); } catch (Exception e) {}
395
396                 /* Log listing replies */
397                 try { get_int(line, "flight"); stored_flight++; }  catch (Exception e) {}
398
399                 /* HAS_GYRO */
400                 try {
401                         if (line.startsWith("IMU call along")) {
402                                 String[] bits = line.split("\\s+");
403                                 if (bits.length >= 8) {
404                                         accel_zero_along = Integer.parseInt(bits[3]);
405                                         accel_zero_across = Integer.parseInt(bits[5]);
406                                         accel_zero_through = Integer.parseInt(bits[7]);
407                                 }
408                         }
409                 } catch (Exception e) {}
410         }
411
412         public AltosConfigData() {
413                 reset();
414         }
415
416         private void read_link(AltosLink link, String finished) throws InterruptedException, TimeoutException {
417                 for (;;) {
418                         String line = link.get_reply();
419                         if (line == null)
420                                 throw new TimeoutException();
421                         if (line.contains("Syntax error"))
422                                 continue;
423                         this.parse_line(line);
424
425                         /* signals the end of the version info */
426                         if (line.startsWith(finished))
427                                 break;
428                 }
429         }
430
431         public boolean has_frequency() {
432                 return radio_frequency >= 0 || radio_setting >= 0 || radio_channel >= 0;
433         }
434
435         public boolean has_telemetry_rate() {
436                 return telemetry_rate >= 0;
437         }
438
439         public void set_frequency(double freq) {
440                 int     frequency = radio_frequency;
441                 int     setting = radio_setting;
442
443                 if (frequency > 0) {
444                         radio_frequency = (int) Math.floor (freq * 1000 + 0.5);
445                         radio_channel = AltosLib.MISSING;
446                 } else if (setting > 0) {
447                         radio_setting =AltosConvert.radio_frequency_to_setting(freq,
448                                                                                     radio_calibration);
449                         radio_channel = AltosLib.MISSING;
450                 } else {
451                         radio_channel = AltosConvert.radio_frequency_to_channel(freq);
452                 }
453         }
454
455         public double frequency() {
456                 int     channel = radio_channel;
457                 int     setting = radio_setting;
458
459                 if (radio_frequency < 0 && channel < 0 && setting < 0)
460                         return AltosLib.MISSING;
461
462                 if (channel < 0)
463                         channel = 0;
464                 if (setting < 0)
465                         setting = 0;
466
467                 return AltosConvert.radio_to_frequency(radio_frequency,
468                                                        setting,
469                                                        radio_calibration,
470                                                        channel);
471         }
472
473         boolean use_flash_for_config() {
474                 if (product.startsWith("TeleMega"))
475                         return false;
476                 if (product.startsWith("TeleMetrum-v2"))
477                         return false;
478                 if (product.startsWith("EasyMega"))
479                         return false;
480                 return true;
481         }
482
483
484         public boolean mma655x_inverted() throws AltosUnknownProduct {
485                 if (product.startsWith("EasyMega-v1"))
486                         return false;
487                 if (product.startsWith("TeleMetrum-v2"))
488                         return true;
489                 if (product.startsWith("TeleMega-v2"))
490                         return false;
491                 if (product.startsWith("TeleMega-v1"))
492                         return false;
493                 throw new AltosUnknownProduct(product);
494         }
495
496         public void get_values(AltosConfigValues source) throws AltosConfigDataException {
497
498                 /* HAS_FLIGHT */
499                 if (main_deploy >= 0)
500                         main_deploy = source.main_deploy();
501                 if (apogee_delay >= 0)
502                         apogee_delay = source.apogee_delay();
503                 if (apogee_lockout >= 0)
504                         apogee_lockout = source.apogee_lockout();
505
506                 /* HAS_RADIO */
507                 if (has_frequency())
508                         set_frequency(source.radio_frequency());
509                 if (radio_enable >= 0)
510                         radio_enable = source.radio_enable();
511                 if (callsign != null)
512                         callsign = source.callsign();
513                 if (telemetry_rate >= 0)
514                         telemetry_rate = source.telemetry_rate();
515
516                 /* HAS_ACCEL */
517                 if (pad_orientation >= 0)
518                         pad_orientation = source.pad_orientation();
519
520                 /* HAS_LOG */
521                 if (flight_log_max >= 0)
522                         flight_log_max = source.flight_log_max();
523
524                 /* HAS_IGNITE */
525                 if (ignite_mode >= 0)
526                         ignite_mode = source.ignite_mode();
527
528                 /* AO_PYRO_NUM */
529                 if (npyro > 0)
530                         pyros = source.pyros();
531                 if (pyro_firing_time >= 0)
532                         pyro_firing_time = source.pyro_firing_time();
533
534                 /* HAS_APRS */
535                 if (aprs_interval >= 0)
536                         aprs_interval = source.aprs_interval();
537                 if (aprs_ssid >= 0)
538                         aprs_ssid = source.aprs_ssid();
539                 if (aprs_format >= 0)
540                         aprs_format = source.aprs_format();
541
542                 /* HAS_BEEP */
543                 if (beep >= 0)
544                         beep = source.beep();
545                 /* HAS_TRACKER */
546                 if (tracker_motion >= 0)
547                         tracker_motion = source.tracker_motion();
548                 if (tracker_interval >= 0)
549                         tracker_interval = source.tracker_interval();
550         }
551
552         public void set_values(AltosConfigValues dest) {
553                 dest.set_serial(serial);
554                 dest.set_product(product);
555                 dest.set_version(version);
556                 dest.set_altitude_32(altitude_32);
557                 dest.set_main_deploy(main_deploy);
558                 dest.set_apogee_delay(apogee_delay);
559                 dest.set_apogee_lockout(apogee_lockout);
560                 dest.set_radio_calibration(radio_calibration);
561                 dest.set_radio_frequency(frequency());
562                 dest.set_telemetry_rate(telemetry_rate);
563                 boolean max_enabled = true;
564
565                 if (log_space() == 0)
566                         max_enabled = false;
567
568                 if (log_fixed > 0)
569                         max_enabled = false;
570
571                 switch (log_format) {
572                 case AltosLib.AO_LOG_FORMAT_TINY:
573                         max_enabled = false;
574                         break;
575                 default:
576                         if (stored_flight > 0)
577                                 max_enabled = false;
578                         break;
579                 }
580
581                 dest.set_flight_log_max_enabled(max_enabled);
582                 dest.set_radio_enable(radio_enable);
583                 dest.set_flight_log_max_limit(log_space() / 1024);
584                 dest.set_flight_log_max(flight_log_max);
585                 dest.set_ignite_mode(ignite_mode);
586                 dest.set_pad_orientation(pad_orientation);
587                 dest.set_callsign(callsign);
588                 if (npyro > 0)
589                         dest.set_pyros(pyros);
590                 else
591                         dest.set_pyros(null);
592                 dest.set_pyro_firing_time(pyro_firing_time);
593                 dest.set_aprs_interval(aprs_interval);
594                 dest.set_aprs_ssid(aprs_ssid);
595                 dest.set_aprs_format(aprs_format);
596                 dest.set_beep(beep);
597                 dest.set_tracker_motion(tracker_motion);
598                 dest.set_tracker_interval(tracker_interval);
599         }
600
601         public boolean log_has_state() {
602                 switch (log_format) {
603                 case AltosLib.AO_LOG_FORMAT_TELEGPS:
604                         return false;
605                 }
606                 return true;
607         }
608
609         public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException {
610
611                 /* HAS_FLIGHT */
612                 if (main_deploy >= 0)
613                         link.printf("c m %d\n", main_deploy);
614                 if (apogee_delay >= 0)
615                         link.printf("c d %d\n", apogee_delay);
616                 if (apogee_lockout >= 0)
617                         link.printf("c L %d\n", apogee_lockout);
618
619                 /* HAS_RADIO */
620                 if (has_frequency()) {
621                         boolean has_frequency = radio_frequency >= 0;
622                         boolean has_setting = radio_setting > 0;
623                         double frequency = frequency();
624                         link.set_radio_frequency(frequency,
625                                                         has_frequency,
626                                                         has_setting,
627                                                         radio_calibration);
628                         /* When remote, reset the dongle frequency at the same time */
629                         if (remote) {
630                                 link.flush_output();
631                                 link.stop_remote();
632                                 link.set_radio_frequency(frequency);
633                                 link.flush_output();
634                                 link.start_remote();
635                         }
636                 }
637
638                 if (telemetry_rate >= 0) {
639                         link.printf("c T %d\n", telemetry_rate);
640                         if (remote) {
641                                 link.flush_output();
642                                 link.stop_remote();
643                                 link.set_telemetry_rate(telemetry_rate);
644                                 link.flush_output();
645                                 link.start_remote();
646                         }
647                 }
648
649                 if (callsign != null) {
650                         link.printf("c c %s\n", callsign);
651                         if (remote) {
652                                 link.flush_output();
653                                 link.stop_remote();
654                                 link.set_callsign(callsign);
655                                 link.flush_output();
656                                 link.start_remote();
657                         }
658                 }
659
660                 if (radio_enable >= 0)
661                         link.printf("c e %d\n", radio_enable);
662
663                 /* HAS_ACCEL */
664                 /* UI doesn't support accel cal */
665                 if (pad_orientation >= 0)
666                         link.printf("c o %d\n", pad_orientation);
667
668                 /* HAS_LOG */
669                 if (flight_log_max != 0)
670                         link.printf("c l %d\n", flight_log_max);
671
672                 /* HAS_IGNITE */
673                 if (ignite_mode >= 0)
674                         link.printf("c i %d\n", ignite_mode);
675
676                 /* HAS_AES */
677                 /* UI doesn't support AES key config */
678
679                 /* AO_PYRO_NUM */
680                 if (npyro > 0) {
681                         for (int p = 0; p < pyros.length; p++) {
682                                 link.printf("c P %s\n",
683                                                    pyros[p].toString());
684                         }
685                 }
686                 if (pyro_firing_time >= 0)
687                         link.printf("c I %d\n", (int) (pyro_firing_time * 100.0 + 0.5));
688
689                 /* HAS_APRS */
690                 if (aprs_interval >= 0)
691                         link.printf("c A %d\n", aprs_interval);
692                 if (aprs_ssid >= 0)
693                         link.printf("c S %d\n", aprs_ssid);
694                 if (aprs_format >= 0)
695                         link.printf("c C %d\n", aprs_format);
696
697                 /* HAS_BEEP */
698                 if (beep >= 0)
699                         link.printf("c b %d\n", beep);
700
701                 /* HAS_TRACKER */
702                 if (tracker_motion >= 0 && tracker_interval >= 0)
703                         link.printf("c t %d %d\n", tracker_motion, tracker_interval);
704
705                 /* HAS_GYRO */
706                 /* UI doesn't support accel cal */
707
708                 link.printf("c w\n");
709                 link.flush_output();
710         }
711
712         public AltosConfigData(AltosLink link) throws InterruptedException, TimeoutException {
713                 reset();
714                 link.printf("c s\nf\nv\n");
715                 read_link(link, "software-version");
716                 switch (log_format) {
717                 case AltosLib.AO_LOG_FORMAT_UNKNOWN:
718                 case AltosLib.AO_LOG_FORMAT_NONE:
719                         break;
720                 default:
721                         link.printf("l\n");
722                         read_link(link, "done");
723                         break;
724                 }
725         }
726 }