Skip to content
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

OpenRGBClient() fails to get number of devices #32

Closed
henryruhs opened this issue Jun 29, 2021 · 3 comments
Closed

OpenRGBClient() fails to get number of devices #32

henryruhs opened this issue Jun 29, 2021 · 3 comments

Comments

@henryruhs
Copy link

henryruhs commented Jun 29, 2021

Hello, this issue might be similar to #29 - I get this error:

OpenRGB: 0.6
openrgb-python: 0.2.9

Traceback (most recent call last):
  File "./test.py", line 8, in <module>
    client = OpenRGBClient()
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/orgb.py", line 268, in __init__
    self.comms.requestDeviceNum()
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/network.py", line 176, in requestDeviceNum
    self.read()
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/network.py", line 114, in read
    self.callback(device_id, packet_type, buff[0])
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/orgb.py", line 283, in _callback
    self.comms.requestDeviceData(x)
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/network.py", line 169, in requestDeviceData
    self.read()
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/network.py", line 133, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/utils.py", line 466, in unpack
    start, metadata = MetaData.unpack(data, version, start)
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/utils.py", line 413, in unpack
    start, val = parse_string(data, start)
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/utils.py", line 101, in parse_string
    val = struct.unpack(f"{size}s", data[start:start + size])[0].decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 0: invalid start byte

You codebase contains lot of [0] that might cause nullpointer exceptions or code not to work as expected. That being said, it might be nice to raise more exceptions or fix potential unsafe code.

@jath03
Copy link
Owner

jath03 commented Jul 27, 2021

What devices do you have? If it is related to #29, it would be a problem with a USB device. I did add a (slightly) better exception for parsing errors. Also, sorry this response is so late.

@jath03
Copy link
Owner

jath03 commented Aug 1, 2021

Can you try using a more recent build of OpenRGB? Anything after https://gitlab.com/CalcProgrammer1/OpenRGB/-/commit/22acdd1fed976392698753b349b74233e8e319ed should work. It could fix your problem if it the same as #29

@henryruhs
Copy link
Author

henryruhs commented Aug 9, 2021

It works with OpenRGB 0.61 (from master) and your latest openrgb-python-0.2.10... Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants