- void get_data() throws InterruptedException, TimeoutException {
- try {
- start_serial();
- serial_line.printf("c s\nv\n");
- for (;;) {
- String line = serial_line.get_reply(5000);
- if (line == null)
- throw new TimeoutException();
- get_int(line, "serial-number", serial);
- get_int(line, "Main deploy:", main_deploy);
- get_int(line, "Apogee delay:", apogee_delay);
- get_int(line, "Radio channel:", radio_channel);
- get_int(line, "Radio cal:", radio_calibration);
- get_string(line, "Callsign:", callsign);
- get_string(line,"software-version", version);
- get_string(line,"product", product);
-
- /* signals the end of the version info */
- if (line.startsWith("software-version"))
- break;
+ void get_data() {
+ data = null;
+ try {
+ start_serial();
+ data = new AltosConfigData(config.serial_line);
+ } catch (InterruptedException ie) {
+ } catch (TimeoutException te) {
+ try {
+ stop_serial();
+ callback("abort");
+ } catch (InterruptedException ie) {
+ }
+ } finally {
+ try {
+ stop_serial();
+ } catch (InterruptedException ie) {
+ }
+ }
+ callback("all finished");
+ }
+
+ void save_data() {
+ try {
+ double frequency = frequency();
+ boolean has_frequency = data.radio_frequency > 0;
+ boolean has_setting = data.radio_setting > 0;
+ start_serial();
+ serial_line.printf("c m %d\n", data.main_deploy);
+ serial_line.printf("c d %d\n", data.apogee_delay);
+ serial_line.printf("c L %d\n", data.apogee_lockout);
+ if (!remote)
+ serial_line.printf("c f %d\n", data.radio_calibration);
+ serial_line.set_radio_frequency(frequency,
+ has_frequency,
+ has_setting,
+ data.radio_calibration);
+ if (remote) {
+ serial_line.stop_remote();
+ serial_line.set_radio_frequency(frequency);
+ AltosUIPreferences.set_frequency(device.getSerial(), frequency);
+ serial_line.start_remote();
+ }
+ serial_line.printf("c c %s\n", data.callsign);
+ if (data.flight_log_max != 0)
+ serial_line.printf("c l %d\n", data.flight_log_max);
+ if (data.radio_enable >= 0)
+ serial_line.printf("c e %d\n", data.radio_enable);
+ if (data.ignite_mode >= 0)
+ serial_line.printf("c i %d\n", data.ignite_mode);
+ if (data.pad_orientation >= 0)
+ serial_line.printf("c o %d\n", data.pad_orientation);
+ if (data.pyros.length > 0) {
+ for (int p = 0; p < data.pyros.length; p++) {
+ serial_line.printf("c P %s\n",
+ data.pyros[p].toString());
+ }
+ }
+ serial_line.printf("c w\n");
+ } catch (InterruptedException ie) {
+ } catch (TimeoutException te) {
+ } finally {
+ try {
+ stop_serial();
+ } catch (InterruptedException ie) {
+ }