Agilent 34461A DMM - Pyusb No Langid和Entity未找到

时间:2017-06-09 18:01:31

标签: python-2.7 libusb pyusb pyvisa

我不是一个强大的python程序员。我正在使用Pyvisa与GPIB工具连接。在学习曲线之后,似乎很容易。最近,我通过Pyvisa成功命令的一个GPIB仪器被更换为仅支持USB / Ethernet的更新版本。

所以现在我正在学习USB协议,这是一个意想不到但令人欢迎的惊喜。经过一些研究后,我了解到我应该安装PyUSB我做的以及安装最新版本的libusb-win32-devel-filter-1.2.6.0.exe

我还安装了Keysight Connection Expert,可以从那里查看,命令和查看设备。据我所知,安装了该设备的正确驱动程序。这是一些它的照片。 Keysight Conn Expert good comms with device 在第一张图片中,您可以看到Keysight软件可以看到设备,并在Visa地址中显示供应商和产品ID。第二张图描绘了对设备的成功命令响应 所以设备工作。现在使用Pycharm并跟随example我在python控制台中输入以下内容:

import usb.backend.openusb
dev = usb.backend.openusb.get_backend()
usb.core.find(idVendor = 0x2a8d, product = 0x1401, backend = dev)

我收到了这个错误:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "P:\Python27\lib\site-packages\usb\__init__.py", line 97, in <module>
from usb.legacy import *
File "P:\Python27\lib\site-packages\usb\legacy.py", line 29, in <module>
import usb.core as core
File "P:\Python27\lib\site-packages\usb\core.py", line 46, in <module>
import usb.util as util
File "P:\Python27\lib\site-packages\usb\util.py", line 316
raise ValueError("The device has no langid")

好的,所以经过对no langid问题的一些研究后,我不情愿地决定对util.py进行一些更改:

from usb.control import get_descriptor
# The following lines of code added to support the Agilent 34461A
# dev.langids = 0x0409
langids = dev.langids

# if 0 == len(langids):
#     raise ValueError("The device has no langid")
langid = 0x0409
# if langid is None:
#     langid = langids[0]
# elif langid not in langids:
#     raise ValueError("The device does not support the specified langid")

因此,在新控制台中重新运行以前的命令会出现以下错误:

Traceback (most recent call last):
  File "<input>", line 3, in <module>
  File "P:\Python27\lib\site-packages\usb\core.py", line 1269, in find
    return _interop._next(device_iter(**args))
  File "P:\Python27\lib\site-packages\usb\_interop.py", line 66, in _next
    return next(iter)
  File "P:\Python27\lib\site-packages\usb\core.py", line 1249, in device_iter
    if _interop._all(tests) and (custom_match is None or custom_match(d)):
  File "P:\Python27\lib\site-packages\usb\core.py", line 1248, in <genexpr>
    tests = (val == getattr(d, key) for key, val in kwargs.items())
  File "P:\Python27\lib\site-packages\usb\core.py", line 841, in product
    self._product = util.get_string(self, self.iProduct)
  File "P:\Python27\lib\site-packages\usb\util.py", line 328, in get_string
    langid
  File "P:\Python27\lib\site-packages\usb\control.py", line 173, in get_descriptor
    data_or_wLength = desc_size)
  File "P:\Python27\lib\site-packages\usb\core.py", line 1025, in ctrl_transfer
    self._ctx.managed_open()
  File "P:\Python27\lib\site-packages\usb\core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "P:\Python27\lib\site-packages\usb\core.py", line 120, in managed_open
    self.handle = self.backend.open_device(self.dev)
  File "P:\Python27\lib\site-packages\usb\backend\libusb1.py", line 786, in open_device
    return _DeviceHandle(dev)
  File "P:\Python27\lib\site-packages\usb\backend\libusb1.py", line 643, in __init__
    _check(_lib.libusb_open(self.devid, byref(self.handle)))
  File "P:\Python27\lib\site-packages\usb\backend\libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 2] Entity not found

我现在处于亏损状态。我不认为继续编辑pyusb库是明智的。我对python和一个关于USB接口的完整菜鸟相对较新。任何意见是极大的赞赏。

系统信息:Win 7 Pro 64 Bit,Python 2.7,Pycharm

0 个答案:

没有答案