-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monitor randomly responds with 0 to get_*()-command and/or fails set_*()-command #288
Comments
This looks a lot like what happens if the VCP timeout is set too low in Linux, but Windows does not expose this control. I booted into Windows 10 and tried this on my own system (Acer XF270HU, 4090, displayport) and was unable to reproduce it after running the script for 10 minutes. You could try it on Linux to see if it responds differently. This would narrow it down to a hardware or software problem, but booting into Linux is a pain to do if you're not already dual booting. I sadly don't have a lot of experience with debugging Windows APIs and I'm not sure if there are any tools available to see the data on the bus. |
Thanks for looking into this. I assume I could boot a live distro and set up Python, but in the end, we still couldn't fix it even if it was the timeout. I have to admit, I'm not overly motivated to go down that route :/ Essentially, my main problem is not that monitorcontrol crashes during Could you somehow check, why there is no error reported in case Let me know if I can help with any more logs or stuff. |
There is a CRC in Linux, I double checked the Windows code, and sure enough, I misunderstood the python interface to the Windows APIs. I thought the return status bools automatically got turned into I made a branch windows-oops, I tried to wrangle my monitors to get a negative status but was unsuccessful, are you able to test that and let me know what happens on your setup? With |
Yep, definitely different. No
This affects both, |
Hmm that seems like another issue, but the only inputs to
I must have missed that line in the ctypes docs :( I pushed another commit to fix that second exception. Can you try again? Also, with this fix does it now "work" for you, in that you can catch the exception and retry? |
Updated the package and ran again. The error now looks like this:
Using It looks a bit odd to me that the error still is about an "invalid value in its command field". I would intuitively expect something different in case of a timeout, but I'm also 100% not familiar with low-level windows VCP code 😄 |
Yeah, it looks odd to me too 🤔 |
I made a release with the current "fix": https://github.com/newAM/monitorcontrol/releases/tag/3.1.0 Feel free to reopen the issue anytime :) |
@XDA-Bam I had a similar or same(?) issue. The workaround for me is to retry until it works again. The application code part looks as follows: try:
def _set():
monitor.set_luminance(value)
logger.info(f"Set brightness value {value} on monitor#{i}")
_set()
except VCPError as e:
logger.exception(e)
time.sleep(5)
_set() |
@gabortim Thanks for posting. Yes, I implemented a workaround, too. Currently using retry2-package, which seemed like a clean solution to me: from retry import retry
retry_delay = 0.25
retry_count = 10
@retry(delay=retry_delay, tries=retry_count)
def get_brightness(monitor):
brightness = monitor.get_luminance()
if brightness > 100 or brightness < 0:
raise ValueError('Reported brightness value outside of valid range [0, 100].')
return brightness I should probably define an additional error in case the code ever happens to fail after 10 tries, but for my tiny project, it doesn't really matter (and I never saw it reach that threshold). |
HP Omen 27u
DP (different cables and both DP ports on the GPU tested)
Discrete Radeon 6800 (at least two different driver versions tested)
Win 10 Pro 64 bit
3.12.0 (also tested 3.11.3)
monitorcontrol --version
):3.0.3
Steps to Reproduce
Create a very basic Python script, which asks for monitor brightness and contrast and then tries to set the reported value for brightness (contrast ignored for now):
The script works erratically. Almost always, the first reported contrast value is
0
, while the first reported brightness is correct. Sometimes, brightness is reported as0
later on. If that is the case, the screen brightness is accordingly set to0
in the following step, in casemonitor.set_luminance()
does not crash. If the script does crash, it is always atmonitor.set_luminance()
with the reported error that whatever brightness was defined is larger than the maximum allowed value of0
(?).Crashes occur with roughly 20% probability. A typical run of the script looks like this:
The text was updated successfully, but these errors were encountered: