2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
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.
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.
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.
19 package org.altusmetrum.altoslib_14;
23 import java.util.concurrent.*;
25 /* Don't change the field names in this structure; they're part of all .eeprom files */
26 public class AltosConfigData {
28 /* Version information */
29 public String manufacturer;
30 public String product;
33 public int log_format;
35 public String version;
36 public int altitude_32;
37 public int config_major, config_minor;
39 /* Config information */
41 public int main_deploy;
42 public int apogee_delay;
43 public int apogee_lockout;
46 public int radio_frequency;
47 public String callsign;
48 public int radio_enable;
49 public int radio_calibration;
50 public int telemetry_rate;
51 /* Old HAS_RADIO values */
52 public int radio_channel;
53 public int radio_setting;
56 public int accel_cal_plus, accel_cal_minus;
57 private int accel_cal_plus_cooked, accel_cal_minus_cooked;
58 private boolean accel_cal_adjusted;
59 public int pad_orientation;
62 public int flight_log_max;
66 public int ignite_mode;
69 public String aes_key;
72 public AltosPyro[] pyros;
75 public double pyro_firing_time;
78 public int aprs_interval;
80 public int aprs_format;
81 public int aprs_offset;
86 /* Storage info replies */
87 public int storage_size;
88 public int storage_erase_unit;
90 /* Log listing replies */
91 public int stored_flight;
92 public AltosEepromFlight[] flights;
95 public int tracker_motion;
96 public int tracker_interval;
99 public int accel_zero_along, accel_zero_across, accel_zero_through;
104 public AltosMs5607 ms5607() {
106 ms5607 = new AltosMs5607();
110 public static String get_string(String line, String label) throws ParseException {
111 if (line.startsWith(label)) {
112 String quoted = line.substring(label.length()).trim();
114 if (quoted.startsWith("\""))
115 quoted = quoted.substring(1);
116 if (quoted.endsWith("\""))
117 quoted = quoted.substring(0,quoted.length()-1);
120 throw new ParseException("mismatch", 0);
123 public static int get_int(String line, String label) throws NumberFormatException, ParseException {
124 if (line.startsWith(label)) {
125 String tail = line.substring(label.length()).trim();
126 String[] tokens = tail.split("\\s+");
127 if (tokens.length > 0)
128 return Integer.parseInt(tokens[0]);
130 throw new ParseException("mismatch", 0);
133 public static int[] get_values(String line, String label) throws NumberFormatException, ParseException {
134 if (line.startsWith(label)) {
135 String tail = line.substring(label.length()).trim();
136 String[] tokens = tail.split("\\s+");
137 if (tokens.length > 1) {
138 int[] values = new int[2];
139 values[0] = Integer.parseInt(tokens[0]);
140 values[1] = Integer.parseInt(tokens[1]);
144 throw new ParseException("mismatch", 0);
147 public int log_space() {
148 if (log_space != AltosLib.MISSING)
151 if (storage_size != AltosLib.MISSING) {
152 int space = storage_size;
154 if (storage_erase_unit != AltosLib.MISSING && use_flash_for_config())
155 space -= storage_erase_unit;
157 if (space != AltosLib.MISSING)
163 public int log_available() {
164 switch (log_format) {
165 case AltosLib.AO_LOG_FORMAT_TINY:
169 case AltosLib.AO_LOG_FORMAT_TELEMETRY:
170 case AltosLib.AO_LOG_FORMAT_TELESCIENCE:
173 if (flight_log_max <= 0)
175 int log_max = flight_log_max * 1024;
176 int log_space = log_space();
182 log_used = flights.length * log_max;
185 if (log_used >= log_space)
188 log_avail = (log_space - log_used) / log_max;
194 public int invert_accel_value(int value) {
195 if (value == AltosLib.MISSING)
196 return AltosLib.MISSING;
198 switch (log_format) {
199 case AltosLib.AO_LOG_FORMAT_FULL:
200 return 0x7fff - value;
201 case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
202 case AltosLib.AO_LOG_FORMAT_TELEMETRUM:
203 case AltosLib.AO_LOG_FORMAT_TELEMEGA:
204 case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
205 case AltosLib.AO_LOG_FORMAT_TELEMEGA_4:
207 case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
208 case AltosLib.AO_LOG_FORMAT_EASYMOTOR:
211 if (product.startsWith("EasyTimer-"))
213 return AltosLib.MISSING;
217 public boolean has_monitor_battery() {
218 if (product.startsWith("TeleBT"))
223 int[] parse_version(String v) {
224 String[] parts = v.split("\\.");
225 int r[] = new int[parts.length];
227 for (int i = 0; i < parts.length; i++) {
229 r[i] = (int) AltosLib.fromdec(parts[i]);
230 } catch (NumberFormatException n) {
238 public boolean altitude_32() {
239 return altitude_32 == 1;
242 public int compare_version(String other) {
243 int[] me = parse_version(version);
244 int[] them = parse_version(other);
246 int l = Math.min(me.length, them.length);
248 for (int i = 0; i < l; i++) {
249 int d = me[i] - them[i];
260 public void reset() {
263 serial = AltosLib.MISSING;
264 flight = AltosLib.MISSING;
265 log_format = AltosLib.AO_LOG_FORMAT_UNKNOWN;
266 log_space = AltosLib.MISSING;
268 config_major = AltosLib.MISSING;
269 config_minor = AltosLib.MISSING;
271 main_deploy = AltosLib.MISSING;
272 apogee_delay = AltosLib.MISSING;
273 apogee_lockout = AltosLib.MISSING;
275 radio_frequency = AltosLib.MISSING;
277 radio_enable = AltosLib.MISSING;
278 radio_calibration = AltosLib.MISSING;
279 radio_channel = AltosLib.MISSING;
280 radio_setting = AltosLib.MISSING;
281 telemetry_rate = AltosLib.MISSING;
283 accel_cal_plus_cooked = AltosLib.MISSING;
284 accel_cal_minus_cooked = AltosLib.MISSING;
285 accel_cal_plus = AltosLib.MISSING;
286 accel_cal_minus = AltosLib.MISSING;
287 pad_orientation = AltosLib.MISSING;
288 accel_cal_adjusted = false;
290 flight_log_max = AltosLib.MISSING;
291 log_fixed = AltosLib.MISSING;
292 ignite_mode = AltosLib.MISSING;
296 pyro = AltosLib.MISSING;
297 npyro = AltosLib.MISSING;
299 pyro_firing_time = AltosLib.MISSING;
301 aprs_interval = AltosLib.MISSING;
302 aprs_ssid = AltosLib.MISSING;
303 aprs_format = AltosLib.MISSING;
304 aprs_offset = AltosLib.MISSING;
306 beep = AltosLib.MISSING;
308 tracker_motion = AltosLib.MISSING;
309 tracker_interval = AltosLib.MISSING;
311 storage_size = AltosLib.MISSING;
312 storage_erase_unit = AltosLib.MISSING;
316 accel_zero_along = AltosLib.MISSING;
317 accel_zero_across = AltosLib.MISSING;
318 accel_zero_through = AltosLib.MISSING;
321 /* Return + accel calibration relative to a specific pad orientation */
322 public int accel_cal_plus(int pad_orientation) {
324 switch (pad_orientation) {
325 case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP:
326 case AltosLib.AO_PAD_ORIENTATION_WORDS_UPRIGHT:
327 case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_UP:
328 return accel_cal_plus_cooked;
329 case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN:
330 case AltosLib.AO_PAD_ORIENTATION_WORDS_UPSIDEDOWN:
331 case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_DOWN:
332 return invert_accel_value(accel_cal_minus_cooked);
334 return AltosLib.MISSING;
338 /* Return - accel calibration relative to a specific pad orientation */
339 public int accel_cal_minus(int pad_orientation) {
341 switch (pad_orientation) {
342 case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP:
343 case AltosLib.AO_PAD_ORIENTATION_WORDS_UPRIGHT:
344 case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_UP:
345 return accel_cal_minus_cooked;
346 case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN:
347 case AltosLib.AO_PAD_ORIENTATION_WORDS_UPSIDEDOWN:
348 case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_DOWN:
349 return invert_accel_value(accel_cal_plus_cooked);
351 return AltosLib.MISSING;
355 /* Once we have all of the values from the config data, compute the
356 * accel cal values relative to Antenna Up orientation.
358 private void adjust_accel_cal() {
359 if (!accel_cal_adjusted &&
360 pad_orientation != AltosLib.MISSING &&
361 accel_cal_plus != AltosLib.MISSING &&
362 accel_cal_minus != AltosLib.MISSING)
364 switch (pad_orientation) {
365 case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP:
366 case AltosLib.AO_PAD_ORIENTATION_WORDS_UPRIGHT:
367 case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_UP:
368 accel_cal_plus_cooked = accel_cal_plus;
369 accel_cal_minus_cooked = accel_cal_minus;
370 accel_cal_adjusted = true;
372 case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN:
373 case AltosLib.AO_PAD_ORIENTATION_WORDS_UPSIDEDOWN:
374 case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_DOWN:
375 accel_cal_plus_cooked = invert_accel_value(accel_cal_minus);
376 accel_cal_minus_cooked = invert_accel_value(accel_cal_plus);
377 accel_cal_adjusted = true;
385 public void parse_line(String line) {
387 /* Version replies */
388 try { manufacturer = get_string(line, "manufacturer"); } catch (Exception e) {}
389 try { product = get_string(line, "product"); } catch (Exception e) {}
390 try { serial = get_int(line, "serial-number"); } catch (Exception e) {}
391 try { flight = get_int(line, "current-flight"); } catch (Exception e) {}
392 try { log_format = get_int(line, "log-format"); } catch (Exception e) {}
393 try { log_space = get_int(line, "log-space"); } catch (Exception e) {}
394 try { altitude_32 = get_int(line, "altitude-32"); } catch (Exception e) {}
395 try { version = get_string(line, "software-version"); } catch (Exception e) {}
397 /* Version also contains MS5607 info, which we ignore here */
399 try { ms5607().reserved = get_int(line, "ms5607 reserved:"); } catch (Exception e) {}
400 try { ms5607().sens = get_int(line, "ms5607 sens:"); } catch (Exception e) {}
401 try { ms5607().off = get_int(line, "ms5607 off:"); } catch (Exception e) {}
402 try { ms5607().tcs = get_int(line, "ms5607 tcs:"); } catch (Exception e) {}
403 try { ms5607().tco = get_int(line, "ms5607 tco:"); } catch (Exception e) {}
404 try { ms5607().tref = get_int(line, "ms5607 tref:"); } catch (Exception e) {}
405 try { ms5607().tempsens = get_int(line, "ms5607 tempsens:"); } catch (Exception e) {}
406 try { ms5607().crc = get_int(line, "ms5607 crc:"); } catch (Exception e) {}
408 /* Config show replies */
411 if (line.startsWith("Config version")) {
412 String[] bits = line.split("\\s+");
413 if (bits.length >= 3) {
414 String[] cfg = bits[2].split("\\.");
416 if (cfg.length >= 2) {
417 config_major = Integer.parseInt(cfg[0]);
418 config_minor = Integer.parseInt(cfg[1]);
422 } catch (Exception e) {}
425 try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {}
426 try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {}
427 try { apogee_lockout = get_int(line, "Apogee lockout:"); } catch (Exception e) {}
431 radio_frequency = get_int(line, "Frequency:");
432 if (radio_frequency < 0)
433 radio_frequency = 434550;
434 } catch (Exception e) {}
435 try { callsign = get_string(line, "Callsign:"); } catch (Exception e) {}
436 try { radio_enable = get_int(line, "Radio enable:"); } catch (Exception e) {}
437 try { radio_calibration = get_int(line, "Radio cal:"); } catch (Exception e) {}
438 try { telemetry_rate = get_int(line, "Telemetry rate:"); } catch (Exception e) {}
440 /* Old HAS_RADIO values */
441 try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {}
442 try { radio_setting = get_int(line, "Radio setting:"); } catch (Exception e) {}
446 if (line.startsWith("Accel cal")) {
447 String[] bits = line.split("\\s+");
448 if (bits.length >= 6) {
449 accel_cal_plus = Integer.parseInt(bits[3]);
450 accel_cal_minus = Integer.parseInt(bits[5]);
451 accel_cal_adjusted = false;
454 } catch (Exception e) {}
455 try { pad_orientation = get_int(line, "Pad orientation:"); } catch (Exception e) {}
458 try { flight_log_max = get_int(line, "Max flight log:"); } catch (Exception e) {}
459 try { log_fixed = get_int(line, "Log fixed:"); } catch (Exception e) {}
462 try { ignite_mode = get_int(line, "Ignite mode:"); } catch (Exception e) {}
465 try { aes_key = get_string(line, "AES key:"); } catch (Exception e) {}
469 npyro = get_int(line, "Pyro-count:");
470 pyros = new AltosPyro[npyro];
472 } catch (Exception e) {}
473 if (npyro != AltosLib.MISSING) {
475 AltosPyro p = new AltosPyro(pyro, line);
478 } catch (Exception e) {}
480 try { pyro_firing_time = get_int(line, "Pyro time:") / 100.0; } catch (Exception e) {}
483 try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {}
484 try { aprs_ssid = get_int(line, "APRS SSID:"); } catch (Exception e) {}
485 try { aprs_format = get_int(line, "APRS format:"); } catch (Exception e) {}
486 try { aprs_offset = get_int(line, "APRS offset:"); } catch (Exception e) {}
489 try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {}
493 int[] values = get_values(line, "Tracker setting:");
494 tracker_motion = values[0];
495 tracker_interval = values[1];
496 } catch (Exception e) {}
498 /* Storage info replies */
499 try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {}
500 try { storage_erase_unit = get_int(line, "Storage erase unit:"); } catch (Exception e) {}
502 /* Log listing replies */
504 int flight = get_int(line, "flight");
505 String[] tokens = line.split("\\s+");
506 if (tokens.length >= 6) {
507 int start = -1, end = -1;
509 if (tokens[2].equals("start"))
510 start = AltosParse.parse_hex(tokens[3]);
511 if (tokens[4].equals("end"))
512 end = AltosParse.parse_hex(tokens[5]);
513 if (flight != 0 && start >= 0 && end > 0) {
518 len = flights.length;
519 AltosEepromFlight [] new_flights = new AltosEepromFlight[len + 1];
520 for (int i = 0; i < len; i++)
521 new_flights[i] = flights[i];
522 new_flights[len] = new AltosEepromFlight(flight, start, end);
523 flights = new_flights;
524 stored_flight = flights.length;
526 } catch (ParseException pe) { System.out.printf("Parse error %s\n", pe.toString()); }
528 } catch (Exception e) {}
532 if (line.startsWith("IMU cal along")) {
533 String[] bits = line.split("\\s+");
534 if (bits.length >= 8) {
535 accel_zero_along = Integer.parseInt(bits[3]);
536 accel_zero_across = Integer.parseInt(bits[5]);
537 accel_zero_through = Integer.parseInt(bits[7]);
540 } catch (Exception e) {}
542 /* Fix accel cal as soon as all of the necessary values appear */
546 public AltosConfigData() {
550 private void read_link(AltosLink link, String finished) throws InterruptedException, TimeoutException {
552 String line = link.get_reply();
554 throw new TimeoutException();
555 if (line.contains("Syntax error"))
557 this.parse_line(line);
559 /* signals the end of the version info */
560 if (line.startsWith(finished))
565 public boolean has_frequency() {
566 return radio_frequency != AltosLib.MISSING || radio_setting != AltosLib.MISSING || radio_channel != AltosLib.MISSING;
569 public boolean has_telemetry_rate() {
570 return telemetry_rate != AltosLib.MISSING;
573 public void set_frequency(double freq) {
574 int frequency = radio_frequency;
575 int setting = radio_setting;
577 if (frequency != AltosLib.MISSING) {
578 radio_frequency = (int) Math.floor (freq * 1000 + 0.5);
579 radio_channel = AltosLib.MISSING;
580 } else if (setting != AltosLib.MISSING) {
581 radio_setting =AltosConvert.radio_frequency_to_setting(freq, radio_calibration);
582 radio_channel = AltosLib.MISSING;
584 radio_channel = AltosConvert.radio_frequency_to_channel(freq);
588 public double frequency() {
589 int channel = radio_channel;
590 int setting = radio_setting;
592 if (radio_frequency == AltosLib.MISSING && channel == AltosLib.MISSING && setting == AltosLib.MISSING)
593 return AltosLib.MISSING;
595 if (channel == AltosLib.MISSING)
597 if (setting == AltosLib.MISSING)
600 return AltosConvert.radio_to_frequency(radio_frequency,
606 boolean use_flash_for_config() {
607 if (product.startsWith("TeleMega"))
609 if (product.startsWith("TeleMetrum-v2"))
611 if (product.startsWith("TeleMetrum-v3"))
613 if (product.startsWith("EasyMega"))
619 public boolean mma655x_inverted() throws AltosUnknownProduct {
620 if (product != null) {
621 if (product.startsWith("EasyMega-v1"))
623 if (product.startsWith("TeleMetrum-v2"))
625 if (product.startsWith("TeleMega-v2"))
627 if (product.startsWith("TeleMega-v1"))
630 throw new AltosUnknownProduct(product);
633 public boolean adxl375_inverted() throws AltosUnknownProduct {
634 if (product != null) {
635 if (product.startsWith("EasyMega-v2"))
637 if (product.startsWith("TeleMetrum-v3"))
639 if (product.startsWith("TeleMega-v4"))
641 if (product.startsWith("EasyMotor-v2"))
644 throw new AltosUnknownProduct(product);
647 public int adxl375_axis() throws AltosUnknownProduct {
648 if (product != null) {
649 if (product.startsWith("EasyMega-v2"))
650 return AltosAdxl375.X_AXIS;
651 if (product.startsWith("TeleMetrum-v3"))
652 return AltosAdxl375.X_AXIS;
653 if (product.startsWith("TeleMega-v4"))
654 return AltosAdxl375.X_AXIS;
655 if (product.startsWith("EasyMotor-v2"))
656 return AltosAdxl375.X_AXIS;
659 throw new AltosUnknownProduct(product);
662 public void get_values(AltosConfigValues source) throws AltosConfigDataException {
665 if (main_deploy != AltosLib.MISSING)
666 main_deploy = source.main_deploy();
667 if (apogee_delay != AltosLib.MISSING)
668 apogee_delay = source.apogee_delay();
669 if (apogee_lockout != AltosLib.MISSING)
670 apogee_lockout = source.apogee_lockout();
674 set_frequency(source.radio_frequency());
675 if (radio_enable != AltosLib.MISSING)
676 radio_enable = source.radio_enable();
677 if (callsign != null)
678 callsign = source.callsign();
679 if (telemetry_rate != AltosLib.MISSING)
680 telemetry_rate = source.telemetry_rate();
683 if (pad_orientation != AltosLib.MISSING)
684 pad_orientation = source.pad_orientation();
686 if (accel_cal_plus_cooked != AltosLib.MISSING)
687 accel_cal_plus_cooked = source.accel_cal_plus();
689 if (accel_cal_minus_cooked != AltosLib.MISSING)
690 accel_cal_minus_cooked = source.accel_cal_minus();
693 if (flight_log_max != AltosLib.MISSING)
694 flight_log_max = source.flight_log_max();
697 if (ignite_mode != AltosLib.MISSING)
698 ignite_mode = source.ignite_mode();
701 if (npyro != AltosLib.MISSING)
702 pyros = source.pyros();
703 if (pyro_firing_time != AltosLib.MISSING)
704 pyro_firing_time = source.pyro_firing_time();
707 if (aprs_interval != AltosLib.MISSING)
708 aprs_interval = source.aprs_interval();
709 if (aprs_ssid != AltosLib.MISSING)
710 aprs_ssid = source.aprs_ssid();
711 if (aprs_format != AltosLib.MISSING)
712 aprs_format = source.aprs_format();
713 if (aprs_offset != AltosLib.MISSING)
714 aprs_offset = source.aprs_offset();
717 if (beep != AltosLib.MISSING)
718 beep = source.beep();
720 if (tracker_motion != AltosLib.MISSING)
721 tracker_motion = source.tracker_motion();
722 if (tracker_interval != AltosLib.MISSING)
723 tracker_interval = source.tracker_interval();
726 public void set_values(AltosConfigValues dest) {
727 dest.set_serial(serial);
728 dest.set_product(product);
729 dest.set_version(version);
730 dest.set_altitude_32(altitude_32);
731 dest.set_main_deploy(main_deploy);
732 dest.set_apogee_delay(apogee_delay);
733 dest.set_apogee_lockout(apogee_lockout);
734 dest.set_radio_calibration(radio_calibration);
735 dest.set_radio_frequency(frequency());
736 dest.set_telemetry_rate(telemetry_rate);
737 boolean max_enabled = true;
739 if (log_space() == 0)
742 if (log_fixed != AltosLib.MISSING)
745 switch (log_format) {
746 case AltosLib.AO_LOG_FORMAT_TINY:
755 dest.set_flight_log_max_enabled(max_enabled);
756 dest.set_radio_enable(radio_enable);
757 dest.set_flight_log_max_limit(log_space() >> 10, storage_erase_unit >> 10);
758 dest.set_flight_log_max(flight_log_max);
759 dest.set_ignite_mode(ignite_mode);
760 dest.set_pad_orientation(pad_orientation);
761 dest.set_accel_cal(accel_cal_plus(AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP),
762 accel_cal_minus(AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP));
763 dest.set_callsign(callsign);
764 if (npyro != AltosLib.MISSING)
765 dest.set_pyros(pyros);
767 dest.set_pyros(null);
768 dest.set_pyro_firing_time(pyro_firing_time);
769 dest.set_aprs_interval(aprs_interval);
770 dest.set_aprs_ssid(aprs_ssid);
771 dest.set_aprs_format(aprs_format);
772 dest.set_aprs_offset(aprs_offset);
774 dest.set_tracker_motion(tracker_motion);
775 dest.set_tracker_interval(tracker_interval);
778 public boolean log_has_state() {
779 switch (log_format) {
780 case AltosLib.AO_LOG_FORMAT_TELEGPS:
786 public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException {
789 if (main_deploy != AltosLib.MISSING)
790 link.printf("c m %d\n", main_deploy);
791 if (apogee_delay != AltosLib.MISSING)
792 link.printf("c d %d\n", apogee_delay);
793 if (apogee_lockout != AltosLib.MISSING)
794 link.printf("c L %d\n", apogee_lockout);
797 if (has_frequency()) {
798 boolean has_frequency = radio_frequency != AltosLib.MISSING;
799 boolean has_setting = radio_setting != AltosLib.MISSING;
800 double frequency = frequency();
801 link.set_radio_frequency(frequency,
805 /* When remote, reset the dongle frequency at the same time */
806 if (remote && frequency != link.frequency) {
808 link.set_radio_frequency(frequency);
813 if (telemetry_rate != AltosLib.MISSING) {
814 link.printf("c T %d\n", telemetry_rate);
815 if (remote && telemetry_rate != link.telemetry_rate) {
817 link.set_telemetry_rate(telemetry_rate);
822 if (callsign != null) {
823 link.printf("c c %s\n", callsign);
824 if (remote && !callsign.equals(link.callsign)) {
825 System.out.printf("changing link callsign from %s to %s\n", link.callsign, callsign);
827 link.set_callsign(callsign);
832 if (radio_enable != AltosLib.MISSING)
833 link.printf("c e %d\n", radio_enable);
836 /* set orientation first so that we know how to set the accel cal */
837 if (pad_orientation != AltosLib.MISSING)
838 link.printf("c o %d\n", pad_orientation);
839 int plus = accel_cal_plus(pad_orientation);
840 int minus = accel_cal_minus(pad_orientation);
841 if (plus != AltosLib.MISSING && minus != AltosLib.MISSING) {
845 minus = 65536 + minus;
846 if (accel_zero_along != AltosLib.MISSING &&
847 accel_zero_across != AltosLib.MISSING &&
848 accel_zero_through != AltosLib.MISSING)
849 link.printf("c a %d %d %d %d %d\n",
855 link.printf("c a %d %d\n", plus, minus);
859 if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
860 link.printf("c l %d\n", flight_log_max);
863 if (ignite_mode != AltosLib.MISSING)
864 link.printf("c i %d\n", ignite_mode);
867 /* UI doesn't support AES key config */
870 if (npyro != AltosLib.MISSING) {
871 for (int p = 0; p < pyros.length; p++) {
872 link.printf("c P %s\n",
873 pyros[p].toString());
876 if (pyro_firing_time != AltosLib.MISSING)
877 link.printf("c I %d\n", (int) (pyro_firing_time * 100.0 + 0.5));
880 if (aprs_interval != AltosLib.MISSING)
881 link.printf("c A %d\n", aprs_interval);
882 if (aprs_ssid != AltosLib.MISSING)
883 link.printf("c S %d\n", aprs_ssid);
884 if (aprs_format != AltosLib.MISSING)
885 link.printf("c C %d\n", aprs_format);
886 if (aprs_offset != AltosLib.MISSING)
887 link.printf("c O %d\n", aprs_offset);
890 if (beep != AltosLib.MISSING)
891 link.printf("c b %d\n", beep);
894 if (tracker_motion != AltosLib.MISSING && tracker_interval != AltosLib.MISSING)
895 link.printf("c t %d %d\n", tracker_motion, tracker_interval);
898 /* UI doesn't support accel cal */
900 link.printf("c w\n");
901 read_link(link, "Saved");
904 public AltosConfigData(AltosLink link) throws InterruptedException, TimeoutException {
906 link.printf("c s\nf\nv\n");
907 read_link(link, "software-version");
908 switch (log_format) {
909 case AltosLib.AO_LOG_FORMAT_UNKNOWN:
910 case AltosLib.AO_LOG_FORMAT_NONE:
914 read_link(link, "done");