ljakob / unit_ut61eplus

Access digtal multimeter UNI-T UT61E+ from Python via CP2110 based USB connection
GNU General Public License v3.0
32 stars 11 forks source link

oserror open failed. #9

Open hippylover opened 1 year ago

hippylover commented 1 year ago
02:09:26 kris ~/unit_ut61eplus-main $ python readDMM.py 
Traceback (most recent call last):
  File "/home/kris/unit_ut61eplus-main/readDMM.py", line 9, in <module>
    dmm = UT61EPLUS()
          ^^^^^^^^^^^
  File "/home/kris/unit_ut61eplus-main/ut61eplus/ut61eplus.py", line 313, in __init__
    self.dev.open(self.CP2110_VID, self.CP2110_PID)
  File "hid.pyx", line 142, in hid.device.open
OSError: open failed

i have the library installed https://github.com/trezor/cython-hidapi through archlinux package manager

euandekock commented 8 months ago

There are a couple of potential issues here.

1: Permissions, try running it with sudo to check if it works then. If it does, then you need to add a rule to your udev system to give normal users permission.

Add a file in /etc/udev/rules.d EG: /etc/udev/rules.d/99-unit-ut61e-plus-udev.rules

And put in the following lines:

# Uni-T UT61E+ CP2110 HID Device
ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea80", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"

or in my case (See 2 below):

# Uni-T UT61E+ CP2110 HID Device
ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e429", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"

2: The USB Vendor and Product are different. I just received my Uni-T UT61E+ today, and it has a different vendor and product info from that in the code.

Use the lsusb command to see what devioces are plugged in:

lsusb

...
Bus 003 Device 009: ID 1a86:e429 QinHeng Electronics WCH UART TO KB-MS_V1.6
...

If your vendor and product numbers are different to the default values, you will need to edit the python file in ut61eplus/ut61eplus.py and change these variables to match your unit, and make sure that the option 1 values match the vendor and product.

class UT61EPLUS:

    #CP2110_VID = 0x10c4
    #CP2110_PID = 0xEA80
    CP2110_VID = 0x1A86
    CP2110_PID = 0xE429