Skip to content
Snippets Groups Projects
Commit 38dc7988 authored by NATAF Emmanuel's avatar NATAF Emmanuel
Browse files

scripts

parent 60b31f86
Branches lt-wsn
No related tags found
No related merge requests found
...@@ -10,17 +10,18 @@ nrg=0 ...@@ -10,17 +10,18 @@ nrg=0
C=$((600)) C=$((600))
ecu=0 ecu=0
prc=0 prc=0
dating=$3
for v in $(grep "$1" $2 | cut -d ' ' -f13-53) for v in $(grep "$1" $2 | cut -d ' ' -f13-53)
do do
case $i in case $i in
[0-6]) [0-5])
time=$(($time + ($v << ($i * 8)) ));; time=$(($time + ($v << ($i * 8)) ));;
8|9|1[0-1]) 8|9|1[0-1])
cpu=$(($cpu + ($v << (($i - 8) * 8)) ));; cpu=$(($cpu + ($v << (($i - 8) * 8)) ));;
1[6-9]) 1[6-9])
lpm=$(($lpm + ($v << (($i - 16) * 8)) ));; lpm=$(($lpm + ($v << (($i - 16) * 8)) ));;
2[4-9]|3[0-1]) 2[4-9]|3[01])
tx=$(($tx + ($v << (($i - 24) * 8)) ));; tx=$(($tx + ($v << (($i - 24) * 8)) ));;
3[2-9]) 3[2-9])
rx=$(($rx + ($v << (($i - 32) * 8)) ));; rx=$(($rx + ($v << (($i - 32) * 8)) ));;
...@@ -60,8 +61,13 @@ do ...@@ -60,8 +61,13 @@ do
prc=$(echo "$prc + $tps*100/$d" | bc -l) prc=$(echo "$prc + $tps*100/$d" | bc -l)
ecu=$(echo "100-$prc" | bc -l) ecu=$(echo "100-$prc" | bc -l)
echo $(date -d @$time +%D:%H:%M:%S) $ecu >> $$.nrg.tmp if [ $dating ]
then
echo $(date -d @$time +%D:%H:%M:%S) $ecu >> $$.nrg.tmp
else
echo $time $ecu >> $$.nrg.tmp
fi
fi fi
done done
cat $$.nrg.tmp cat $$.nrg.tmp
......
#!/bin/bash #!/bin/bash
i=0 i=0
tx=0 rx=0
time=0 time=0
dating=$3
for v in $(grep -E "$1" $2 | cut -d ' ' -f5-20) for v in $(grep -E "$1" $2 | cut -d ' ' -f5-20)
do do
case $i in case $i in
[0-6]) [0-6])
tx=$(($tx + ($v << ($i * 8)) )) rx=$(($rx + ($v << ($i * 8)) ))
;; ;;
8|9|1[0-5]) 8|9|1[0-5])
time=$(($time + ($v << (($i-8) * 8)) )) time=$(($time + ($v << (($i-8) * 8)) ))
...@@ -18,11 +19,16 @@ do ...@@ -18,11 +19,16 @@ do
i=$(((i+1)%16)) i=$(((i+1)%16))
if [ $i -eq 0 ] if [ $i -eq 0 ]
then then
if [ $tx -ne 0 ] if [ $rx -ne 0 ]
then then
echo $(date -d @$time +%D:%H:%M:%S) $tx if [ $dating ]
then
echo $(date -d @$time +%D:%H:%M:%S) $rx
else
echo $time $rx
fi
fi fi
tx=0 rx=0
time=0 time=0
fi fi
done done
...@@ -13,11 +13,13 @@ rcvip=0 ...@@ -13,11 +13,13 @@ rcvip=0
fwip=0 fwip=0
dropip=0 dropip=0
dating=$3
for v in $(grep "$1" $2 | cut -d ' ' -f5-36) for v in $(grep "$1" $2 | cut -d ' ' -f5-36)
do do
case $i in case $i in
[0-7]) [0-7])
time=$(($time + ($v << ($i * 8)) )) time=$(($time + ($v << ($i * 7)) ))
;; ;;
8|9) 8|9)
senddio=$(($senddio + ($v << (($i-8) * 8)) )) senddio=$(($senddio + ($v << (($i-8) * 8)) ))
...@@ -60,7 +62,12 @@ do ...@@ -60,7 +62,12 @@ do
i=$(((i+1)%32)) i=$(((i+1)%32))
if [ $i -eq 0 ] if [ $i -eq 0 ]
then then
echo $(date -d @$time +%D:%H:%M:%S) $senddio $rcvdio $senddao $rcvdao $senddis $rcvdis $sendack $rcvack $sendip $rcvip $fwdip $dropip if [ $dating ]
then
echo $(date -d @$time +%D:%H:%M:%S) $senddio $rcvdio $senddao $rcvdao $senddis $rcvdis $sendack $rcvack $sendip $rcvip $fwdip $dropip
else
echo $time $senddio $rcvdio $senddao $rcvdao $senddis $rcvdis $sendack $rcvack $sendip $rcvip $fwdip $dropip
fi
time=0 time=0
senddio=0 senddio=0
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
i=0 i=0
time=0 time=0
volt=0 volt=0
dating=$3
rm $$.vlt.tmp &> /dev/null rm $$.vlt.tmp &> /dev/null
...@@ -19,10 +20,15 @@ do ...@@ -19,10 +20,15 @@ do
i=$(((i+1)%12)) i=$(((i+1)%12))
if [ $i -eq 0 ] if [ $i -eq 0 ]
then then
if [ $dating ]
then
if date -d @$time +%D:%H:%M:%S &>/dev/null if date -d @$time +%D:%H:%M:%S &>/dev/null
then then
echo $(date -d @$time +%D:%H:%M:%S) $volt >> $$.vlt.tmp echo $(date -d @$time +%D:%H:%M:%S) $volt >> $$.vlt.tmp
fi fi
else
echo $time $volt >> $$.vlt.tmp
fi
time=0 time=0
volt=0 volt=0
fi fi
......
#!/bin/bash #!/bin/bash
i=0 i=0
for a in $(cat sensors-adresses)
dating=$2
for a in $(cat sensors-in-test)
do do
if grep "^[0-9]* : $a " $1 > /dev/null if grep "^[0-9]* : $a " $1 > /dev/null
then then
### Rx Time ### Rx Time
grep "^[0-9]* : $a " $1 | cut -d ' ' -f1,4 | sort -uh > $a.rxt grep "^[0-9]* : $a " $1 | cut -d ' ' -f1,4 | sort -uh > $a.rxt
### Cycles timestamps ### Cycles timestamps
echo "'^[0-9]* : [0-9]* ' $1 $a" | xargs ./Cycles.sh > $a.cyl echo "'^[0-9]* : [0-9]* ' $1 $a" | xargs ./Cycles.sh > $a.cyl
## Network trace ## Network trace
echo "'^[0-9]* : $a (66|68|71|81) ' $1 " |xargs ./Rx.sh > $a.tx echo "'^[0-9]* : $a (66|68|71|81) ' $1 $dating " |xargs ./Rx.sh > $a.rx
i=$(($i+1))
## All data contains volts info ## All data contains volts info
echo "'^[0-9]* : $a 6[68]' $1" |xargs ./Volts.sh > $a.vlt echo "'^[0-9]* : $a 6[68]' $1 $dating" |xargs ./Volts.sh > $a.vlt
## Case for energest data ## Case for energest data
echo "'^[0-9]* : $a [78]1' $1" |xargs ./Energest.sh > $a.nrg echo "'^[0-9]* : $a [78]1' $1 $dating" |xargs ./Energest.sh > $a.nrg
## UIP and RPL stats ## UIP and RPL stats
echo "'^[0-9]* : $a 83' $1" |xargs ./UipRpl.sh > $a.uip echo "'^[0-9]* : $a 83' $1 $dating" |xargs ./UipRpl.sh > $a.uip
## Analysis of each sensor ## Analysis of each sensor
## 2 0 : dht22 ## 2 0 : dht22
if grep -E "^[0-9]* : $a 6[68] ([0-9]+ ){20}2 0" $1 > /dev/null if grep -E "^[0-9]* : $a 6[68] ([0-9]+ ){20}2 0" $1 > /dev/null
then then
echo "'^[0-9]* : $a 6[68]' $1" |xargs ./TempDht22.sh > $a.dht22 echo "'^[0-9]* : $a 6[68]' $1" |xargs ./TempDht22.sh > $a.dht22
fi fi
## 3 0 Analog light sensor ## 3 0 Analog light sensor
if grep -E "^[0-9]* : $a 6[68] ([0-9]+ ){12}3 0" $1 > /dev/null if grep -E "^[0-9]* : $a 6[68] ([0-9]+ ){20}3 0" $1 > /dev/null
then then
echo "'^[0-9]* : $a 6[68]' $1" |xargs ./LightA.sh > $a.lux echo "'^[0-9]* : $a 6[68]' $1" |xargs ./LightA.sh > $a.lux
fi fi
...@@ -81,7 +91,9 @@ then ...@@ -81,7 +91,9 @@ then
uipfiles=$(echo $uipfiles | sed s/' '/'"'' using 1:12','"'/g) uipfiles=$(echo $uipfiles | sed s/' '/'"'' using 1:12','"'/g)
uipfiles="\"$uipfiles\" using 1:12" uipfiles="\"$uipfiles\" using 1:12"
uiprpl="$uiprpl, $uipfiles" uiprpl="$uiprpl, $uipfiles"
gnuplot <<EOF if [ $dating ]
then
gnuplot <<EOF
set terminal png size 1200,800 set terminal png size 1200,800
set output "uiprpl.png" set output "uiprpl.png"
set xdata time set xdata time
...@@ -93,6 +105,17 @@ set ylabel "Number" ...@@ -93,6 +105,17 @@ set ylabel "Number"
set title "UIP and RPL stats" set title "UIP and RPL stats"
plot $uiprpl plot $uiprpl
EOF EOF
else
gnuplot <<EOF
set terminal png size 1200,800
set output "uiprpl.png"
set grid
set xlabel "Temps"
set ylabel "Number"
set title "UIP and RPL stats"
plot $uiprpl
EOF
fi
eog uiprpl.png eog uiprpl.png
fi fi
...@@ -120,8 +143,9 @@ if ls *.vlt &> /dev/null ...@@ -120,8 +143,9 @@ if ls *.vlt &> /dev/null
voltsfiles=$(ls *.vlt) voltsfiles=$(ls *.vlt)
voltsfiles=$(echo $voltsfiles | sed s/' '/'"'' using 1:2 with lines','"'/g) voltsfiles=$(echo $voltsfiles | sed s/' '/'"'' using 1:2 with lines','"'/g)
voltsfiles="\"$voltsfiles\" using 1:2 with lines" voltsfiles="\"$voltsfiles\" using 1:2 with lines"
if [ $dating ]
gnuplot <<EOF then
gnuplot <<EOF
set terminal png size 1200,800 set terminal png size 1200,800
set output "volts.png" set output "volts.png"
set xdata time set xdata time
...@@ -133,17 +157,29 @@ set ylabel "Volts" ...@@ -133,17 +157,29 @@ set ylabel "Volts"
set title "Voltage" set title "Voltage"
plot $voltsfiles plot $voltsfiles
EOF EOF
else
gnuplot <<EOF
set terminal png size 1200,800
set output "volts.png"
set grid
set xlabel "Temps"
set ylabel "Volts"
set title "Voltage"
plot $voltsfiles
EOF
fi
eog volts.png& eog volts.png&
fi fi
## Plotting Tx time ## Plotting Rx time
if ls *.tx &> /dev/null if ls *.rx &> /dev/null
then then
txfiles=$(ls *.tx) txfiles=$(ls *.rx)
txfiles=$(echo $txfiles | sed s/' '/'"'' using 1:2','"'/g) txfiles=$(echo $txfiles | sed s/' '/'"'' using 1:2','"'/g)
txfiles="\"$txfiles\" using 1:2" txfiles="\"$txfiles\" using 1:2"
if [ $dating ]
gnuplot <<EOF then
gnuplot <<EOF
set terminal png size 1200,800 set terminal png size 1200,800
set output "tx.png" set output "tx.png"
set xdata time set xdata time
...@@ -155,6 +191,17 @@ set ylabel "sec" ...@@ -155,6 +191,17 @@ set ylabel "sec"
set title "Temps accès réseau" set title "Temps accès réseau"
plot $txfiles plot $txfiles
EOF EOF
else
gnuplot <<EOF
set terminal png size 1200,800
set output "tx.png"
set grid
set xlabel "Temps"
set ylabel "sec"
set title "Temps accès réseau"
plot $txfiles
EOF
fi
eog tx.png& eog tx.png&
fi fi
...@@ -165,8 +212,9 @@ then ...@@ -165,8 +212,9 @@ then
nrgfiles=$(ls *.nrg) nrgfiles=$(ls *.nrg)
nrgfiles=$(echo $nrgfiles | sed s/' '/'"'' using 1:2 with lines','"'/g) nrgfiles=$(echo $nrgfiles | sed s/' '/'"'' using 1:2 with lines','"'/g)
nrgfiles="\"$nrgfiles\" using 1:2 with lines" nrgfiles="\"$nrgfiles\" using 1:2 with lines"
if [ $dating ]
gnuplot <<EOF then
gnuplot <<EOF
set terminal png size 1200,800 set terminal png size 1200,800
set output "energy.png" set output "energy.png"
set xdata time set xdata time
...@@ -178,6 +226,17 @@ set ylabel "mA" ...@@ -178,6 +226,17 @@ set ylabel "mA"
set title "Energy" set title "Energy"
plot $nrgfiles plot $nrgfiles
EOF EOF
else
gnuplot <<EOF
set terminal png size 1200,800
set output "energy.png"
set grid
set xlabel "Temps"
set ylabel "mA"
set title "Energy"
plot $nrgfiles
EOF
fi
eog energy.png& eog energy.png&
fi fi
...@@ -204,23 +263,42 @@ fi ...@@ -204,23 +263,42 @@ fi
## Plotting Temperature ## Plotting Temperature
if ls *.dht22 &> /dev/null if ls *.dht22 &> /dev/null
then then
tempfiles=$(ls *.dht22) tmphmd=""
tempfiles=$(echo $tempfiles | sed s/' '/'"'' using 1:2 with lines','"'/g) dhtfiles=$(ls *.dht22)
tempfiles="\"$tempfiles\" using 1:2 with lines" dhtfiles=$(echo $dhtfiles | sed s/' '/'"'' using 1:2 with lines','"'/g)
dhtfiles="\"$dhtfiles\" using 1:2 with lines"
tmphmd="$dhtfiles"
dhtfiles=$(ls *.dht22)
dhtfiles=$(echo $dhtfiles | sed s/' '/'"'' using 1:3 with lines','"'/g)
dhtfiles="\"$dhtfiles\" using 1:3 with lines"
tmphmd="$tmphmd, $dhtfiles"
gnuplot <<EOF if [ $dating ]
then
gnuplot <<EOF
set terminal png size 1200,800 set terminal png size 1200,800
set output "temperatures.png" set output "temp-hmd.png"
set xdata time set xdata time
set timefmt "%m/%d/%y:%H:%M:%S" set timefmt "%m/%d/%y:%H:%M:%S"
set format x "%m-%d\n%H:%M" set format x "%m-%d\n%H:%M"
set grid set grid
set xlabel "Temps" set xlabel "Temps"
set ylabel "Temp" set ylabel "%"
set title "Temperature" set title "Temperature and humidity"
plot $tempfiles plot $tmphmd
EOF
else
gnuplot <<EOF
set terminal png size 1200,800
set output "temp-hmd.png"
set grid
set xlabel "Temps"
set ylabel "%"
set title "Temperature and humidity"
plot $tmphmd
EOF EOF
eog temperatures.png& fi
eog temp-hmd.png&
fi fi
## Plotting light ## Plotting light
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment