jath03 / openrgb-python

A python client for the OpenRGB SDK
GNU General Public License v3.0
115 stars 22 forks source link

Getting confusing parsing[?] error running example code #35

Closed apolunar closed 3 years ago

apolunar commented 3 years ago

The below error is generated every time I run the example code given by the readme. I don't know if it's a silly mistake on my part or a problem with the module. Honestly, it's probably the former. Also a screenshot showing the server I have running in OpenRGB and that a client did connect to it.

image


  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 137, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\utils.py", line 547, in unpack
    metadata = MetaData.unpack(data, version)
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\utils.py", line 489, in unpack
    serial = parse_string(data)
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\utils.py", line 116, in parse_string     
    return parse_var(f'{length}s', data).decode().rstrip('\x00')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa6 in position 0: invalid start byte

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "example_code.py", line 4, in <module>
    client = OpenRGBClient()
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\orgb.py", line 287, in __init__
    self.comms.requestDeviceNum()
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 188, in requestDeviceNum
    self.read()
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 116, in read
    self.callback(device_id, packet_type, buff[0])
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\orgb.py", line 302, in _callback
    self.comms.requestDeviceData(x)
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 181, in requestDeviceData
    self.read()
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 139, in read
    raise utils.ControllerParsingError(f"Unable to parse data from request `{packet_type}` for device #{device_id}") from e
openrgb.utils.ControllerParsingError: Unable to parse data from request `1` for device #1```
plutonium-239 commented 3 years ago

The error doesn't pertain to openrgb, it's a UnicodeDecodeError, or, the data that you are trying to parse is not utf-8. I don't know what your data is, so can't tell what codec to use.

apolunar commented 3 years ago

Thanks for the quick response! I think that even if I did know what codec to use, I wouldn't know what to do with it because the actual error is occurring within OpenRGB itself -

File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\orgb.py", line 287, in __init__
    self.comms.requestDeviceNum()
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 188, in requestDeviceNum
    self.read()

... And, python throws the error on the first line of the example code provided by the readme-

Traceback (most recent call last):
  File "example_code.py", line 4, in <module>
    client = OpenRGBClient()

The code that goes on inside of OpenRGBClient() is not really something I have control over. What I do have control over is my rgb devices and how OpenRGB is setup, I'm thinking the error comes from one of those two places as they are the only two places that I can think of where data might be coming in. As you said, the data OpenRGB is trying to parse is not utf-8, but alas I did not provide that data directly through code meaning the solution will probably be figuring out what that data is and how to change it... after all, it got the bad data in some other place. You know what they say, garbage in, garbage out lol

I could be totally wrong with all of this, but these are my thoughts. I'll keep trying to figure this error out, thanks for your help thus far.

jath03 commented 3 years ago

See the newly pinned issue (#33)

jath03 commented 3 years ago

Feel free to reopen if you are having a different problem.