From: Keith Packard Date: Thu, 5 Nov 2009 05:59:51 +0000 (-0800) Subject: Stop recording in ao-dumplog after receiving an invalid block X-Git-Tag: debian/0.6+27+gb0d7e3f~14 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=5a79a04ddb0b3ee64de34e366f71a0f6db509c01 Stop recording in ao-dumplog after receiving an invalid block If no samples in a block are valid, assume the flight log is over. Signed-off-by: Keith Packard --- diff --git a/ao-tools/ao-dumplog/ao-dumplog.c b/ao-tools/ao-dumplog/ao-dumplog.c index 4bfb7e51..b3a0a25a 100644 --- a/ao-tools/ao-dumplog/ao-dumplog.c +++ b/ao-tools/ao-dumplog/ao-dumplog.c @@ -82,6 +82,8 @@ main (int argc, char **argv) int done; int column; int remote = 0; + int any_valid; + int invalid; while ((c = getopt_long(argc, argv, "T:D:R", options, NULL)) != -1) { switch (c) { @@ -146,6 +148,7 @@ main (int argc, char **argv) column = 0; } putchar('.'); fflush(stdout); column++; + any_valid = 0; for (addr = 0; addr < 0x100;) { cc_usb_getline(cc, line, sizeof (line)); if (sscanf(line, "00%x %x %x %x %x %x %x %x %x", @@ -160,6 +163,8 @@ main (int argc, char **argv) if (log_checksum(data) != 0) fprintf (stderr, "invalid checksum at 0x%x\n", block * 256 + received_addr); + else + any_valid = 1; cmd = data[0]; tick = data[2] + (data[3] << 8); @@ -182,6 +187,11 @@ main (int argc, char **argv) addr += 8; } } + if (!any_valid) { + fclose(out); + out = NULL; + done = 1; + } } if (column) putchar('\n');