bahorn / OpenRGB-PyClient

it's a python client for OpenRGBs new server
MIT License
11 stars 3 forks source link

Running simple example fails #8

Closed palikar closed 4 years ago

palikar commented 4 years ago

I just discovered this library and tried running the provided simple example. I can connect to the OpenRGB server but then I get some internal error when I try to activate a mode for a device. For example, when running zone-change.py, I get

Traceback (most recent call last):
  File "zone-change.py", line 21, in <module>
    mode.active()
  File "/home/sun/code/py_envs/dev/lib/python3.6/site-packages/openrgb/ORGBDevice.py", line 67, in active
    con.set_update_mode(self, device_id=device.id)
  File "/home/sun/code/py_envs/dev/lib/python3.6/site-packages/openrgb/OpenRGB.py", line 115, in set_update_mode
    data=prepend_length(bytes(data)),
  File "/home/sun/code/py_envs/dev/lib/python3.6/site-packages/openrgb/ORGBDevice.py", line 88, in __bytes__
    blob.color(color)
  File "/home/sun/code/py_envs/dev/lib/python3.6/site-packages/openrgb/binreader.py", line 41, in color
    return self._packer('cccx', value)
  File "/home/sun/code/py_envs/dev/lib/python3.6/site-packages/openrgb/binreader.py", line 25, in _packer
    return self._pack(fmt, data)
  File "/home/sun/code/py_envs/dev/lib/python3.6/site-packages/openrgb/binreader.py", line 17, in _pack
    res = struct.pack(fmt, data)
struct.error: pack expected 3 items for packing (got 1)
bahorn commented 4 years ago

Hi!

Had a look into this a bit earlier, doesn't seem to occur in my personal setup but I can see the logic that would cause this to happen.

Should be a fairly minor patch, basically need to add a * in front of data in this specific case where colors are set in a mode. (I believe this was introduced in one of my more recent commits where I restructured the project.)

Should hopeful have a fix up over this over the weekend, though it's a little harder for me to test right now as I'm away from my desktop (still have remote access, but can't see the pretty colors!)

palikar commented 4 years ago

Oh, okay, thanks for the info. Btw, sorry that I forgot to mention the version of the library I use. I believe I just installed it through pip so whatever the newest version on PyPi, I used that one.

bahorn commented 4 years ago

Ok, should have just resolved this in master, had to check if the argument to Blob._pack is either a tuple or a list.

Going to push this version this PyPi.

Will reopen if it turns out I broke it again.

Thanks!