Need to round log sizes down to a multiple of the block size so that
erasing works sensibly on the device.
Signed-off-by: Keith Packard <keithp@keithp.com>
dest.set_flight_log_max_enabled(max_enabled);
dest.set_radio_enable(radio_enable);
dest.set_flight_log_max_enabled(max_enabled);
dest.set_radio_enable(radio_enable);
- dest.set_flight_log_max_limit(log_space() / 1024);
+ dest.set_flight_log_max_limit(log_space() >> 10, storage_erase_unit >> 10);
dest.set_flight_log_max(flight_log_max);
dest.set_ignite_mode(ignite_mode);
dest.set_pad_orientation(pad_orientation);
dest.set_flight_log_max(flight_log_max);
dest.set_ignite_mode(ignite_mode);
dest.set_pad_orientation(pad_orientation);
link.printf("c a %d %d\n", plus, minus);
/* HAS_LOG */
link.printf("c a %d %d\n", plus, minus);
/* HAS_LOG */
- if (flight_log_max != 0)
+ if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
link.printf("c l %d\n", flight_log_max);
/* HAS_IGNITE */
link.printf("c l %d\n", flight_log_max);
/* HAS_IGNITE */
try {
/* bounds check stuff */
try {
/* bounds check stuff */
- if (config_ui.flight_log_max() > data.log_space() / 1024) {
+ if (config_ui.flight_log_max() != AltosLib.MISSING &&
+ config_ui.flight_log_max() > data.log_space() / 1024)
+ {
JOptionPane.showMessageDialog(owner,
String.format("Requested flight log, %dk, is larger than the available space, %dk.\n",
config_ui.flight_log_max(),
JOptionPane.showMessageDialog(owner,
String.format("Requested flight log, %dk, is larger than the available space, %dk.\n",
config_ui.flight_log_max(),
return AltosLib.MISSING;
}
return AltosLib.MISSING;
}
- public void set_flight_log_max_limit(int new_flight_log_max_limit) {
+ public void set_flight_log_max_limit(int new_flight_log_max_limit, int new_storage_erase_unit) {
flight_log_max_limit = new_flight_log_max_limit;
if (new_flight_log_max_limit != AltosLib.MISSING) {
flight_log_max_value.removeAllItems();
for (int i = 8; i >= 1; i--) {
int size = flight_log_max_limit / i;
flight_log_max_limit = new_flight_log_max_limit;
if (new_flight_log_max_limit != AltosLib.MISSING) {
flight_log_max_value.removeAllItems();
for (int i = 8; i >= 1; i--) {
int size = flight_log_max_limit / i;
+ if (new_storage_erase_unit != 0)
+ size &= ~(new_storage_erase_unit - 1);
flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
}
}
flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
}
}
- if (flight_log_max != 0)
+ if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
set_flight_log_max(flight_log_max);
}
set_flight_log_max(flight_log_max);
}
serial_line.printf("d %d\n", log.flight);
for (;;) {
/* It can take a while to erase the flash... */
serial_line.printf("d %d\n", log.flight);
for (;;) {
/* It can take a while to erase the flash... */
- String line = serial_line.get_reply(20000);
+ String line = serial_line.get_reply(200000);
if (line == null)
throw new TimeoutException();
if (line.equals("Erased"))
break;
if (line == null)
throw new TimeoutException();
if (line.equals("Erased"))
break;
+ if (line.equals("Failed to erase"))
+ throw new IOException(line);
if (line.startsWith("No such"))
throw new IOException(line);
}
if (line.startsWith("No such"))
throw new IOException(line);
}
return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
}
return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
}
- public void set_flight_log_max_limit(int new_flight_log_max_limit) {
+ public void set_flight_log_max_limit(int new_flight_log_max_limit, int new_storage_erase_unit) {
flight_log_max_limit = new_flight_log_max_limit;
flight_log_max_limit = new_flight_log_max_limit;
- flight_log_max_value.removeAllItems();
- for (int i = 8; i >= 1; i--) {
- int size = flight_log_max_limit / i;
- flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
+ if (new_flight_log_max_limit != AltosLib.MISSING) {
+ flight_log_max_value.removeAllItems();
+ for (int i = 8; i >= 1; i--) {
+ int size = flight_log_max_limit / i;
+ if (new_storage_erase_unit != 0)
+ size &= ~(new_storage_erase_unit - 1);
+ flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
+ }
- if (flight_log_max != 0)
+ if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
set_flight_log_max(flight_log_max);
}
set_flight_log_max(flight_log_max);
}