Skip to content

OpenRGBClient() fails to get number of devices #32

Closed
@henryruhs

Description

@henryruhs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions