Date:2010-09-16 06:01:02 (13 years 6 months ago)
Author:Werner Almesberger
Commit:e445fe1b015e63c1686774f6e3bb3ea427ad6ccf
Message:usrp/: a set of utilities for testing board performance with an USRP2

- usrp/d.c: reduce the number of data points in a file produced by
usrp2_rx_cfile.py and print them as text suitable for gnuplot
- usrp/p.c: determine the peak amplitude in a series of transmissions,
filtering noise and artefacts at the beginning of the data file
- usrp/step: step through all channels and measure TX power (for antenna
tuning)
- usrp/Makefile: built "p" and "d"
Files: usrp/Makefile (1 diff)
usrp/d.c (1 diff)
usrp/p.c (1 diff)
usrp/step (1 diff)

Change Details

usrp/Makefile
1CFLAGS=-Wall -O9
2LDFLAGS=-lm
3
4all: p d
usrp/d.c
1#include <stdio.h>
2#include <math.h>
3
4
5#define N 100
6
7
8int main(int argc, char **argv)
9{
10    float c[2];
11    int n = 0;
12    float sum = 0;
13    size_t s;
14
15
16    while (1) {
17        s = fread(c, sizeof(c), 1, stdin);
18        if (!s) {
19            if (!ferror(stdin))
20                break;
21            if (s < 0) {
22                perror("read");
23                return 1;
24            }
25        }
26        sum += hypot(c[0], c[1]);
27        if (n++ % N)
28            continue;
29        printf("%f\n", sum/N);
30        sum = 0;
31    }
32    return 0;
33}
usrp/p.c
1#include <stdlib.h>
2#include <stdio.h>
3#include <math.h>
4#include <sys/types.h>
5
6
7#define PERC 0.9
8#define SKIP 1000000
9
10
11static int comp(const void *_a, const void *_b)
12{
13    float a = *(const float *) _a;
14    float b = *(const float *) _b;
15
16    return a < b ? -1 : a > b;
17}
18
19
20int main(int argc, char **argv)
21{
22    float max = 0;
23    float c[2], a;
24    float *rec = NULL;
25    int e = 0, n = 0, skip = SKIP;
26
27    while (1) {
28        size_t s;
29
30        s = fread(c, sizeof(c), 1, stdin);
31        if (!s) {
32            if (!ferror(stdin))
33                break;
34            if (s < 0) {
35                perror("read");
36                return 1;
37            }
38        }
39        if (skip) {
40            skip--;
41            continue;
42        }
43        a = hypotf(c[0], c[1]);
44        if (a > max)
45            max = a;
46        if (e <= n) {
47            e = e ? e*2 : 10000;
48            rec = realloc(rec, e*sizeof(float));
49            if (!rec) {
50                perror("realloc");
51                exit(1);
52            }
53        }
54        rec[n] = a;
55        n++;
56    }
57    qsort(rec, n, sizeof(float), comp);
58    printf("%f %f\n", max, rec[(int) (PERC*n)]);
59#if 0
60int i;
61
62    for (i = 0; i < n; i += 1000)
63        printf("%f %f\n", (double) i/n, rec[i]);
64#endif
65    return 0;
66}
usrp/step
1#!/bin/sh -x
2
3CH_FIRST=11
4CH_LAST=26
5RUNS=10
6
7m10=0123456789
8m20=$m10$m10
9MSG=$m20$m20$m20$m20$m20
10
11
12mhz()
13{
14    expr 2405 + 5 \* \( $1 - 11 \)
15}
16
17rm -f out
18run=0
19while [ $run -lt $RUNS ]; do
20    c=$CH_FIRST
21    while [ $c -le $CH_LAST ]; do
22    echo "Run $run, ch $c (`mhz $c` MHz)" 1>&2
23        mhz $c | tr '\n' ' ' >>out
24    ( ssh ben ./atspi-txrx -c $c -p 4 $MSG 1500; echo DONE 1>&2; ) &
25    sleep 3
26    usrp2_rx_cfile.py -d 4 -f `mhz $c`M -g 40 -N 100M tmp
27    sync
28    ./p <tmp >>out
29    rm -f tmp
30    sync
31    sleep 2
32    c=`expr $c + 1`
33    done
34    run=`expr $run + 1`
35    echo >>out
36done

Archive Download the corresponding diff file



interactive