Compute the maximum flight log using the data returned from the 'f'
command (total storage and erase block size). Limit menu to choices
which fall within this limit, complain if the user asks for too big a value.
Signed-off-by: Keith Packard <keithp@keithp.com>
int_ref ignite_mode;
int_ref pad_orientation;
int_ref radio_setting;
int_ref ignite_mode;
int_ref pad_orientation;
int_ref radio_setting;
+ int_ref storage_size;
+ int_ref storage_erase_unit;
string_ref version;
string_ref product;
string_ref callsign;
string_ref version;
string_ref product;
string_ref callsign;
serial_line.stop_remote();
}
serial_line.stop_remote();
}
+ int log_limit() {
+ if (storage_size.get() > 0 && storage_erase_unit.get() > 0) {
+ int log_limit = storage_size.get() - storage_erase_unit.get();
+ if (log_limit > 0)
+ return log_limit / 1024;
+ }
+ return 1024;
+ }
+
void update_ui() {
config_ui.set_serial(serial.get());
config_ui.set_product(product.get());
void update_ui() {
config_ui.set_serial(serial.get());
config_ui.set_product(product.get());
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_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_limit(log_limit());
config_ui.set_flight_log_max(flight_log_max.get());
config_ui.set_ignite_mode(ignite_mode.get());
config_ui.set_pad_orientation(pad_orientation.get());
config_ui.set_flight_log_max(flight_log_max.get());
config_ui.set_ignite_mode(ignite_mode.get());
config_ui.set_pad_orientation(pad_orientation.get());
get_int(line, "Ignite mode:", ignite_mode);
get_int(line, "Pad orientation:", pad_orientation);
get_int(line, "Radio setting:", radio_setting);
get_int(line, "Ignite mode:", ignite_mode);
get_int(line, "Pad orientation:", pad_orientation);
get_int(line, "Radio setting:", radio_setting);
+ get_int(line, "Storage size:", storage_size);
+ get_int(line, "Storage erase unit:", storage_erase_unit);
get_string(line, "Callsign:", callsign);
get_string(line,"software-version", version);
get_string(line,"product", product);
get_string(line, "Callsign:", callsign);
get_string(line,"software-version", version);
get_string(line,"product", product);
void get_data() {
try {
config.start_serial();
void get_data() {
try {
config.start_serial();
- config.serial_line.printf("c s\nv\n");
+ config.serial_line.printf("c s\nf\nv\n");
for (;;) {
try {
String line = config.serial_line.get_reply(5000);
for (;;) {
try {
String line = config.serial_line.get_reply(5000);
radio_calibration.get());
if (remote) {
serial_line.stop_remote();
radio_calibration.get());
if (remote) {
serial_line.stop_remote();
- serial_line.set_radio_frequency(frequency,
- has_setting,
- radio_calibration.get());
+ serial_line.set_radio_frequency(frequency);
AltosPreferences.set_frequency(device.getSerial(), frequency);
serial_line.start_remote();
}
AltosPreferences.set_frequency(device.getSerial(), frequency);
serial_line.start_remote();
}
+
+ /* bounds check stuff */
+ if (config_ui.flight_log_max() > log_limit()) {
+ JOptionPane.showMessageDialog(owner,
+ String.format("Requested flight log, %dk, is larger than the available space, %dk.\n",
+ config_ui.flight_log_max(),
+ log_limit()),
+ "Maximum Flight Log Too Large",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
main_deploy.set(config_ui.main_deploy());
apogee_delay.set(config_ui.apogee_delay());
radio_calibration.set(config_ui.radio_calibration());
set_frequency(config_ui.radio_frequency());
flight_log_max.set(config_ui.flight_log_max());
main_deploy.set(config_ui.main_deploy());
apogee_delay.set(config_ui.apogee_delay());
radio_calibration.set(config_ui.radio_calibration());
set_frequency(config_ui.radio_frequency());
flight_log_max.set(config_ui.flight_log_max());
- ignite_mode.set(config_ui.ignite_mode());
- pad_orientation.set(config_ui.pad_orientation());
+ if (ignite_mode.get() >= 0)
+ ignite_mode.set(config_ui.ignite_mode());
+ if (pad_orientation.get() >= 0)
+ pad_orientation.set(config_ui.pad_orientation());
callsign.set(config_ui.callsign());
run_serial_thread(serial_mode_save);
}
callsign.set(config_ui.callsign());
run_serial_thread(serial_mode_save);
}
flight_log_max = new int_ref(0);
ignite_mode = new int_ref(-1);
pad_orientation = new int_ref(-1);
flight_log_max = new int_ref(0);
ignite_mode = new int_ref(-1);
pad_orientation = new int_ref(-1);
+ storage_size = new int_ref(-1);
+ storage_erase_unit = new int_ref(-1);
callsign = new string_ref("N0CALL");
version = new string_ref("unknown");
product = new string_ref("unknown");
callsign = new string_ref("N0CALL");
version = new string_ref("unknown");
product = new string_ref("unknown");
int radio_calibration;
int flight_log_max;
int ignite_mode;
int radio_calibration;
int flight_log_max;
int ignite_mode;
+ int storage_size;
+ int storage_erase_unit;
static String get_string(String line, String label) throws ParseException {
if (line.startsWith(label)) {
static String get_string(String line, String label) throws ParseException {
if (line.startsWith(label)) {
}
public AltosConfigData(AltosSerial serial_line) throws InterruptedException, TimeoutException {
}
public AltosConfigData(AltosSerial serial_line) throws InterruptedException, TimeoutException {
- serial_line.printf("c s\nv\n");
+ serial_line.printf("c s\nf\nv\n");
lines = new LinkedList<String>();
radio_setting = 0;
for (;;) {
lines = new LinkedList<String>();
radio_setting = 0;
for (;;) {
try { version = get_string(line,"software-version"); } catch (Exception e) {}
try { product = get_string(line,"product"); } catch (Exception e) {}
try { version = get_string(line,"software-version"); } catch (Exception e) {}
try { product = get_string(line,"product"); } catch (Exception e) {}
+ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {}
+ try { storage_erase_unit = get_int(line, "Storage erase unit"); } catch (Exception e) {}
+
/* signals the end of the version info */
if (line.startsWith("software-version"))
break;
/* signals the end of the version info */
if (line.startsWith("software-version"))
break;
return Integer.parseInt(flight_log_max_value.getSelectedItem().toString());
}
return Integer.parseInt(flight_log_max_value.getSelectedItem().toString());
}
+ public void set_flight_log_max_limit(int flight_log_max_limit) {
+ boolean any_added = false;
+ flight_log_max_value.removeAllItems();
+ for (int i = 0; i < flight_log_max_values.length; i++) {
+ if (Integer.parseInt(flight_log_max_values[i]) < flight_log_max_limit){
+ flight_log_max_value.addItem(flight_log_max_values[i]);
+ any_added = true;
+ }
+ }
+ flight_log_max_value.addItem(String.format("%d", flight_log_max_limit));
+ }
+
public void set_ignite_mode(int new_ignite_mode) {
if (new_ignite_mode < 0) {
ignite_mode_value.setEnabled(false);
public void set_ignite_mode(int new_ignite_mode) {
if (new_ignite_mode < 0) {
ignite_mode_value.setEnabled(false);
}
public int ignite_mode() {
}
public int ignite_mode() {
- return ignite_mode_value.getSelectedIndex();
+ if (ignite_mode_value.isEnabled())
+ return ignite_mode_value.getSelectedIndex();
+ else
+ return -1;
}
public int pad_orientation() {
}
public int pad_orientation() {
- return pad_orientation_value.getSelectedIndex();
+ if (pad_orientation_value.isEnabled())
+ return pad_orientation_value.getSelectedIndex();
+ else
+ return -1;
}
public void set_clean() {
}
public void set_clean() {