gfduszynski / cm-rgb

Control your Wraith Prism RGB on Linux, Mac OS and Windows
MIT License
207 stars 11 forks source link

V0.0.9 - IOError open failed #7

Closed DocTdb closed 4 years ago

DocTdb commented 4 years ago

Hi, I can't manage to make your project work on my Mint 19.2 but I'm not a python master so it's surely my mistake. Install went great with pip. I can access --help so it's installed but when I try your example :

cm-rgb-cli logo --mode=breathe --color=#00ff00 --speed=3 --brightness=5 fan --mode=breathe --color=#0000ff --speed=4 --brightness=1 ring --mode=swirl --color=#ff0000 --speed=1 --brightness=1
Traceback (most recent call last):
  File "/home/user/.local/bin/cm-rgb-cli", line 161, in <module>
    cli()
  File "/home/user/.local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/lib/python2.7/site-packages/click/core.py", line 1164, in invoke
    return _process_result(rv)
  File "/home/user/.local/lib/python2.7/site-packages/click/core.py", line 1102, in _process_result
    **ctx.params)
  File "/home/user/.local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/.local/bin/cm-rgb-cli", line 22, in process_pipeline
    c = CMRGBController()
  File "/home/user/.local/lib/python2.7/site-packages/cm_rgb/ctrl.py", line 50, in __init__
    self.__init_hid_device()
  File "/home/user/.local/lib/python2.7/site-packages/cm_rgb/ctrl.py", line 60, in __init_hid_device
    self.device.open_path(device_list[0]["path"])
  File "hid.pyx", line 72, in hid.device.open_path
IOError: open failed

Did I miss something ?

gfduszynski commented 4 years ago

Hi, Try running with sudo, usually I get the same error when I forget it.

DocTdb commented 4 years ago

When I ran it with sudo it gave me a "Command not found"

So I reinstalled it with sudo pip install cm-rgb and then sudo pip install --upgrade cm-rgb and now when I run your example :

sudo cm-rgb-cli logo --mode=breathe --color=#00ff00 --speed=3 --brightness=5 fan --mode=breathe --color=#0000ff --speed=4 --brightness=1 ring --mode=swirl --color=#ff0000 --speed=1 --brightness=1
Traceback (most recent call last):
  File "/usr/local/bin/cm-rgb-cli", line 3, in <module>
    from cm_rgb.ctrl import LedChannel, LedMode, CMRGBController
  File "/usr/local/lib/python2.7/dist-packages/cm_rgb/ctrl.py", line 1, in <module>
    import hid
ImportError: No module named hid

Maybe a problem with hidapi though it has been installed with cm-rgb. Thanks for your time.

gfduszynski commented 4 years ago

Probably the package was only installed for your user initially.

Try lsusb and find Cooler Master Then sudo chmod 777 /dev/bus/usb/<bus>/<device>

This should enable access without sudo until next reboot.

gfduszynski commented 4 years ago

If you still have problem with hid please try following installation procedure: https://github.com/trezor/cython-hidapi

DocTdb commented 4 years ago

Oddly with lsusb I found a vendor matching CoolerMaster and an id 0051 but no mention of the brand evidently.

It works great now, I updated Setuptools and reinstalled Hidapi both with sudo, thanks for your help.

One thing though, for a leek like me, could you precise how to specify a RANGE in brightness and speed ? Thanks a lot.

Edit : tried it Python style range(3, 5) but failed. Edit 2 : tried it Bash style {3..5} but nop.

gfduszynski commented 4 years ago

I'm glad it has worked out for you :)

I'm not sure I understand the part about the range. Are you referring to CLI or direct usage of ctrl.py ?

Are you trying to 'animate' brightness and speed ?

DocTdb commented 4 years ago

I'm refering to CLI, the syntax to pass a range as argument. In the help ( For clarity, you already know it cause...you wrote it.)

sudo cm-rgb-cli fan --help
Usage: cm-rgb-cli fan [OPTIONS]

Options:
  --color TEXT
  --mode [off|static|breathe]
  --speed INTEGER RANGE
  --brightness INTEGER RANGE
  --help                       Show this message and exit.

In speed and brightness you propose INTEGER or RANGE, at the moment the fan goes from totally dark to full bright and so on. I think that range would allow to go from half bright to full bright and repeat.

gfduszynski commented 4 years ago

Actually this message is generated by click library and it's misguiding.

@cli.command('logo')
@click.option('--color','color', default='#00FFFF')
@click.option('--mode', type=click.Choice(['off', 'static', 'breathe'], case_sensitive=False), default='static')
@click.option('--speed', type=click.IntRange(1, 5, clamp=True), default=3)
@click.option('--brightness', type=click.IntRange(1, 5, clamp=True), default=3)
@click.pass_context
def setup_logo(ctx, mode, color, brightness, speed):

This means that speed/brightness accept single value within predefined range. (1 to 5 in both cases)

To achieve the the effect you are describing currently breathe mode can be used, but only max value of brightness can be defined. This is a limitation of the controller.

I hope this clears it up a bit :)

DocTdb commented 4 years ago

Yep ! All is clear now. Thanks a Bunch.