asus-wireless.sh wants to switch led on even if no wifi card is present

Bug #38354 reported by Nicolò Chieffo
22
Affects Status Importance Assigned to Milestone
acpi-support (Ubuntu)
Invalid
Medium
Unassigned

Bug Description

look at wireless.sh, it echos a 0 if the card is off, a 1 if it's on, and nothing if no card is present.

asus-wireless.sh should do so:

state=`. /etc/acpi/wireless.sh`

if [ "$state" = "1" ]; then
      echo -n 1 > /proc/acpi/asus/wled
else
      echo -n 0 > /proc/acpi/asus/wled
fi

now 1 and 0 are inverted, but it's wrong!

Revision history for this message
Nicolò Chieffo (yelo3) wrote :

Excuse me, did you receive the request?? This is a easily fixable bug, but it's still there!

Revision history for this message
Nicolò Chieffo (yelo3) wrote :

the correct script can be found in this bug:

https://launchpad.net/malone/43061

Revision history for this message
Paul Sladen (sladen) wrote :

Can you comment how this relates to bug #22795, that attempts to synchronise the LED on bootup and resume.

Is the bug you're reporting with the change-of-state script (toggled by the hotkey), or that it gives the wrong with no wireless card installed.

The current code is in:

   /etc/acpi/start.d/60-asus-wireless-led.sh

and also in 'resume.d'.

Changed in acpi-support:
status: Unconfirmed → Needs Info
Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 38354] Re: asus-wireless.sh wants to switch led on even if no wifi card is present

dear paul the bug is related simply because I tried to make a new
script which is aware of everything I noticed not working properly
(code duplication, wireless led on if module is unloaded, state not
saved after a reboot, ipw2200 crashing if switched off using
power/state)

Well, this happens, now I'm in a hurry and I can't lolok further in
that script: if you remove ipw2200 moduleand hit the wireless hotkey,
the led gets switches on! this also happens then you boot without the
module!

I'll give you further info when I'll be back home

Revision history for this message
Nicolò Chieffo (yelo3) wrote :

in edgy there is the same problem.
I will attach the new asus-wireless.sh and II re explain the problem:

If no wireless card is present (yes I've removed it from my laptop) the script called to determinate the state will return an empty string.
In this case the current script does a check on the returned string and it disables the led only if it's "0". since the returnet string is "" the led is enabled.
the error is that the led must be enabled only if the returned string contains "1" and not "everything but 0".
To tell the truth the real error is done in /etc/acpi/wireless.sh... note that this script will echo something strange if a user has more than one wireless card:
"11" if he has two devices enabled. In my opinion that script (/etc/acpi/wireless.sh) should be rewritten, but a simple solution is using the one attached (/etc/acpi/asus-wireless.sh)

Revision history for this message
Nicolò Chieffo (yelo3) wrote :

I don't know if this script will be removed since the old method used in wireless.sh to deactivate the wlan card is deprecated in linux-2.6.20
should this bug be rejected?

Revision history for this message
Nicolò Chieffo (yelo3) wrote :

Paul Sladen:
this bug is not related to the one you'we reported. That bug corrected the fact that the led wasn't synchronized after the boot. This bug only want to point out that there are errors in

/etc/acpi/asus-wireless.sh is buggy and moreover should use the new functions written in
/usr/share/acpi-support/state-funcs
it should look like this:

### START ###
#!/bin/bash
# Find and enable/disable wireless devices

. /usr/share/acpi-support/state-funcs
/etc/acpi/start.d/60-asus-wireless-led.sh

/etc/acpi/wireless.sh
if isAnyWirelessPoweredOn ; then
    setLEDAsusWireless 1
else
    setLEDAsusWireless 0
fi
### END ###

or, better to say, a new function called "syncLEDAsusWireless" should be added in /usr/share/acpi-support/state-funcs so that every acpi script use it (such as /etc/acpi/start.d/60-asus-wireless-led.sh and the one in resume.d) and there will be less code duplication

to tell the truth, as we can see in bug https://launchpad.net/bugs/66083 even the function isAnyWirelessPoweredOn is wrong, but it can be fixed easily.

So the things to be done are:
-) fix bug https://launchpad.net/bugs/66083 (there is already a fix described in the bugreport)
-) add a function syncLEDAsusWireless to /usr/share/acpi-support/state-funcs (will attach it)
-) rewrite /etc/acpi/asus-wireless.sh (will attach it)
-) rewrite /etc/acpi/start.d/60-asus-wireless-led.sh (will attach it)
-) rewrite /etc/acpi/resume.d/60-asus-wireless-led.sh (will attach it)

They are all very easy things to do, fortunately!

Revision history for this message
Nicolò Chieffo (yelo3) wrote :

I've pasted wrong in the previous commend.
delete the line /etc/acpi/start.d/60-asus-wireless-led.sh in the script. Better to look at the attachment!

Revision history for this message
Nicolò Chieffo (yelo3) wrote :
Revision history for this message
Nicolò Chieffo (yelo3) wrote :

this file also contains the fix of bug https://launchpad.net/bugs/66083

Revision history for this message
Nicolò Chieffo (yelo3) wrote :
Revision history for this message
Nicolò Chieffo (yelo3) wrote :

or if you prefer diffs

Revision history for this message
Nicolò Chieffo (yelo3) wrote :
Revision history for this message
Nicolò Chieffo (yelo3) wrote :
Revision history for this message
Nicolò Chieffo (yelo3) wrote :

rejecting because this bug had become too messy. I'm opening a new one more clear.

Changed in acpi-support:
status: Needs Info → Rejected
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.