Comments (22)
Bypassing only checksum won't work as most probably remaining code will fail as well. I saw this already - not only checksum was incorrect but expected data was too short thus unpacking failed and it was not caught.
For my application it would be better to pass some argument during runtime down to vcp to bypass checksum and following operations and try to recover and/or use some predefined default values i.e. I have config file in which I can specify e.g. which bus number should have it bypassed and remaining one(s) should not.
As I have physical access to this monitor I can prototype and propose something. What do you think?
from monitorcontrol.
I have seen this behavior once before on a different monitor, what helped for that was increasing the timeout beyond the DDC-CI minimum values.
Can you try increasing these constants to see if it changes the behavior?
monitorcontrol.vcp.vcp_linux.LinuxVCP.GET_VCP_TIMEOUT = 0.2 # default 0.04
monitorcontrol.vcp.vcp_linux.LinuxVCP.CMD_RATE = 0.2 # default 0.05
from monitorcontrol.
Unfortunately, it does not help:
File "/root/.local/lib/python3.7/site-packages/monitorcontrol/vcp/vcp_linux.py", line 178, in get_vcp_feature
raise VCPIOError(f"checksum does not match: {checksum_xor}")
monitorcontrol.vcp.vcp_abc.VCPIOError: checksum does not match: 80
from monitorcontrol.
Huh, interesting! This is the first monitor that I have heard of that violates the spec then.
I would like to keep the exceptions as the default behavior since they usually mean that the rest of the command will fail.
These exceptions are buried rather deep as you noted. I would like to ideally add some way for the user to handle the exceptions better, but I don't see an elegant way forward with that.
I am thinking of a static class variable to disable exceptions; something along the lines of:
monitorcontrol.vcp.vcp_linux.LinuxVCP.BYPASS_CHECKSUM: bool = True
# and others for the various locations where VCPIOError can be raised
Would that work for your application?
from monitorcontrol.
As I have physical access to this monitor I can prototype and propose something. What do you think?
That would be great!
from monitorcontrol.
I have latest Arch Linux, ddcutil works great, but I would like to use Python implementation, because I plan gui and small hw which will be set backlight value from ambient light (I finished HW, next part is SW in Python). But unfortunately latest monitorcontrol said:
monitorcontrol --get-luminance
Traceback (most recent call last):
File "/usr/bin/monitorcontrol", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.8/site-packages/monitorcontrol/__main__.py", line 70, in main
luminance = monitor.get_luminance()
File "/usr/lib/python3.8/site-packages/monitorcontrol/monitorcontrol.py", line 180, in get_luminance
return self._get_vcp_feature(code)
File "/usr/lib/python3.8/site-packages/monitorcontrol/monitorcontrol.py", line 157, in _get_vcp_feature
current, maximum = self.vcp.get_vcp_feature(code.value)
File "/usr/lib/python3.8/site-packages/monitorcontrol/vcp/vcp_linux.py", line 178, in get_vcp_feature
raise VCPIOError(f"checksum does not match: {checksum_xor}")
monitorcontrol.vcp.vcp_abc.VCPIOError: checksum does not match: 115
But the problem is not in monitor (it is HPE243i), because on Windows
monitorcontrol is working great :).
On Arch Linux I followed this https://monitorcontrol.readthedocs.io/en/latest/linux_setup.html and it is working for ddcutil too, but for monitorcontrol there is checksum bug.
from monitorcontrol.
...huh, if two people have this issue then this likely is a bug.
I'll add something this weekend to optionally disable the checksum.
@jiri-one does you monitor also work aside from the bad checksum?
from monitorcontrol.
On Win10 I tested only get and set luminance and it worked great. But on Archlinux everything ended with bad checksum.
from monitorcontrol.
I also always get the VCPIOError which says: checksum does not match: 80, but I didn't get the display run on my Ubuntu properly with other tools while it works perfect on macOS with ddcutil.
There may also be a driver issue.
from monitorcontrol.
I pushed a 2.2.0 release which disables the checksums by default.
https://monitorcontrol.readthedocs.io/en/latest/api.html#checksum-behaviour
This does not fully address this issue since there were also problems with the payload unpacking mentioned here.
Let me know if this solves any of the problems you guys are having (or what new problems you now have).
from monitorcontrol.
I tested new version on Archlinux and it is not working.
https://pastebin.com/xNYnmCP1
And the last version is working nice on Windows .... with same monitor.
from monitorcontrol.
from monitorcontrol.
@newAM Maybe you want to make some tests on my monitor? If you contact me directly on email jiri spot one in domain pm spot me (I hope I confused the spambots enough :)) then I can redirect some port on my router to my ArchLinux PC, and you can connect to it over SSH. Just if you want, it is just idea.
from monitorcontrol.
Thanks for the offer @jiri-one , I may take you up on that pending the results of this next iteration.
I made another release, 2.3.0 with debug logging in the VCP class (and a --verbose
argument to the CLI). This will not fix the exception, but it will give clues as to what is going on.
From the CLI can one of you repeat this with the new version (pip install -U monitorcontrol
to upgrade)?
$ monitorcontrol -vvvv --get-luminance
DEBUG monitorcontrol.vcp.vcp_linux header=b'n\x88'
DEBUG monitorcontrol.vcp.vcp_linux payload=b'\x02\x00\x10\x00\x00d\x00d\xa4'
100
Yours should look similar but with the exception instead of 100
.
The byte values of the header and the payload will help a lot to compare with the spec.
from monitorcontrol.
Hi, sorry for my delay, but covid shot me. Here is output:
monitorcontrol -vvvv --get-luminance
DEBUG monitorcontrol.vcp.vcp_linux header=b'\x08\x08'
DEBUG monitorcontrol.vcp.vcp_linux payload=b'\x08\x08\x08\x08\x08\x08\x08\x08\x08'
Traceback (most recent call last):
File "/usr/bin/monitorcontrol", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.8/site-packages/monitorcontrol/__main__.py", line 101, in main
luminance = monitor.get_luminance()
File "/usr/lib/python3.8/site-packages/monitorcontrol/monitorcontrol.py", line 180, in get_luminance
return self._get_vcp_feature(code)
File "/usr/lib/python3.8/site-packages/monitorcontrol/monitorcontrol.py", line 157, in _get_vcp_feature
current, maximum = self.vcp.get_vcp_feature(code.value)
File "/usr/lib/python3.8/site-packages/monitorcontrol/vcp/vcp_linux.py", line 202, in get_vcp_feature
raise VCPIOError(
monitorcontrol.vcp.vcp_abc.VCPIOError: received unexpected response code: 8
from monitorcontrol.
Hi, sorry for my delay, but covid shot me.
No worries, hope you are doing well now!
monitorcontrol -vvvv --get-luminance
DEBUG monitorcontrol.vcp.vcp_linux header=b'\x08\x08'
DEBUG monitorcontrol.vcp.vcp_linux payload=b'\x08\x08\x08\x08\x08\x08\x08\x08\x08'
Well, I am not sure what I expected, but it definitely wasn't that.
I will take you up on your offer to SSH into your box if that is still open - this will require some trial and error to get to the bottom of, I sent you an email with my public SSH key.
from monitorcontrol.
I got access to a failing monitor (thanks @jiri-one !) a while ago.
I think I found the root cause of this issue in the way the DDC packets were being constructed.
Using Jiri's monitor with monitorcontrol -vvvvv --get-luminance
, to generate a payload of 51 82 01 10
it would only work if I hard coded the CRC to AC
.
monitorcontrol
calculated the CRC as C2
though, which checks out.
>>> hex(0x51 ^ 0x82 ^ 0x01 ^ 0x10)
'0xc2'
The difference between C2
and AC
is 6E
:
>>> hex(0xC2 ^ 0xAC)
'0x6e'
Now there's a familiar number from the DDC spec!
Sure enough, shift it by one, and you get the DDC-CI command address:
>>> hex(0x6E >> 1)
'0x37'
Now that's where the problems start occurring, the address is set in the VCP constructor with ioctl
, and then the CRC is calculated like so:
# transmission data
data = bytearray()
data.append(self.GET_VCP_CMD)
data.append(code)
# add headers and footers
data.insert(0, (len(data) | self.PROTOCOL_FLAG))
data.insert(0, self.HOST_ADDRESS)
data.append(self.get_checksum(data))
get_checksum
doesn't take into account the address in the CRC calculation.
The correct checksum is calculated if I just prepend the command address to the CRC.
# transmission data
data = bytearray()
data.append(self.GET_VCP_CMD)
data.append(code)
# add headers and footers
data.insert(0, (len(data) | self.PROTOCOL_FLAG))
data.insert(0, self.HOST_ADDRESS)
data.append(
self.get_checksum(bytearray([self.DDCCI_ADDR << 1]) + data)
)
Anyway, a pull-request is here to fix this: #20
Let me know if it fixes anything for you guys.
Also turns out my monitors are just ignoring invalid CRC, which explains why I couldn't reproduce this
from monitorcontrol.
Not a problem newAM and note, your access to my PC is still on, so if you need some more tests, it is not a problem ... because:
This is version from git:
./monitorcontrol --get-luminance
Traceback (most recent call last):
File "./monitorcontrol", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.8/site-packages/monitorcontrol/__main__.py", line 101, in main
luminance = monitor.get_luminance()
File "/usr/lib/python3.8/site-packages/monitorcontrol/monitorcontrol.py", line 180, in get_luminance
return self._get_vcp_feature(code)
File "/usr/lib/python3.8/site-packages/monitorcontrol/monitorcontrol.py", line 157, in _get_vcp_feature
current, maximum = self.vcp.get_vcp_feature(code.value)
File "/usr/lib/python3.8/site-packages/monitorcontrol/vcp/vcp_linux.py", line 186, in get_vcp_feature
raise VCPIOError(
monitorcontrol.vcp.vcp_abc.VCPIOError: received unexpected response code: 8
And this is version from git with replaced file from commit 27235db
monitorcontrol --get-luminance
Traceback (most recent call last):
File "./monitorcontrol", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.8/site-packages/monitorcontrol/__main__.py", line 101, in main
luminance = monitor.get_luminance()
File "/usr/lib/python3.8/site-packages/monitorcontrol/monitorcontrol.py", line 180, in get_luminance
return self._get_vcp_feature(code)
File "/usr/lib/python3.8/site-packages/monitorcontrol/monitorcontrol.py", line 157, in _get_vcp_feature
current, maximum = self.vcp.get_vcp_feature(code.value)
File "/usr/lib/python3.8/site-packages/monitorcontrol/vcp/vcp_linux.py", line 186, in get_vcp_feature
raise VCPIOError(
monitorcontrol.vcp.vcp_abc.VCPIOError: received unexpected response code: 8
from monitorcontrol.
I have a problem, is there any way to send and get commands like 6e 88 88 02 00 60 00 00 03 00 01 in vcp_linux from vcp_windows
from monitorcontrol.
I have a problem, is there any way to send and get commands like 6e 88 88 02 00 60 00 00 03 00 01 in vcp_linux from vcp_windows
I'm not sure I understand the "in vcp_linux from vcp_windows" part.
from monitorcontrol.
I have a problem, is there any way to send and get commands like 6e 88 88 02 00 60 00 00 03 00 01 in vcp_linux from vcp_windows
I'm not sure I understand the "in vcp_linux from vcp_windows" part.
Hmm...I mean I want to use the command 03 10 00 100 on windows instead of using -set-luminance 100, and I will get the information returned by the monitor like 6F 6E 88 02...
I'm sorry that I am new to this field, some words may not be clear.
from monitorcontrol.
It has been a while since I wrote this, but I don't think you can do (exactly) that with the APIs Microsoft provides for Windows, because it abstracts away some of the headers/footers: https://learn.microsoft.com/en-us/windows/win32/api/lowlevelmonitorconfigurationapi/#functions
If that's just a set/get VCP feature then you can use the set_vcp_feature
and get_vcp_feature
abstraction on the VCP which tries to make the Windows/Linux functions look the same.
from monitorcontrol.
Related Issues (20)
- ValueError: invalid literal for int() with base 16: ')' HOT 2
- Error in get_monitors() for SAMSUNG monitor HOT 3
- Checking input works for one monitor but not the other (both same model) HOT 8
- ValueError: 33 is not a valid InputSource HOT 3
- MacOs Support ?? HOT 4
- [bug] Capabilities string incomplete or too long HOT 1
- Not compatible with pyglet.window.Window HOT 2
- monitorcontrol doesn't switch inputs HOT 18
- Support for USB C HOT 1
- Return 0 of get_luminance() in windows 10 HOT 3
- set_input_source does not work for any of the codes listed in get_vcp_capabilities HOT 6
- "--set-power-mode on" is not working (windows) HOT 1
- File access won't be closed on /dev/i2c HOT 3
- KeyError: 0 when running `monitorcontrol --get-monitors` HOT 6
- How to distinguish between different monitors of the same model type? HOT 6
- ValueError: 27 is not a valid InputSource HOT 2
- More information for each monitor HOT 1
- Crash when monitor do not support input_source HOT 1
- Luminance function not working as intended HOT 7
- USB-C InputMode not supported HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monitorcontrol.