openbmc / phosphor-led-sysfs

Application to manage BMC-owned LEDs using Linux sysfs interfaces
Apache License 2.0
3 stars 6 forks source link

Unable to switch off LED if it's in blink state on led controller start #2

Closed Kitsok closed 9 months ago

Kitsok commented 2 years ago

Hi all!

If LED blinks when led controller is starting (timer in /sys/class/led/.../trigger), its' state is not set correctly in D-Bus. This leads to inability to switch it off directly without prior switching on. It's caused by following if block inPhysical::driveLED function physical.cpp :

void Physical::driveLED(Action current, Action request)
{
    if (current == request)
    {   
        return;
    }

To fix this I've added set of state in "trigger" branch of setInitialState():

diff --git a/physical.cpp b/physical.cpp
index f4ef8a1..6767d73 100644
--- a/physical.cpp
+++ b/physical.cpp
@@ -38,6 +38,8 @@ void Physical::setInitialState()
         auto percentScale = periodMs / 100;
         this->dutyOn(delayOn / percentScale);
         this->period(periodMs);
+        sdbusplus::xyz::openbmc_project::Led::server::Physical::state(
+                Action::Blink);
     }
     else
     {
amboar commented 2 years ago

Thanks, I'll look at getting a patch merged to fix it.

lxwinspur commented 9 months ago

@amboar @Kitsok Fixed in https://github.com/openbmc/phosphor-led-sysfs/commit/001e2a3daddc8b06de9356aa0b4f08244e66a4bf#diff-e6b01ccef09208403be631419c06a3a118dba0cb3cd6e0c35e3bee59043e6f8dR41-R42

Could you please close this issue?