flok / pydualsense

control your dualsense controller with python
MIT License
118 stars 32 forks source link

OSError: Could not open connection to device. #36

Closed mwlock closed 2 years ago

mwlock commented 2 years ago

Ubuntu 22.04

Traceback (most recent call last):
  File "/home/matt/projects/particle-filter/src/dualsense/test_controller.py", line 7, in <module>
    ds.init() # initialize controller
  File "/home/matt/.local/lib/python3.10/site-packages/pydualsense/pydualsense.py", line 95, in init
    self.device: hidapi.Device = self.__find_device()
  File "/home/matt/.local/lib/python3.10/site-packages/pydualsense/pydualsense.py", line 168, in __find_device
    dual_sense = hidapi.Device(vendor_id=detected_device.vendor_id, product_id=detected_device.product_id)
  File "/home/matt/.local/lib/python3.10/site-packages/hidapi.py", line 256, in __init__
    raise IOError("Could not open connection to device.")
OSError: Could not open connection to device.
flok commented 2 years ago

hidapi is raw usb. You either need elevated privileges (sudo) or need to setup a udev rule for the controller to use is with user permissions

Master-OB1 commented 2 months ago

I am having the same issue. I am on a raspberry pi 5 and am getting the error

Traceback (most recent call last):
  File "/home/harrison06/ps5test.py", line 25, in <module>
    dualsense.init()
  File "/home/harrison06/.local/lib/python3.11/site-packages/pydualsense/pydualsense.py", line 108, in init
    self.device: hidapi.Device = self.__find_device()
                                 ^^^^^^^^^^^^^^^^^^^^
  File "/home/harrison06/.local/lib/python3.11/site-packages/pydualsense/pydualsense.py", line 186, in __find_device
    dual_sense = hidapi.Device(
                 ^^^^^^^^^^^^^^
  File "/home/harrison06/.local/lib/python3.11/site-packages/hidapi.py", line 256, in __init__
    raise IOError("Could not open connection to device.")
OSError: Could not open connection to device.

I set up the udev file 70-ps5-controller but that didn't fix the issue. I am not experienced so any commands i can copy would be helpful.