INFO LED bei USB DataTransfer?

hrust_ray

Neuer User
Mitglied seit
11 Jan 2007
Beiträge
133
Punkte für Reaktionen
0
Punkte
0
Hello.
I have USB-stick without led. So I cannot see if data is transferring or not at current moment. Is it possible to use INFO-LED blinking while datatransferring to USB?
 
Hello hrust_ray,

in /proc/diskstats you see some data that show access statistics for drives. If you have only one usb-stick, with one partition, you see at the end of the "file" something like:

8 0 sda 646 2237 2890 224260 261 110 371 141230 0 16280 365490
8 1 sda1 2882 2882 371 371

(sda ist the first usb drive, sda1 the first partition on it). The numbers after sda1 shows read/write counts for the first partition. You can create a litte script or program, that switch on Info-LED when Data changed, and switch it off when data was not changed. Something like:

Code:
#!/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

I'm not so familiar in creating scripts, a better way would be to use "sed" instead of "grep", but I don't know the correct syntax. You must call the script, giving the wanted partition p.E. "./UsbActiv sda1". On problem of scripts was the shortest pause ist 1 sec (sleep 1), so there was a delay. If you test the script, you will also see, that many accesses are not displayed. This was because off caching.

Best regards,

Reiner Mueller
 
Zuletzt bearbeitet:
Thnx.
Unfotunately on my FB7141 I cannot controll leds by "echo 7,1>/var/led"
From terminal I tried different values - no result :(
 
Hello,

I found in forum that there are some problems with LED's on 7141. I looked to source code and found another syntax, there is also a flash option, so you need not reset led:

echo "SET info,2 = 10" >/dev/new_led.

",2" ist the instance, on my box ist can be 0 .. 4. Different flash time with = 8...11. I'll change it in script above.

Best regards, Reiner
 
Zuletzt bearbeitet:
Thanx!!! :groesste:
Now it works finally!
7141 is very strange thing, concerning LEDs behavior.
I found that it works only if first I switch off INFOled (SET info,0 = 0). After this on each partition changing i make (SET info,0 = 13)
Parameter 13 works exactly like it is necessary - shitches led of for half second and the switches it on. So, if no changes were don on partition - led stays switched on till next changes :)
Is it possible to use one led to show Reading process, and some other - for writing? I tried to use (SET wlan,0 = 0) - not works


My code looks like:
Code:
#!/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
 
hrust_ray schrieb:
Now it works finally!
Great!
hrust_ray schrieb:
Is it possible to use one led to show Reading process, and some other - for writing? I
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:
Code:
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")
OK, Busybox knows one array: $* so you can set "new parameter" with
Code:
PartName=$1  # save partition-name, is destoyed by set --
set -- $(grep /proc/diskstats | grep $PartName)
, after this $4 should be ReadVal, $6 should be WriteVal...

Best regards, Reiner
 
Zuletzt bearbeitet:
Holen Sie sich 3CX - völlig kostenlos!
Verbinden Sie Ihr Team und Ihre Kunden Telefonie Livechat Videokonferenzen

Gehostet oder selbst-verwaltet. Für bis zu 10 Nutzer dauerhaft kostenlos. Keine Kreditkartendetails erforderlich. Ohne Risiko testen.

3CX
Für diese E-Mail-Adresse besteht bereits ein 3CX-Konto. Sie werden zum Kundenportal weitergeleitet, wo Sie sich anmelden oder Ihr Passwort zurücksetzen können, falls Sie dieses vergessen haben.