cazz
cazz

Reputation: 1

To get voltage signal with pyusb through USB device

I am making a Python code to get voltage signal through USB port with "DIGITAL ICP USB SIGNAL CONDITIONER Model 485B39". Now I encountered a following error. But I am not sure how to deal with it. I would appreciate it if someone could support me.

The error encountered is :

Connected to pydev debugger (build 233.13763.11)
 DEVICE ID 29da:000a on Bus 001 Address 015 =================
 bLength                :   0x12 (18 bytes)
 bDescriptorType        :    0x1 Device
 bcdUSB                 :  0x200 USB 2.0
 bDeviceClass           :    0x0 Specified at interface
 bDeviceSubClass        :    0x0
 bDeviceProtocol        :    0x0
 bMaxPacketSize0        :    0x8 (8 bytes)
 idVendor               : 0x29da
 idProduct              : 0x000a
 bcdDevice              :  0x100 Device 1.0
 iManufacturer          :    0x1 Digiducer.com 
 iProduct               :    0x2 485B39 200212708071760811861230228
 iSerialNumber          :    0x3 002127    200212708071760811861230228
 bNumConfigurations     :    0x1
  CONFIGURATION 1: 40 mA ===================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0xbd (189 bytes)
   bNumInterfaces       :    0x2
   bConfigurationValue  :    0x1
   iConfiguration       :    0x0 
   bmAttributes         :   0x80 Bus Powered
   bMaxPower            :   0x14 (40 mA)
    INTERFACE 0: Audio =====================================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x0
     bInterfaceClass    :    0x1 Audio
     bInterfaceSubClass :    0x1
     bInterfaceProtocol :    0x0
     iInterface         :    0x0 
    INTERFACE 1: Audio =====================================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x1
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x0
     bInterfaceClass    :    0x1 Audio
     bInterfaceSubClass :    0x2
     bInterfaceProtocol :    0x0
     iInterface         :    0x0 
    INTERFACE 1, 1: Audio ==================================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x1
     bAlternateSetting  :    0x1
     bNumEndpoints      :    0x1
     bInterfaceClass    :    0x1 Audio
     bInterfaceSubClass :    0x2
     bInterfaceProtocol :    0x0
     iInterface         :    0x0
      ENDPOINT 0x81: Isochronous IN ========================
       bLength          :    0x9 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0xd Isochronous
       wMaxPacketSize   :   0xc0 (192 bytes)
       bInterval        :    0x1
    INTERFACE 1, 2: Audio ==================================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x1
     bAlternateSetting  :    0x2
     bNumEndpoints      :    0x1
     bInterfaceClass    :    0x1 Audio
     bInterfaceSubClass :    0x2
     bInterfaceProtocol :    0x0
     iInterface         :    0x0 
      ENDPOINT 0x81: Isochronous IN ========================
       bLength          :    0x9 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0xd Isochronous
       wMaxPacketSize   :  0x120 (288 bytes)
       bInterval        :    0x1
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2023.3.3\plugins\python-        ce\helpers\pydev\pydevd.py", line 1534, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2023.3.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:\Users\sai\PycharmProjects\Voltage_signal_acq\000_wo_def_for_Ch01.py", line 26, in <module>
    usb.util.claim_interface(dev, interface_number)
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\util.py", line 207, in claim_interface
    device._ctx.managed_claim_interface(device, interface)
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\core.py", line 113, in wrapper
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\core.py", line 178, in managed_claim_interface
    self.backend.claim_interface(self.handle, i)
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-    packages\usb\backend\libusb1.py", line 829, in claim_interface
_check(self.lib.libusb_claim_interface(dev_handle.handle, intf))
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\backend\libusb1.py", line 600, in _check
    raise NotImplementedError(_strerror(ret))
NotImplementedError: Operation not supported or unimplemented on this platform

  python-BaseException Process finished with exit code 1

The current code is:

import usb.core
import usb.util

# Find the USB device
vendor_id = 0x29DA
product_id = 0x000A

dev = usb.core.find(idVendor=vendor_id, idProduct=product_id)
if dev is None:
    raise ValueError('Device not found')
print(dev)

# Set the active configuration
dev.set_configuration()

# Interface numbers and alternate settings for each channel
CHANNEL_1_INTERFACE_NUMBER = 0x1
CHANNEL_1_ALTERNATE_SETTING = 0x1

interface_number = CHANNEL_1_INTERFACE_NUMBER
alternate_setting = CHANNEL_1_ALTERNATE_SETTING

# Assuming the endpoint address for both channels is 0x81, you would read from it
endpoint_address = 0x81

usb.util.claim_interface(dev, interface_number)
# Set the alternate setting for the interface
dev.set_interface_altsetting(interface_number, alternate_setting)`

References : OS : Windows10 USB driver :libusbK

I have already tried below. But

try:
    dev.detach_kernel_driver(interface_number)
except usb.core.USBError as e:
    print("Error detaching kernel driver: ", e)

Error encountered :

Traceback (most recent call last):
  File "C:\Users\sai\PycharmProjects\Voltage_signal_acq\000_wo_def_for_Ch01.py", line 26, in <module>
    usb.util.claim_interface(dev, interface_number)
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\util.py", line 207, in claim_interface
    device._ctx.managed_claim_interface(device, interface)
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\core.py", line 113, in wrapper
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\core.py", line 178, in managed_claim_interface
    self.backend.claim_interface(self.handle, i)
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\backend\libusb1.py", line 829, in claim_interface
_check(self.lib.libusb_claim_interface(dev_handle.handle, intf))
  File "C:\Users\sai\AppData\Local\Programs\Python\Python312\Lib\site-packages\usb\backend\libusb1.py", line 600, in _check
    raise NotImplementedError(_strerror(ret))
NotImplementedError: Operation not supported or unimplemented on this platform

Upvotes: 0

Views: 139

Answers (0)

Related Questions