+ public int log_available() {
+ switch (log_format) {
+ case Altos.AO_LOG_FORMAT_TINY:
+ if (stored_flight == 0)
+ return 1;
+ return 0;
+ default:
+ if (flight_log_max <= 0)
+ return 1;
+ int log_space = storage_size - storage_erase_unit;
+ int log_used = stored_flight * flight_log_max;
+
+ if (log_used >= log_space)
+ return 0;
+ return (log_space - log_used) / flight_log_max;
+ }
+ }
+
+ int[] parse_version(String v) {
+ String[] parts = v.split("\\.");
+ int r[] = new int[parts.length];
+
+ for (int i = 0; i < parts.length; i++) {
+ try {
+ r[i] = Altos.fromdec(parts[i]);
+ } catch (NumberFormatException n) {
+ r[i] = 0;
+ }
+ }
+
+ return r;
+ }
+
+ public int compare_version(String other) {
+ int[] me = parse_version(version);
+ int[] them = parse_version(other);
+
+ int l = Math.min(me.length, them.length);
+
+ for (int i = 0; i < l; i++) {
+ int d = me[i] - them[i];
+ if (d != 0)
+ return d;
+ }
+ if (me.length > l)
+ return 1;
+ if (them.length > l)
+ return -1;
+ return 0;
+ }
+