X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=micropeak%2FMicroData.java;fp=micropeak%2FMicroData.java;h=4a53482c74ad95e93f43daa968cb7c320472c70d;hb=b140da92536d7c48ba37868f1c2afce7bb86dfdb;hp=359ccd7aea592bced582a440e87d8f3f6d66a02c;hpb=1d208c9509f03f7e2c913abe5c0dd78ef0083c0f;p=fw%2Faltos diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index 359ccd7a..4a53482c 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -157,6 +157,8 @@ public class MicroData { public boolean crc_valid; + public boolean log_empty; + int mix_in (int high, int low) { return high - (high & 0xffff) + low; } @@ -246,6 +248,15 @@ public class MicroData { f.write('\n'); } + public boolean is_empty() { + boolean empty = true; + for (int c : bytes) { + if (!Character.isWhitespace(c) && c != 'f') + empty = false; + } + return empty; + } + public void export (Writer f) throws IOException { PrintWriter pw = new PrintWriter(f); pw.printf(" Time, Press(Pa), Height(m), Height(f), Speed(m/s), Speed(mph), Speed(mach), Accel(m/s²), Accel(ft/s²), Accel(g)\n"); @@ -352,7 +363,12 @@ public class MicroData { int current_crc = swap16(~file_crc & 0xffff); int crc = get_16(f); - crc_valid = crc == current_crc; + crc_valid = (crc == current_crc); + + if (!crc_valid && is_empty()) { + crc_valid = true; + nsamples = 0; + } if (log_id == LOG_ID_MICROPEAK2) { unique_id = get_line(f);