kcuzner / led-watch

A miniature ARM-powered LED wristwatch
http://kevincuzner.com/2017/04/18/the-led-wristwatch-a-more-or-less-completed-project/
MIT License
95 stars 16 forks source link

Error attempting to open HID object #6

Closed Eqqm4n closed 1 year ago

Eqqm4n commented 1 year ago

The hidapi library crashes attempting to open the object returned by the wristwatch.py script's find_device() function ::

Traceback (most recent call last): File "/home/perfecta/Downloads/led-watch-master/host/bootloader", line 68, in main() File "/home/perfecta/Downloads/led-watch-master/host/bootloader", line 54, in main with open_bootloader(args.timeout) as dev: File "/home/perfecta/Downloads/led-watch-master/host/device/wristwatch.py", line 40, in enter self.open_path(self.path) File "hid.pyx", line 157, in hid.device.open_path OSError: open failed

If you check the file name and line number reported for hid.pyx you'll see this function ::

def open_path(self, bytes path):
    """Open connection by path.

    :param path: Path to device
    :type path: bytes
    :raises IOError:
    """
    cdef char* cbuff = path
    if self._c_hid != NULL:
        raise RuntimeError('already open')
    self._c_hid = hid_open_path(cbuff)
    if self._c_hid == NULL:
        raise IOError('open failed')
    self._close = weakref.finalize(self, _closer.wrap(self._c_hid).close)

...and I verified that the 'path' parameter is this object :: {'path': b'3-2:1.0'}. In order to raise the IOError then there must have been a failure of the hid_open_path() function call, but how to troubleshoot this further is unclear as I don't know how to reconstruct the 'cdef char* cbuff = path' line when trying to do these things step by step via running the Python interpreter directly.

kcuzner commented 1 year ago

Please check that your user is able to access the hidraw handle and/or USB handle in dev and if it doesn't have write permissions, add a udev rule or use sudo to run the script as noted in #5

Eqqm4n commented 1 year ago

Thank you for the response. Running the script with sudo cleared that up.