Root/tools/atrf-path/genpathprof

Source at commit 66d641f624f7c2a196c483d0592a7a871976310f created 8 years 11 months ago.
By Werner Almesberger, atrf-path/genpathprof: profile generator
1#!/usr/bin/perl
2#
3# atrf-path/genpathprof - Generate profile for atrf-path
4#
5# Written 2011 by Werner Almesberger
6# Copyright 2011 Werner Almesberger
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13
14sub usage
15{
16    print STDERR <<"END"
17usage: $0 below above [file ...]
18
19  below/above define either absolute values or clearances:
20    10 = 10.0 dBm
21    -3.5 = -3.5 dBm
22    +5 = 5 dBm below or above the minimum/maximum measurement
23END
24;
25    exit(1);
26}
27
28$below = shift @ARGV;
29$above = shift @ARGV;
30
31&usage unless defined $below && defined $above;
32
33while (<>) {
34    next unless /^(\d+)\.5\s+(-?\d+(\.\d*))\s+/;
35    $f = int(($1+2.5)/5)*5;
36    $min{$f} = $2 if $min{$f} > $2 || !defined $min{$f};
37    $max{$f} = $2 if $max{$f} < $2 || !defined $max{$f};
38}
39print "# min\tmax\t Chan\tMHz\n";
40for ($i = 0; $i != 16; $i++) {
41    $f = 2405+5*$i;
42    if ($below =~ /^\+/) {
43        $min = $min{$f}-$';
44    } else {
45        $min = $below;
46    }
47    if ($above =~ /^\+/) {
48        $max = $max{$f}+$';
49    } else {
50        $max = $above;
51    }
52    printf("%.2f\t%.2f\t# %d\t%d\n", $min, $max, $i+11, $f);
53}
54

Archive Download this file



interactive