Date:2011-01-19 23:34:16 (8 years 6 months ago)
Author:Werner Almesberger
Commit:6282c334bc60635ee57507bd95a22b9e548b030f
Message: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
Files: tools/atrf-txrx/per-text.c (2 diffs)
tools/atrf-txrx/perdump.c (3 diffs)
tools/atrf-txrx/perdump.h (1 diff)

Change Details

tools/atrf-txrx/per-text.c
1717
1818
1919static char line[65] = "";
20static double t_line;
2021static int packets = 0, garbled = 0, bad = 0, skipped = 0;
2122static int is_bad = 0;
2223
2324
2425static void flush(void)
2526{
26    if (*line)
27    if (*line) {
28        printf("%9.3f ", t_line);
2729        printf("%s\n", line);
30    }
2831    *line = 0;
2932}
3033
3134
32static void text_undecided(int symbols)
35static void text_undecided(int symbols, double t)
3336{
3437    int i;
3538
3639    flush();
40    printf("%9.3f ", t);
3741    for (i = 0; i != symbols/4; i++)
3842        putchar('?');
3943    putchar('\n');
4044}
4145
4246
43static void text_packet(int symbols, int skip)
47static void text_packet(int symbols, int skip, double t)
4448{
4549    int i;
4650
...... 
5054        for (i = 0; i != skip; i++)
5155            putchar('\n');
5256    else
53        printf("\n(%d)\n\n", skip);
57        printf("\n (%d)\n\n", skip);
5458    for (i = 0; i != symbols/4; i++)
5559        line[i] = '-';
5660    line[i] = 0;
61    t_line = t;
5762    packets++;
5863    is_bad = 0;
5964}
tools/atrf-txrx/perdump.c
2525static const struct result_ops *ops;
2626
2727
28static void analyze(uint8_t *buf, int len)
28static void analyze(uint8_t *buf, int len, double ts)
2929{
3030    static int last = -1;
31    static double t0 = 0;
3132    int freq[256];
3233    uint8_t best = 0;
3334    int i;
3435
36    if (!t0)
37        t0 = ts;
3538    for (i = 0; i != 256; i++)
3639        freq[i] = 0;
3740    for (i = 0; i != len; i++) {
...... 
4043            best = buf[i];
4144    }
4245    if (freq[best] <= len >> 1 && freq[best] != len) {
43        ops->undecided(len*2);
46        ops->undecided(len*2, ts-t0);
4447        if (last != -1)
4548            last++; /* probably :-) */
4649        return;
4750    }
48    ops->packet(len*2, last == -1 ? 0 : (uint8_t) (best-last-1));
51    ops->packet(len*2, last == -1 ? 0 : (uint8_t) (best-last-1), ts-t0);
4952    last = best;
5053    for (i = 0; i != len; i++) {
5154        uint8_t delta = buf[i] ^ best;
...... 
8790        fprintf(stderr, "file truncated\n");
8891        exit(1);
8992    }
90    analyze(buf, hdr.caplen);
93    analyze(buf, hdr.caplen, hdr.ts_sec+hdr.ts_usec/1000000.0);
9194    return 1;
9295}
9396
tools/atrf-txrx/perdump.h
1616
1717struct result_ops {
1818    void (*begin)(void);
19    void (*undecided)(int symbols);
20    void (*packet)(int symbols, int skip);
19    void (*undecided)(int symbols, double t);
20    void (*packet)(int symbols, int skip, double t);
2121    void (*error)(int symbol);
2222    void (*finish)(void);
2323};

Archive Download the corresponding diff file



interactive