From 4f64d66295a8f76680af8cfda4650aa4c4f8576d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 14 Aug 2011 19:19:50 -0700 Subject: altos: Lost change that reported flight 0 when log memory was full commit 52ac83fedbfd380d14d4df2e79992bbdfba3552a added coded to check for a full flight log and complain with a special tone. It also reported flight 0 over telemetry, and that part of the patch got lost when moving to the new telemetry format. This patch resurrects that piece. Signed-off-by: Keith Packard --- src/ao_telemetry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ao_telemetry.c b/src/ao_telemetry.c index 15ba4302..8a18ba07 100644 --- a/src/ao_telemetry.c +++ b/src/ao_telemetry.c @@ -101,7 +101,7 @@ ao_send_configuration(void) { telemetry.generic.type = AO_TELEMETRY_CONFIGURATION; telemetry.configuration.device = AO_idProduct_NUMBER; - telemetry.configuration.flight = ao_flight_number; + telemetry.configuration.flight = ao_log_full() ? 0 : ao_flight_number; telemetry.configuration.config_major = AO_CONFIG_MAJOR; telemetry.configuration.config_minor = AO_CONFIG_MINOR; telemetry.configuration.apogee_delay = ao_config.apogee_delay; -- cgit v1.2.3 From adb7d345963ab9981c49c7cc68c6b4d7156dce46 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 14 Aug 2011 21:09:42 -0700 Subject: altosui: Ancient log files used 'apogee' for 'coast' state 2009-07-18-serial-004-flight-000 says 'apogee' for the apogee-detect phase of the flight; map this to coast so that this flight replays correctly (although the log terminates at apogee...) Signed-off-by: Keith Packard --- altosui/Altos.java | 1 + 1 file changed, 1 insertion(+) diff --git a/altosui/Altos.java b/altosui/Altos.java index 416d9328..d3f8fa67 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -112,6 +112,7 @@ public class Altos { string_to_state.put("fast", ao_flight_fast); string_to_state.put("coast", ao_flight_coast); string_to_state.put("drogue", ao_flight_drogue); + string_to_state.put("apogee", ao_flight_coast); string_to_state.put("main", ao_flight_main); string_to_state.put("landed", ao_flight_landed); string_to_state.put("invalid", ao_flight_invalid); -- cgit v1.2.3 From 048b3eb45169e572f33c68ff152b89db9ef97d31 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 14 Aug 2011 21:11:41 -0700 Subject: altosui: Add 'On-board Data Logging' indicator to pad tab This shows whether the on-board data memory is full, or is ready to record the flight. This is indicated in the telemetry stream by a flight number of '0'. Signed-off-by: Keith Packard --- altosui/AltosPad.java | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index d08925be..2ed1ab2c 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -173,6 +173,29 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { Main main; + class LoggingReady extends LaunchStatus { + void show (AltosState state, int crc_errors) { + show(); + System.out.printf("flight %d state %d\n", state.data.flight, state.data.state); + if (state.data.flight != 0) { + if (state.data.state <= Altos.ao_flight_pad) + value.setText("Ready to record"); + else if (state.data.state < Altos.ao_flight_landed) + value.setText("Recording data"); + else + value.setText("Recorded data"); + } + else + value.setText("Storage full"); + lights.set(state.data.flight != 0); + } + public LoggingReady (GridBagLayout layout, int y) { + super(layout, y, "On-board Data Logging"); + } + } + + LoggingReady logging_ready; + class GPSLocked extends LaunchStatus { void show (AltosState state, int crc_errors) { show(); @@ -252,6 +275,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { battery.reset(); apogee.reset(); main.reset(); + logging_ready.reset(); gps_locked.reset(); gps_ready.reset(); pad_lat.reset(); @@ -269,6 +293,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { main.hide(); else main.show(state, crc_errors); + logging_ready.show(state, crc_errors); pad_alt.show(state, crc_errors); if (state.gps != null && state.gps.connected) { gps_locked.show(state, crc_errors); @@ -301,10 +326,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { battery = new Battery(layout, 0); apogee = new Apogee(layout, 1); main = new Main(layout, 2); - gps_locked = new GPSLocked(layout, 3); - gps_ready = new GPSReady(layout, 4); - pad_lat = new PadLat(layout, 5); - pad_lon = new PadLon(layout, 6); - pad_alt = new PadAlt(layout, 7); + logging_ready = new LoggingReady(layout, 3); + gps_locked = new GPSLocked(layout, 4); + gps_ready = new GPSReady(layout, 5); + pad_lat = new PadLat(layout, 6); + pad_lon = new PadLon(layout, 7); + pad_alt = new PadAlt(layout, 8); } } -- cgit v1.2.3 From fcff63baf8fde1174571a2c7c860099e19dbf629 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 20 Aug 2011 10:43:28 -0700 Subject: altosui: remove debug printf in pad pane Signed-off-by: Keith Packard --- altosui/AltosPad.java | 1 - 1 file changed, 1 deletion(-) diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 2ed1ab2c..3a8d04fe 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -176,7 +176,6 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { class LoggingReady extends LaunchStatus { void show (AltosState state, int crc_errors) { show(); - System.out.printf("flight %d state %d\n", state.data.flight, state.data.state); if (state.data.flight != 0) { if (state.data.state <= Altos.ao_flight_pad) value.setText("Ready to record"); -- cgit v1.2.3 From 67f28c58db0deca8f8050d33e97ad96017f4baaa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 20 Aug 2011 11:19:57 -0700 Subject: altosui: Disable 'max flight log' config when there are stored flights When flights are stored in flash, the maximum flight log value cannot be changed as the flight data might need to be moved around in memory. Check for this case by looking for stored flights and disabling the combo box when storage is not empty. Signed-off-by: Keith Packard --- altosui/AltosConfig.java | 7 ++++++- altosui/AltosConfigUI.java | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 9a44c1c5..84c8a4a3 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -78,6 +78,7 @@ public class AltosConfig implements ActionListener { int_ref radio_setting; int_ref storage_size; int_ref storage_erase_unit; + int_ref stored_flight; string_ref version; string_ref product; string_ref callsign; @@ -146,6 +147,7 @@ public class AltosConfig implements ActionListener { config_ui.set_apogee_delay(apogee_delay.get()); config_ui.set_radio_calibration(radio_calibration.get()); config_ui.set_radio_frequency(frequency()); + config_ui.set_flight_log_max_enabled(stored_flight.get() < 0); config_ui.set_flight_log_max_limit(log_limit()); config_ui.set_flight_log_max(flight_log_max.get()); config_ui.set_ignite_mode(ignite_mode.get()); @@ -177,6 +179,7 @@ public class AltosConfig implements ActionListener { get_int(line, "Radio setting:", radio_setting); get_int(line, "Storage size:", storage_size); get_int(line, "Storage erase unit:", storage_erase_unit); + get_int(line, "flight", stored_flight); get_string(line, "Callsign:", callsign); get_string(line,"software-version", version); get_string(line,"product", product); @@ -206,7 +209,8 @@ public class AltosConfig implements ActionListener { void get_data() { try { config.start_serial(); - config.serial_line.printf("c s\nf\nv\n"); + stored_flight.set(-1); + config.serial_line.printf("c s\nf\nl\nv\n"); for (;;) { try { String line = config.serial_line.get_reply(5000); @@ -413,6 +417,7 @@ public class AltosConfig implements ActionListener { pad_orientation = new int_ref(-1); storage_size = new int_ref(-1); storage_erase_unit = new int_ref(-1); + stored_flight = new int_ref(-1); callsign = new string_ref("N0CALL"); version = new string_ref("unknown"); product = new string_ref("unknown"); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 63e0ba78..69afd691 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -573,6 +573,10 @@ public class AltosConfigUI flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max)); } + public void set_flight_log_max_enabled(boolean enable) { + flight_log_max_value.setEnabled(enable); + } + public int flight_log_max() { return Integer.parseInt(flight_log_max_value.getSelectedItem().toString()); } -- cgit v1.2.3 From f2b0900f8b83fcb3085f3d042ffd961ffd758d5d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 20 Aug 2011 11:28:53 -0700 Subject: altos: Merge common config code in ao_config.c This shuffles code around in ao_config.c to share some common code segments for starting and committing config changes. This also stops printing out changes as they are made which aren't needed by the UI code. Signed-off-by: Keith Packard --- src/ao_config.c | 104 +++++++++++++++++++++++--------------------------------- 1 file changed, 42 insertions(+), 62 deletions(-) diff --git a/src/ao_config.c b/src/ao_config.c index 331509e2..e0eae78e 100644 --- a/src/ao_config.c +++ b/src/ao_config.c @@ -105,11 +105,24 @@ _ao_config_get(void) ao_config_loaded = 1; } -void -ao_config_get(void) +static void +_ao_config_edit_start(void) { ao_mutex_get(&ao_config_mutex); _ao_config_get(); +} + +static void +_ao_config_edit_finish(void) +{ + ao_config_dirty = 1; + ao_mutex_put(&ao_config_mutex); +} + +void +ao_config_get(void) +{ + _ao_config_edit_start(); ao_mutex_put(&ao_config_mutex); } @@ -137,13 +150,10 @@ ao_config_callsign_set(void) __reentrant } if (ao_cmd_status != ao_cmd_success) return; - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); memcpy(&ao_config.callsign, &callsign, AO_MAX_CALLSIGN + 1); - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_callsign_show(); + _ao_config_edit_finish(); } void @@ -159,12 +169,9 @@ ao_config_radio_channel_set(void) __reentrant ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_config.radio_channel = ao_cmd_lex_i; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_radio_channel_show(); + _ao_config_edit_finish(); ao_radio_recv_abort(); } @@ -183,12 +190,9 @@ ao_config_main_deploy_set(void) __reentrant ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_config.main_deploy = ao_cmd_lex_i; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_main_deploy_show(); + _ao_config_edit_finish(); } #if HAS_ACCEL @@ -250,13 +254,10 @@ ao_config_accel_calibrate_set(void) __reentrant up, down); return; } - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_config.accel_plus_g = up; ao_config.accel_minus_g = down; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_accel_calibrate_show(); + _ao_config_edit_finish(); } #endif /* HAS_ACCEL */ @@ -273,12 +274,9 @@ ao_config_apogee_delay_set(void) __reentrant ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_config.apogee_delay = ao_cmd_lex_i; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_apogee_delay_show(); + _ao_config_edit_finish(); } #endif /* HAS_ADC */ @@ -295,12 +293,9 @@ ao_config_radio_cal_set(void) __reentrant ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_config.radio_setting = ao_config.radio_cal = ao_cmd_lex_u32; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_radio_cal_show(); + _ao_config_edit_finish(); } #if HAS_EEPROM @@ -326,12 +321,9 @@ ao_config_log_set(void) __reentrant else if (ao_cmd_lex_i > config) printf("Flight log max %d kB\n", config); else { - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_config.flight_log_max = (uint32_t) ao_cmd_lex_i << 10; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_log_show(); + _ao_config_edit_finish(); } } #endif /* HAS_EEPROM */ @@ -349,12 +341,9 @@ ao_config_ignite_mode_set(void) __reentrant ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_config.ignite_mode = ao_cmd_lex_i; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_ignite_mode_show(); + _ao_config_edit_finish(); } #endif @@ -371,8 +360,7 @@ ao_config_pad_orientation_set(void) __reentrant ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_cmd_lex_i &= 1; if (ao_config.pad_orientation != ao_cmd_lex_i) { uint16_t t; @@ -381,9 +369,7 @@ ao_config_pad_orientation_set(void) __reentrant ao_config.accel_minus_g = 0x7fff - t; } ao_config.pad_orientation = ao_cmd_lex_i; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_pad_orientation_show(); + _ao_config_edit_finish(); } #endif @@ -399,13 +385,10 @@ ao_config_radio_setting_set(void) __reentrant ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - ao_mutex_get(&ao_config_mutex); - _ao_config_get(); + _ao_config_edit_start(); ao_config.radio_setting = ao_cmd_lex_u32; ao_config.radio_channel = 0; - ao_config_dirty = 1; - ao_mutex_put(&ao_config_mutex); - ao_config_radio_setting_show(); + _ao_config_edit_finish(); ao_radio_recv_abort(); } @@ -456,13 +439,13 @@ __code struct ao_config_var ao_config_vars[] = { { "R \0Radio freq control (freq = 434.550 * setting/cal)", ao_config_radio_setting_set, ao_config_radio_setting_show }, { "s\0Show", - ao_config_show, ao_config_show }, + ao_config_show, 0 }, #if HAS_EEPROM { "w\0Write to eeprom", - ao_config_write, ao_config_write }, + ao_config_write, 0 }, #endif { "?\0Help", - ao_config_help, ao_config_help }, + ao_config_help, 0 }, { 0, 0, 0 } }; @@ -479,13 +462,10 @@ ao_config_set(void) func = 0; for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++) if (ao_config_vars[cmd].str[0] == c) { - func = ao_config_vars[cmd].set; - break; + (*ao_config_vars[cmd].set)(); + return; } - if (func) - (*func)(); - else - ao_cmd_status = ao_cmd_syntax_error; + ao_cmd_status = ao_cmd_syntax_error; } static void @@ -505,7 +485,7 @@ ao_config_show(void) __reentrant printf("Config version: %d.%d\n", ao_config.major, ao_config.minor); for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++) - if (ao_config_vars[cmd].show != ao_config_vars[cmd].set) + if (ao_config_vars[cmd].show) (*ao_config_vars[cmd].show)(); } -- cgit v1.2.3 From a08e7ac8bd3840b699c9a1ffc6b1e115b2b84bad Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 20 Aug 2011 11:35:55 -0700 Subject: Bump version to 0.9.7 Bdale is flying 0.9.6 at chili blaster, make sure later firmware gets a later version number. Signed-off-by: Keith Packard --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2bd3120a..93f53115 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([altos], 0.9.6.0) +AC_INIT([altos], 0.9.7.0) AC_CONFIG_SRCDIR([src/ao.h]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 6823ad5e48fc0a19791d96f886b5689f88c4311b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 18 Aug 2011 18:02:02 -0700 Subject: altos/altosui: Add ability to disable telemetry/rdf completely This turns off the telemetry system so that it never transmits telemetry or RDF tones. In idle mode, it will still accept packet mode connections. Signed-off-by: Keith Packard --- altosui/AltosConfig.java | 8 ++++++ altosui/AltosConfigUI.java | 65 +++++++++++++++++++++++++++++++++++++--------- src/ao.h | 3 ++- src/ao_config.c | 25 ++++++++++++++++-- src/ao_telemetry.c | 2 ++ 5 files changed, 88 insertions(+), 15 deletions(-) diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 84c8a4a3..b1e6bc12 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -79,6 +79,7 @@ public class AltosConfig implements ActionListener { int_ref storage_size; int_ref storage_erase_unit; int_ref stored_flight; + int_ref radio_enable; string_ref version; string_ref product; string_ref callsign; @@ -148,6 +149,7 @@ public class AltosConfig implements ActionListener { config_ui.set_radio_calibration(radio_calibration.get()); config_ui.set_radio_frequency(frequency()); config_ui.set_flight_log_max_enabled(stored_flight.get() < 0); + config_ui.set_radio_enable(radio_enable.get()); config_ui.set_flight_log_max_limit(log_limit()); config_ui.set_flight_log_max(flight_log_max.get()); config_ui.set_ignite_mode(ignite_mode.get()); @@ -177,6 +179,7 @@ public class AltosConfig implements ActionListener { get_int(line, "Ignite mode:", ignite_mode); get_int(line, "Pad orientation:", pad_orientation); get_int(line, "Radio setting:", radio_setting); + get_int(line, "Radio enable:", radio_enable); get_int(line, "Storage size:", storage_size); get_int(line, "Storage erase unit:", storage_erase_unit); get_int(line, "flight", stored_flight); @@ -255,6 +258,8 @@ public class AltosConfig implements ActionListener { serial_line.printf("c c %s\n", callsign.get()); if (flight_log_max.get() != 0) serial_line.printf("c l %d\n", flight_log_max.get()); + if (radio_enable.get() >= 0) + serial_line.printf("c e %d\n", radio_enable.get()); if (ignite_mode.get() >= 0) serial_line.printf("c i %d\n", ignite_mode.get()); if (pad_orientation.get() >= 0) @@ -373,6 +378,8 @@ public class AltosConfig implements ActionListener { radio_calibration.set(config_ui.radio_calibration()); set_frequency(config_ui.radio_frequency()); flight_log_max.set(config_ui.flight_log_max()); + if (radio_enable.get() >= 0) + radio_enable.set(config_ui.radio_enable()); if (ignite_mode.get() >= 0) ignite_mode.set(config_ui.ignite_mode()); if (pad_orientation.get() >= 0) @@ -412,6 +419,7 @@ public class AltosConfig implements ActionListener { radio_channel = new int_ref(0); radio_setting = new int_ref(0); radio_calibration = new int_ref(1186611); + radio_enable = new int_ref(-1); flight_log_max = new int_ref(0); ignite_mode = new int_ref(-1); pad_orientation = new int_ref(-1); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 69afd691..bb9e1cd2 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -46,6 +46,7 @@ public class AltosConfigUI JLabel frequency_label; JLabel radio_calibration_label; JLabel radio_frequency_label; + JLabel radio_enable_label; JLabel flight_log_max_label; JLabel ignite_mode_label; JLabel pad_orientation_label; @@ -61,6 +62,7 @@ public class AltosConfigUI JComboBox apogee_delay_value; AltosFreqList radio_frequency_value; JTextField radio_calibration_value; + JRadioButton radio_enable_value; JComboBox flight_log_max_value; JComboBox ignite_mode_value; JComboBox pad_orientation_value; @@ -287,7 +289,7 @@ public class AltosConfigUI radio_calibration_value.setEnabled(false); pane.add(radio_calibration_value, c); - /* Callsign */ + /* Radio Enable */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 7; c.gridwidth = 4; @@ -295,11 +297,34 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; + radio_enable_label = new JLabel("Telemetry/RDF Enable:"); + pane.add(radio_enable_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = 7; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + radio_enable_value = new JRadioButton("Enabled"); + radio_enable_value.addItemListener(this); + pane.add(radio_enable_value, c); + + /* Callsign */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = 8; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; callsign_label = new JLabel("Callsign:"); pane.add(callsign_label, c); c = new GridBagConstraints(); - c.gridx = 4; c.gridy = 7; + c.gridx = 4; c.gridy = 8; c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; @@ -312,7 +337,7 @@ public class AltosConfigUI /* Flight log max */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 8; + c.gridx = 0; c.gridy = 9; c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; @@ -322,7 +347,7 @@ public class AltosConfigUI pane.add(flight_log_max_label, c); c = new GridBagConstraints(); - c.gridx = 4; c.gridy = 8; + c.gridx = 4; c.gridy = 9; c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; @@ -336,7 +361,7 @@ public class AltosConfigUI /* Ignite mode */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 9; + c.gridx = 0; c.gridy = 10; c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; @@ -346,7 +371,7 @@ public class AltosConfigUI pane.add(ignite_mode_label, c); c = new GridBagConstraints(); - c.gridx = 4; c.gridy = 9; + c.gridx = 4; c.gridy = 10; c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; @@ -360,7 +385,7 @@ public class AltosConfigUI /* Pad orientation */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 10; + c.gridx = 0; c.gridy = 11; c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; @@ -370,7 +395,7 @@ public class AltosConfigUI pane.add(pad_orientation_label, c); c = new GridBagConstraints(); - c.gridx = 4; c.gridy = 10; + c.gridx = 4; c.gridy = 11; c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; @@ -384,7 +409,7 @@ public class AltosConfigUI /* Buttons */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 11; + c.gridx = 0; c.gridy = 12; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; @@ -395,7 +420,7 @@ public class AltosConfigUI save.setActionCommand("Save"); c = new GridBagConstraints(); - c.gridx = 2; c.gridy = 11; + c.gridx = 2; c.gridy = 12; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; @@ -406,7 +431,7 @@ public class AltosConfigUI reset.setActionCommand("Reset"); c = new GridBagConstraints(); - c.gridx = 4; c.gridy = 11; + c.gridx = 4; c.gridy = 12; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; @@ -417,7 +442,7 @@ public class AltosConfigUI reboot.setActionCommand("Reboot"); c = new GridBagConstraints(); - c.gridx = 6; c.gridy = 11; + c.gridx = 6; c.gridy = 12; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_END; @@ -559,6 +584,22 @@ public class AltosConfigUI return Integer.parseInt(radio_calibration_value.getText()); } + public void set_radio_enable(int new_radio_enable) { + if (new_radio_enable >= 0) + radio_enable_value.setSelected(new_radio_enable > 0); + else { + radio_enable_value.setSelected(true); + radio_enable_value.setEnabled(false); + } + } + + public int radio_enable() { + if (radio_enable_value.isEnabled()) + return radio_enable_value.isSelected() ? 1 : 0; + else + return -1; + } + public void set_callsign(String new_callsign) { callsign_value.setText(new_callsign); } diff --git a/src/ao.h b/src/ao.h index 79452862..8ac9ac3d 100644 --- a/src/ao.h +++ b/src/ao.h @@ -1415,7 +1415,7 @@ ao_igniter_init(void); */ #define AO_CONFIG_MAJOR 1 -#define AO_CONFIG_MINOR 7 +#define AO_CONFIG_MINOR 8 struct ao_config { uint8_t major; @@ -1431,6 +1431,7 @@ struct ao_config { uint8_t ignite_mode; /* minor version 5 */ uint8_t pad_orientation; /* minor version 6 */ uint32_t radio_setting; /* minor version 7 */ + uint8_t radio_enable; /* minor version 8 */ }; #define AO_IGNITE_MODE_DUAL 0 diff --git a/src/ao_config.c b/src/ao_config.c index e0eae78e..eb1eea3f 100644 --- a/src/ao_config.c +++ b/src/ao_config.c @@ -99,6 +99,8 @@ _ao_config_get(void) ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION; if (ao_config.minor < 7) ao_config.radio_setting = ao_config.radio_cal; + if (ao_config.minor < 8) + ao_config.radio_enable = TRUE; ao_config.minor = AO_CONFIG_MINOR; ao_config_dirty = 1; } @@ -392,6 +394,23 @@ ao_config_radio_setting_set(void) __reentrant ao_radio_recv_abort(); } +void +ao_config_radio_enable_show(void) __reentrant +{ + printf("Radio enable: %d\n", ao_config.radio_enable); +} + +void +ao_config_radio_enable_set(void) __reentrant +{ + ao_cmd_decimal(); + if (ao_cmd_status != ao_cmd_success) + return; + _ao_config_edit_start(); + ao_config.radio_enable = ao_cmd_lex_i; + _ao_config_edit_finish(); +} + struct ao_config_var { __code char *str; void (*set)(void) __reentrant; @@ -418,6 +437,10 @@ __code struct ao_config_var ao_config_vars[] = { ao_config_radio_channel_set, ao_config_radio_channel_show }, { "c \0Callsign (8 char max)", ao_config_callsign_set, ao_config_callsign_show }, + { "R \0Radio freq control (freq = 434.550 * setting/cal)", + ao_config_radio_setting_set, ao_config_radio_setting_show }, + { "e <0 disable, 1 enable>\0Enable telemetry and RDF", + ao_config_radio_enable_set, ao_config_radio_enable_show }, #if HAS_ACCEL { "a <+g> <-g>\0Accel calib (0 for auto)", ao_config_accel_calibrate_set,ao_config_accel_calibrate_show }, @@ -436,8 +459,6 @@ __code struct ao_config_var ao_config_vars[] = { { "o <0 antenna up, 1 antenna down>\0Set pad orientation", ao_config_pad_orientation_set,ao_config_pad_orientation_show }, #endif - { "R \0Radio freq control (freq = 434.550 * setting/cal)", - ao_config_radio_setting_set, ao_config_radio_setting_show }, { "s\0Show", ao_config_show, 0 }, #if HAS_EEPROM diff --git a/src/ao_telemetry.c b/src/ao_telemetry.c index 8a18ba07..c7338a58 100644 --- a/src/ao_telemetry.c +++ b/src/ao_telemetry.c @@ -180,6 +180,8 @@ ao_telemetry(void) int16_t delay; ao_config_get(); + if (!ao_config.radio_enable) + ao_exit(); while (!ao_flight_number) ao_sleep(&ao_flight_number); -- cgit v1.2.3 From 55be3db2e31fe97e7f351e3c490b8bc4cf7192b2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 21 Aug 2011 19:18:54 -0700 Subject: altosui: Clean up command line processing. Add --graph Make the command line processing a bit less ad-hoc, track 'mode' of processing and deal with all files on the command line. Signed-off-by: Keith Packard --- altosui/AltosUI.java | 188 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 123 insertions(+), 65 deletions(-) diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 62e612ed..b2c5107e 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -364,93 +364,151 @@ public class AltosUI extends JFrame { } } + static final int process_none = 0; static final int process_csv = 1; static final int process_kml = 2; + static final int process_graph = 3; + static final int process_replay = 4; - static void process_file(String input, int process) { + static void process_csv(String input) { AltosRecordIterable iterable = open_logfile(input); if (iterable == null) return; - if (process == 0) - process = process_csv; - if ((process & process_csv) != 0) { - String output = Altos.replace_extension(input,".csv"); - System.out.printf("Processing \"%s\" to \"%s\"\n", input, output); - if (input.equals(output)) { - System.out.printf("Not processing '%s'\n", input); - } else { - AltosWriter writer = open_csv("/dev/stdout"); - if (writer != null) { - writer.write(iterable); - writer.close(); - } - } + + String output = Altos.replace_extension(input,".csv"); + System.out.printf("Processing \"%s\" to \"%s\"\n", input, output); + if (input.equals(output)) { + System.out.printf("Not processing '%s'\n", input); + } else { + AltosWriter writer = open_csv(output); + if (writer == null) + return; + writer.write(iterable); + writer.close(); } - if ((process & process_kml) != 0) { - String output = Altos.replace_extension(input,".kml"); - System.out.printf("Processing \"%s\" to \"%s\"\n", input, output); - if (input.equals(output)) { - System.out.printf("Not processing '%s'\n", input); - } else { - AltosWriter writer = open_kml(output); - if (writer == null) - return; - writer.write(iterable); - writer.close(); - } + } + + static void process_kml(String input) { + AltosRecordIterable iterable = open_logfile(input); + if (iterable == null) + return; + + String output = Altos.replace_extension(input,".kml"); + System.out.printf("Processing \"%s\" to \"%s\"\n", input, output); + if (input.equals(output)) { + System.out.printf("Not processing '%s'\n", input); + } else { + AltosWriter writer = open_kml(output); + if (writer == null) + return; + writer.write(iterable); + writer.close(); } } - public static void main(final String[] args) { - int process = 0; - /* Handle batch-mode */ - if (args.length == 1 && args[0].equals("--help")) { + static void process_replay(String filename) { + FileInputStream in; + try { + in = new FileInputStream(filename); + } catch (Exception e) { + System.out.printf("Failed to open file '%s'\n", filename); + return; + } + AltosRecordIterable recs; + AltosReplayReader reader; + if (filename.endsWith("eeprom")) { + recs = new AltosEepromIterable(in); + } else { + recs = new AltosTelemetryIterable(in); + } + reader = new AltosReplayReader(recs.iterator(), new File(filename)); + AltosFlightUI flight_ui = new AltosFlightUI(new AltosVoice(), reader); + flight_ui.set_exit_on_close(); + } + + static void process_graph(String filename) { + FileInputStream in; + try { + in = new FileInputStream(filename); + } catch (Exception e) { + System.out.printf("Failed to open file '%s'\n", filename); + return; + } + AltosRecordIterable recs; + if (filename.endsWith("eeprom")) { + recs = new AltosEepromIterable(in); + } else { + recs = new AltosTelemetryIterable(in); + } + try { + new AltosGraphUI(recs); + } catch (InterruptedException ie) { + } catch (IOException ie) { + } + } + + public static void help(int code) { System.out.printf("Usage: altosui [OPTION]... [FILE]...\n"); System.out.printf(" Options:\n"); System.out.printf(" --fetchmaps \tpre-fetch maps for site map view\n"); System.out.printf(" --replay \t\trelive the glory of past flights \n"); + System.out.printf(" --graph \t\tgraph a flight\n"); System.out.printf(" --csv\tgenerate comma separated output for spreadsheets, etc\n"); System.out.printf(" --kml\tgenerate KML output for use with Google Earth\n"); - } else if (args.length == 3 && args[0].equals("--fetchmaps")) { - double lat = Double.parseDouble(args[1]); - double lon = Double.parseDouble(args[2]); - AltosSiteMap.prefetchMaps(lat, lon, 5, 5); - } else if (args.length == 2 && args[0].equals("--replay")) { - String filename = args[1]; - FileInputStream in; - try { - in = new FileInputStream(filename); - } catch (Exception e) { - System.out.printf("Failed to open file '%s'\n", filename); - return; - } - AltosRecordIterable recs; - AltosReplayReader reader; - if (filename.endsWith("eeprom")) { - recs = new AltosEepromIterable(in); - } else { - recs = new AltosTelemetryIterable(in); - } - reader = new AltosReplayReader(recs.iterator(), new File(filename)); - AltosFlightUI flight_ui = new AltosFlightUI(new AltosVoice(), reader); - flight_ui.set_exit_on_close(); - return; - } else if (args.length > 0) { - for (int i = 0; i < args.length; i++) { - if (args[i].equals("--kml")) - process |= process_kml; - else if (args[i].equals("--csv")) - process |= process_csv; - else - process_file(args[i], process); - } - } else { + System.exit(code); + } + + public static void main(final String[] args) { + /* Handle batch-mode */ + if (args.length == 0) { AltosUI altosui = new AltosUI(); altosui.setVisible(true); java.util.List devices = AltosUSBDevice.list(Altos.product_basestation); for (AltosDevice device : devices) altosui.telemetry_window(device); + } else { + int process = process_none; + for (int i = 0; i < args.length; i++) { + if (args[i].equals("--help")) + help(0); + else if (args[i].equals("--fetchmaps")) { + if (args.length < i + 3) { + help(1); + } else { + double lat = Double.parseDouble(args[i+1]); + double lon = Double.parseDouble(args[i+2]); + AltosSiteMap.prefetchMaps(lat, lon, 5, 5); + i += 2; + } + } else if (args[i].equals("--replay")) + process = process_replay; + else if (args[i].equals("--kml")) + process = process_kml; + else if (args[i].equals("--csv")) + process = process_csv; + else if (args[i].equals("--graph")) + process = process_graph; + else if (args[i].startsWith("--")) + help(1); + else { + switch (process) { + case process_none: + case process_graph: + process_graph(args[i]); + break; + case process_replay: + process_replay(args[i]); + break; + case process_kml: + process_kml(args[i]); + break; + case process_csv: + process_csv(args[i]); + break; + } + } + } } } } -- cgit v1.2.3