Root/usrp/d.c

Source at commit 424ddce9756cb5ead3e86ec27e767b4e25596ed6 created 9 years 6 months ago.
By Werner Almesberger, ants/: Passive board for antenna testing.
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}
34

Archive Download this file



interactive