1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-09-30 01:41:59 +03:00

perdump: print relative receive timestamp

- perdump.h (struct result_ops), perdump.c (analyze, pcap_record): pass
  receive timestamp to reporter
- per-text.c (t_line, flush, text_undecided, text_packet): print relative
  receive timestamp before each packet
This commit is contained in:
Werner Almesberger 2011-01-19 19:34:16 -03:00
parent 6002759464
commit 6282c334bc
3 changed files with 18 additions and 10 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
};