diff --git a/tools/atrf-txrx/per-text.c b/tools/atrf-txrx/per-text.c index b0d34a6..e588958 100644 --- a/tools/atrf-txrx/per-text.c +++ b/tools/atrf-txrx/per-text.c @@ -17,30 +17,34 @@ static char line[65] = ""; +static double t_line; static int packets = 0, garbled = 0, bad = 0, skipped = 0; static int is_bad = 0; static void flush(void) { - if (*line) + if (*line) { + printf("%9.3f ", t_line); printf("%s\n", line); + } *line = 0; } -static void text_undecided(int symbols) +static void text_undecided(int symbols, double t) { int i; flush(); + printf("%9.3f ", t); for (i = 0; i != symbols/4; i++) putchar('?'); putchar('\n'); } -static void text_packet(int symbols, int skip) +static void text_packet(int symbols, int skip, double t) { int i; @@ -50,10 +54,11 @@ static void text_packet(int symbols, int skip) for (i = 0; i != skip; i++) putchar('\n'); else - printf("\n(%d)\n\n", skip); + printf("\n (%d)\n\n", skip); for (i = 0; i != symbols/4; i++) line[i] = '-'; line[i] = 0; + t_line = t; packets++; is_bad = 0; } diff --git a/tools/atrf-txrx/perdump.c b/tools/atrf-txrx/perdump.c index 3056d33..4c8900f 100644 --- a/tools/atrf-txrx/perdump.c +++ b/tools/atrf-txrx/perdump.c @@ -25,13 +25,16 @@ static const struct result_ops *ops; -static void analyze(uint8_t *buf, int len) +static void analyze(uint8_t *buf, int len, double ts) { static int last = -1; + static double t0 = 0; int freq[256]; uint8_t best = 0; int i; + if (!t0) + t0 = ts; for (i = 0; i != 256; i++) freq[i] = 0; for (i = 0; i != len; i++) { @@ -40,12 +43,12 @@ static void analyze(uint8_t *buf, int len) best = buf[i]; } if (freq[best] <= len >> 1 && freq[best] != len) { - ops->undecided(len*2); + ops->undecided(len*2, ts-t0); if (last != -1) last++; /* probably :-) */ return; } - ops->packet(len*2, last == -1 ? 0 : (uint8_t) (best-last-1)); + ops->packet(len*2, last == -1 ? 0 : (uint8_t) (best-last-1), ts-t0); last = best; for (i = 0; i != len; i++) { uint8_t delta = buf[i] ^ best; @@ -87,7 +90,7 @@ static int pcap_record(FILE *file, const char *name) fprintf(stderr, "file truncated\n"); exit(1); } - analyze(buf, hdr.caplen); + analyze(buf, hdr.caplen, hdr.ts_sec+hdr.ts_usec/1000000.0); return 1; } diff --git a/tools/atrf-txrx/perdump.h b/tools/atrf-txrx/perdump.h index 9d2b0c0..e2ca873 100644 --- a/tools/atrf-txrx/perdump.h +++ b/tools/atrf-txrx/perdump.h @@ -16,8 +16,8 @@ struct result_ops { void (*begin)(void); - void (*undecided)(int symbols); - void (*packet)(int symbols, int skip); + void (*undecided)(int symbols, double t); + void (*packet)(int symbols, int skip, double t); void (*error)(int symbol); void (*finish)(void); };