-
Notifications
You must be signed in to change notification settings - Fork 3
/
wbt_pi
42 lines (42 loc) · 951 Bytes
/
wbt_pi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl -w
use strict;
open(UBTS,"spectool_raw|grep ': -[0-9]'|");
while(<UBTS>){
my @bars= ( # from -100dBm to -70dBm (Reset Bars);
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
); # [0] = 50, [1] = 60, [4] = 90
my $l = $_;
$l =~ s/Ubert.*ne [0-9]+: //;
chomp $l;
my @lvls = split(/ /,$l);
for(my $i=0;$i<=$#lvls;$i++){
if($lvls[$i] =~ m/[0-9]/){
$lvls[$i] = abs($lvls[$i]); # drop the sign
$lvls[$i] = 100 - $lvls[$i];
}else{
$lvls[$i] = 0; # ?
}
if($lvls[$i] < 0){ # apperently abs doesnt work sometimes...
$lvls[$i] = 0;
}
for(my$j=0;$j<=$#bars;$j++){
if($bars[$j] !~ m/MHz/){
if($j<=($lvls[$i]-1)){
$bars[$j].="P";
}else{
$bars[$j].=" ";
}
}
}
}
my $graph = "";
for(my$i=$#bars;$i>=0;$i--){
$graph .= $bars[$i]."\n";
}
# print the graph
open(FLE,">ubt.out"); # ubertooth output
print FLE $graph;
close(FLE);
}