mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 20:03:09 +02: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:
parent
6002759464
commit
6282c334bc
@ -17,30 +17,34 @@
|
|||||||
|
|
||||||
|
|
||||||
static char line[65] = "";
|
static char line[65] = "";
|
||||||
|
static double t_line;
|
||||||
static int packets = 0, garbled = 0, bad = 0, skipped = 0;
|
static int packets = 0, garbled = 0, bad = 0, skipped = 0;
|
||||||
static int is_bad = 0;
|
static int is_bad = 0;
|
||||||
|
|
||||||
|
|
||||||
static void flush(void)
|
static void flush(void)
|
||||||
{
|
{
|
||||||
if (*line)
|
if (*line) {
|
||||||
|
printf("%9.3f ", t_line);
|
||||||
printf("%s\n", line);
|
printf("%s\n", line);
|
||||||
|
}
|
||||||
*line = 0;
|
*line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void text_undecided(int symbols)
|
static void text_undecided(int symbols, double t)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
flush();
|
flush();
|
||||||
|
printf("%9.3f ", t);
|
||||||
for (i = 0; i != symbols/4; i++)
|
for (i = 0; i != symbols/4; i++)
|
||||||
putchar('?');
|
putchar('?');
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void text_packet(int symbols, int skip)
|
static void text_packet(int symbols, int skip, double t)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -50,10 +54,11 @@ static void text_packet(int symbols, int skip)
|
|||||||
for (i = 0; i != skip; i++)
|
for (i = 0; i != skip; i++)
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
else
|
else
|
||||||
printf("\n(%d)\n\n", skip);
|
printf("\n (%d)\n\n", skip);
|
||||||
for (i = 0; i != symbols/4; i++)
|
for (i = 0; i != symbols/4; i++)
|
||||||
line[i] = '-';
|
line[i] = '-';
|
||||||
line[i] = 0;
|
line[i] = 0;
|
||||||
|
t_line = t;
|
||||||
packets++;
|
packets++;
|
||||||
is_bad = 0;
|
is_bad = 0;
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,16 @@
|
|||||||
static const struct result_ops *ops;
|
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 int last = -1;
|
||||||
|
static double t0 = 0;
|
||||||
int freq[256];
|
int freq[256];
|
||||||
uint8_t best = 0;
|
uint8_t best = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!t0)
|
||||||
|
t0 = ts;
|
||||||
for (i = 0; i != 256; i++)
|
for (i = 0; i != 256; i++)
|
||||||
freq[i] = 0;
|
freq[i] = 0;
|
||||||
for (i = 0; i != len; i++) {
|
for (i = 0; i != len; i++) {
|
||||||
@ -40,12 +43,12 @@ static void analyze(uint8_t *buf, int len)
|
|||||||
best = buf[i];
|
best = buf[i];
|
||||||
}
|
}
|
||||||
if (freq[best] <= len >> 1 && freq[best] != len) {
|
if (freq[best] <= len >> 1 && freq[best] != len) {
|
||||||
ops->undecided(len*2);
|
ops->undecided(len*2, ts-t0);
|
||||||
if (last != -1)
|
if (last != -1)
|
||||||
last++; /* probably :-) */
|
last++; /* probably :-) */
|
||||||
return;
|
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;
|
last = best;
|
||||||
for (i = 0; i != len; i++) {
|
for (i = 0; i != len; i++) {
|
||||||
uint8_t delta = buf[i] ^ best;
|
uint8_t delta = buf[i] ^ best;
|
||||||
@ -87,7 +90,7 @@ static int pcap_record(FILE *file, const char *name)
|
|||||||
fprintf(stderr, "file truncated\n");
|
fprintf(stderr, "file truncated\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
analyze(buf, hdr.caplen);
|
analyze(buf, hdr.caplen, hdr.ts_sec+hdr.ts_usec/1000000.0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
struct result_ops {
|
struct result_ops {
|
||||||
void (*begin)(void);
|
void (*begin)(void);
|
||||||
void (*undecided)(int symbols);
|
void (*undecided)(int symbols, double t);
|
||||||
void (*packet)(int symbols, int skip);
|
void (*packet)(int symbols, int skip, double t);
|
||||||
void (*error)(int symbol);
|
void (*error)(int symbol);
|
||||||
void (*finish)(void);
|
void (*finish)(void);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user