#!/bin/sh
UsbActiv()
{
while [ 1 ]; do
# data in /proc/diskstats for drive / partition changed ?
ActStat=$(grep $1 /proc/diskstats)
if [ "$ActStat" != "$OldStat" ]; then
# flash Info-LED
echo "SET info,2 = 10" >/dev/new_led
OldStat=$ActStat
fi
sleep 1
done
}
if [ ! $1 ]; then
echo no device given
return
fi
UsbActiv $1
#!/bin/sh
UsbActiv()
{
echo "SCRIPT STARTED"
echo "SET info,0 = 0" >/dev/new_led
while [ 1 ]; do
# data in /proc/diskstats for drive / partition changed ?
ActStat=$(grep $1 /proc/diskstats)
echo "READING STATUS = $ActStat"
echo "OldStatus= $OldStat"
if [ "$ActStat" != "$OldStat" ]; then
echo "STATUS CHANGED"
echo "SET info,0 = 13" >/dev/new_led
OldStat=$ActStat
else
#echo "SET info,1 = 1" >/dev/new_led
echo "STATUS NOT CHANGED"
fi
sleep 1
done
}
if [ ! $1 ]; then
echo no device given
return
fi
UsbActiv $1
Great!hrust_ray schrieb:Now it works finally!
It looks like you have a lot off LED's... On my box (7170v2) power,0, internet,0, ab,1, wlan,0 and info,0 works. An other way could be to use different flash-time for reading / writing (info,0 = 13 / info,0 = 15). And you must spend more "code" to find differences in read and write counter. As I know, BusyBox-sh does not know arrays. If you realy want do this: One way would be to do it with sed:hrust_ray schrieb:Is it possible to use one led to show Reading process, and some other - for writing? I
ReadVal=$(echo $ActStat | sed -n "s/^.*sda1.\([0-9]*\).[0-9]*.\([0-9]*\).[0-9]*.*$/\1/p")
WriteVal=$(echo $ActStat | sed -n "s/^.*sda1.\([0-9]*\).[0-9]*.\([0-9]*\).[0-9]*.*$/\2/p")
PartName=$1 # save partition-name, is destoyed by set --
set -- $(grep /proc/diskstats | grep $PartName)