mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-25 18:57:11 +02:00
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"
This commit is contained in:
parent
c99ba2c769
commit
e445fe1b01
4
usrp/Makefile
Normal file
4
usrp/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
CFLAGS=-Wall -O9
|
||||
LDFLAGS=-lm
|
||||
|
||||
all: p d
|
33
usrp/d.c
Normal file
33
usrp/d.c
Normal file
@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#define N 100
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
float c[2];
|
||||
int n = 0;
|
||||
float sum = 0;
|
||||
size_t s;
|
||||
|
||||
|
||||
while (1) {
|
||||
s = fread(c, sizeof(c), 1, stdin);
|
||||
if (!s) {
|
||||
if (!ferror(stdin))
|
||||
break;
|
||||
if (s < 0) {
|
||||
perror("read");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
sum += hypot(c[0], c[1]);
|
||||
if (n++ % N)
|
||||
continue;
|
||||
printf("%f\n", sum/N);
|
||||
sum = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
66
usrp/p.c
Normal file
66
usrp/p.c
Normal file
@ -0,0 +1,66 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#define PERC 0.9
|
||||
#define SKIP 1000000
|
||||
|
||||
|
||||
static int comp(const void *_a, const void *_b)
|
||||
{
|
||||
float a = *(const float *) _a;
|
||||
float b = *(const float *) _b;
|
||||
|
||||
return a < b ? -1 : a > b;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
float max = 0;
|
||||
float c[2], a;
|
||||
float *rec = NULL;
|
||||
int e = 0, n = 0, skip = SKIP;
|
||||
|
||||
while (1) {
|
||||
size_t s;
|
||||
|
||||
s = fread(c, sizeof(c), 1, stdin);
|
||||
if (!s) {
|
||||
if (!ferror(stdin))
|
||||
break;
|
||||
if (s < 0) {
|
||||
perror("read");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (skip) {
|
||||
skip--;
|
||||
continue;
|
||||
}
|
||||
a = hypotf(c[0], c[1]);
|
||||
if (a > max)
|
||||
max = a;
|
||||
if (e <= n) {
|
||||
e = e ? e*2 : 10000;
|
||||
rec = realloc(rec, e*sizeof(float));
|
||||
if (!rec) {
|
||||
perror("realloc");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
rec[n] = a;
|
||||
n++;
|
||||
}
|
||||
qsort(rec, n, sizeof(float), comp);
|
||||
printf("%f %f\n", max, rec[(int) (PERC*n)]);
|
||||
#if 0
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i += 1000)
|
||||
printf("%f %f\n", (double) i/n, rec[i]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
36
usrp/step
Executable file
36
usrp/step
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh -x
|
||||
|
||||
CH_FIRST=11
|
||||
CH_LAST=26
|
||||
RUNS=10
|
||||
|
||||
m10=0123456789
|
||||
m20=$m10$m10
|
||||
MSG=$m20$m20$m20$m20$m20
|
||||
|
||||
|
||||
mhz()
|
||||
{
|
||||
expr 2405 + 5 \* \( $1 - 11 \)
|
||||
}
|
||||
|
||||
rm -f out
|
||||
run=0
|
||||
while [ $run -lt $RUNS ]; do
|
||||
c=$CH_FIRST
|
||||
while [ $c -le $CH_LAST ]; do
|
||||
echo "Run $run, ch $c (`mhz $c` MHz)" 1>&2
|
||||
mhz $c | tr '\n' ' ' >>out
|
||||
( ssh ben ./atspi-txrx -c $c -p 4 $MSG 1500; echo DONE 1>&2; ) &
|
||||
sleep 3
|
||||
usrp2_rx_cfile.py -d 4 -f `mhz $c`M -g 40 -N 100M tmp
|
||||
sync
|
||||
./p <tmp >>out
|
||||
rm -f tmp
|
||||
sync
|
||||
sleep 2
|
||||
c=`expr $c + 1`
|
||||
done
|
||||
run=`expr $run + 1`
|
||||
echo >>out
|
||||
done
|
Loading…
Reference in New Issue
Block a user