psieg / Lightpack

Lightpack and Prismatik open repository
GNU General Public License v3.0
1.57k stars 188 forks source link

Adalight device - Do not turn off on SLEEP since 5.11.2.22. #366

Open nhadrian opened 4 years ago

nhadrian commented 4 years ago

Since version 5.11.2.22, when I put my PC into sleep mode, Adalight compadible (arduino based) light keeps lighting. If I revert back to 5.11.2.19, it works OK.

Windows 10 64 bit

psieg commented 4 years ago

The release numbers suggest it could be #310. I think when turning off Prismatik sends several frames, maybe some are dropped.

Is there a mention of "skipping current frame" in your logs when you set the debug level to 2? @zomfg FYI - we might need a special signal for "forced turn off" that can't be skipped?

zomfg commented 4 years ago

Hmmm that would mean that a frame is sent after the OFF frame, replacing it in "last will", no? if the OFF frame is queued in last, leddevice::close() should write it out, unless that gets skipped on shutdown? yeah that needs a look...

psieg commented 4 years ago

I don't think the device is closed on sleep, so my guess is that the black frame is skipped and no last will written.

zomfg commented 4 years ago

that would mean that another normal frame comes after the black one, some race condition maybe? anyway, level 2 log would help

2237montala commented 4 years ago

I wanted to upload a debug log for this issue. I believe I'm having the same issue as nhadrain described. I updated to the latest version after a few years of no updates. When I put my computer to sleep the LEDs don't turn off. I have the option disabled to keep the light on after sleep. Let me know if this is helpful or if you need anything else

Attached is a log file of turning on the lights, going to sleep, waking from sleep, and turning off the lights at log level 2 Prismatik.0.log

psieg commented 4 years ago

Are the lights flashing when you suspend? The logs show this:

...
14:51:21:870 Debug: bool __cdecl SystemSession::WindowsEventFilter::nativeEventFilter(const class QByteArray &,void *,long *) System is going to sleep
14:51:21:870 Debug: class QVariant __cdecl SettingsScope::Settings::valueMain(const class QString &) "IsKeepLightsOnAfterSuspend" =  QVariant(QString, "false")
14:51:21:870 Debug: void __cdecl LedDeviceManager::switchOffLeds(void) Is last command completed: true
14:51:21:870 Debug: bool __cdecl LedDeviceAdalight::writeBuffer(const class QByteArray &) Hex: "416461006732000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
14:51:21:871 Debug: bool __cdecl SystemSession::WindowsEventFilter::nativeEventFilter(const class QByteArray &,void *,long *) System is going to sleep
14:51:21:871 Debug: class QVariant __cdecl SettingsScope::Settings::valueMain(const class QString &) "IsKeepLightsOnAfterSuspend" =  QVariant(QString, "false")
14:51:21:871 Debug: void __cdecl LedDeviceManager::switchOffLeds(void) Is last command completed: true
14:51:21:871 Debug: bool __cdecl LedDeviceAdalight::writeBuffer(const class QByteArray &) Hex: "416461006732000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
14:51:21:871 Debug: bool __cdecl LedDeviceAdalight::writeBuffer(const class QByteArray &) Serial bytesToWrite: 318 , skipping current frame
...
14:51:21:972 Debug: void __cdecl LedDeviceAdalight::writeLastWill(const bool) Writing last will frame
14:51:21:972 Debug: bool __cdecl LedDeviceAdalight::writeBuffer(const class QByteArray &) Hex: "416461006732060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402060402"
...

So it does write black once, then a second time (which is skipped), and finally writes colors again.

It seems something is resetting m_colorsSaved in between. It seems the mood lamp keeps sending updates after the standby signal. It looks like this line didn't prevent new colors from being written: https://github.com/psieg/Lightpack/blob/b13dec9cf8e42d137e8569b4ebca0f8eb3d51a15/Software/src/LedDeviceManager.cpp#L126

Could you do another log at level 3 please?

zomfg commented 4 years ago

would be good to retest with #386

Janoo1606 commented 3 years ago

I have the same problem. After my computer shuts down, the leds do not turn off. Is there already a fixed version? Or how can I replace the attached files ( #386 ) in my installation?

p-himik commented 3 years ago

Still a problem on 5.11.2.28 on Ubuntu. Also have the skipping current frame lines in the logs.

I ended up creating a systemd service that turns the lights off on suspend/shutdown and another one that turns them on on waking up.