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