我有一个 Amrel PLA5K-400-400 eLoad 通过 GPIB 连接到 NI GPIB-USB-HS 适配器,还有一个 Agilent 34980A 数据记录器通过 USB 连接到我的 Ubuntu 22.04 笔记本电脑。我正在尝试通过 IVI NI 后端使用 PyVisa 控制这些设备。这是我所做的:
$ apt list --installed | grep libusb
libusb-1.0-0-dev/jammy-updates,now 2:1.0.25-1ubuntu2 amd64 [installed]
libusb-1.0-0/jammy-updates,now 2:1.0.25-1ubuntu2 amd64 [installed,automatic]
libusb-1.0-doc/jammy-updates,jammy-updates,now 2:1.0.25-1ubuntu2 all [installed,automatic]
libusbmuxd6/jammy,now 2.0.2-3build2 amd64 [installed,automatic]
$ sudo su
$ echo 'SUBSYSTEM=="usb", MODE="0666", GROUP="usbusers"' >> /etc/udev/rules.d/99-com.rules
$ pyvisa-info
Machine Details:
Platform ID: Linux-6.5.0-26-generic-x86_64-with-glibc2.35
Processor: x86_64
Python:
Implementation: CPython
Executable: /home/pwrtest/PycharmProjects/test/.venv/bin/python
Version: 3.10.12
Compiler: GCC 11.4.0
Architecture: ('x86', 64)
Build: Nov 20 2023 15:14:05 (#main)
Unicode: UCS4
PyVISA Version: 1.14.1
Backends:
ivi:
Version: 1.14.1 (bundled with PyVISA)
#1: /usr/lib/x86_64-linux-gnu/libvisa.so.24.0.0:
found by: auto
architecture:
('x86', 64)
Vendor: National Instruments
Impl. Version: 25165824
Spec. Version: 7340032
py:
Version: 0.7.2
USB INSTR: Available via PyUSB (1.2.1). Backend: libusb1
USB RAW: Available via PyUSB (1.2.1). Backend: libusb1
TCPIP INSTR: Available
Resource discovery:
- VXI-11: partial (psutil not installed)
- hislip: disabled (zeroconf not installed)
TCPIP SOCKET: Available
ASRL INSTR:
Please install PySerial (>=3.0) to use this resource type.
No module named 'serial'
VICP INSTR:
Please install PyVICP to use this resource type.
GPIB INSTR:
Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of functionalities.
No module named 'gpib'
GPIB INTFC:
Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of functionalities.
No module named 'gpib'
$ lsusb | grep GPIB
Bus 003 Device 002: ID 3923:709b National Instruments Corp. GPIB-USB-HS
$ lsusb | grep Agile
Bus 003 Device 016: ID 0957:0507 Agilent Technologies, Inc. 34980A Switch Measure Unit
$ lsni -v
Scanning localhost for devices...
System Configuration API Experts found:
NI Device Interconnect Manager 24.0.0 (nidim)
NI-488.2 23.5 (ni-488.2)
NI-CONTROLLER 24.0 (ni-controller)
NI Network Browser 24.0 (network)
NI MX Routing Utility 24.0.0 (nimru)
NI-MXI 24.0 (ni-mxi)
NI PXI Platform Services 24.0 (ni-pxi)
NI-QPXI 24.0 (ni-qpxi)
NI System Configuration 24.0 (nisyscfg)
NI-VISA 24.0 (ni-visa)
System Configuration API resources found:
pwrtest-ThinkPad-W520
--Primary Expert: NI System Configuration 24.0
--Model Name: 4282AD4
Ethernet Adapter enp0s25
--Primary Expert: NI System Configuration 24.0
ASRL10::INSTR
--Primary Expert: NI-VISA 24.0
ASRL11::INSTR
--Primary Expert: NI-VISA 24.0
ASRL12::INSTR
--Primary Expert: NI-VISA 24.0
ASRL13::INSTR
--Primary Expert: NI-VISA 24.0
ASRL14::INSTR
--Primary Expert: NI-VISA 24.0
ASRL15::INSTR
--Primary Expert: NI-VISA 24.0
ASRL16::INSTR
--Primary Expert: NI-VISA 24.0
ASRL17::INSTR
--Primary Expert: NI-VISA 24.0
ASRL18::INSTR
--Primary Expert: NI-VISA 24.0
ASRL19::INSTR
--Primary Expert: NI-VISA 24.0
ASRL1::INSTR
--Primary Expert: NI-VISA 24.0
ASRL20::INSTR
--Primary Expert: NI-VISA 24.0
ASRL21::INSTR
--Primary Expert: NI-VISA 24.0
ASRL22::INSTR
--Primary Expert: NI-VISA 24.0
ASRL23::INSTR
--Primary Expert: NI-VISA 24.0
ASRL24::INSTR
--Primary Expert: NI-VISA 24.0
ASRL25::INSTR
--Primary Expert: NI-VISA 24.0
ASRL26::INSTR
--Primary Expert: NI-VISA 24.0
ASRL27::INSTR
--Primary Expert: NI-VISA 24.0
ASRL28::INSTR
--Primary Expert: NI-VISA 24.0
ASRL29::INSTR
--Primary Expert: NI-VISA 24.0
ASRL2::INSTR
--Primary Expert: NI-VISA 24.0
ASRL30::INSTR
--Primary Expert: NI-VISA 24.0
ASRL31::INSTR
--Primary Expert: NI-VISA 24.0
ASRL32::INSTR
--Primary Expert: NI-VISA 24.0
ASRL3::INSTR
--Primary Expert: NI-VISA 24.0
ASRL4::INSTR
--Primary Expert: NI-VISA 24.0
ASRL5::INSTR
--Primary Expert: NI-VISA 24.0
ASRL6::INSTR
--Primary Expert: NI-VISA 24.0
ASRL7::INSTR
--Primary Expert: NI-VISA 24.0
ASRL8::INSTR
--Primary Expert: NI-VISA 24.0
ASRL9::INSTR
--Primary Expert: NI-VISA 24.0
USB0::0x0A5C::0x217F::402CF4E1EB51::2::RAW
--Primary Expert: NI-VISA 24.0
--Model Name: Broadcom Bluetooth Device
--Serial Number: 402CF4E1EB51
USB0::0x17EF::0x1003::NI-VISA-2003::RAW
--Primary Expert: NI-VISA 24.0
--Model Name: Integrated Smart Card Reader
--Serial Number: NI-VISA-2003
import pyvisa
rm = pyvisa.ResourceManager()
rm.list_resources()
('ASRL1::INSTR', 'ASRL2::INSTR', 'ASRL3::INSTR', 'ASRL4::INSTR', 'ASRL5::INSTR', 'ASRL6::INSTR', 'ASRL7::INSTR', 'ASRL8::INSTR', 'ASRL9::INSTR', 'ASRL10::INSTR', 'ASRL11::INSTR', 'ASRL12::INSTR', 'ASRL13::INSTR', 'ASRL14::INSTR', 'ASRL15::INSTR', 'ASRL16::INSTR', 'ASRL17::INSTR', 'ASRL18::INSTR', 'ASRL19::INSTR', 'ASRL20::INSTR', 'ASRL21::INSTR', 'ASRL22::INSTR', 'ASRL23::INSTR', 'ASRL24::INSTR', 'ASRL25::INSTR', 'ASRL26::INSTR', 'ASRL27::INSTR', 'ASRL28::INSTR', 'ASRL29::INSTR', 'ASRL30::INSTR', 'ASRL31::INSTR', 'ASRL32::INSTR')
当我尝试使用 pyvisa-py 后端时,我看到 USB Agilent 设备:
import pyvisa
rm = pyvisa.ResourceManager('@py)
rm.list_resources()
('USB0::2391::1287::MY44009773::0::INSTR',)
我期待使用 IVI ni 后端显示相同的
'USB0::2391::1287::MY44009773::0::INSTR'
设备。
运行以下命令并重新启动后,我能够识别 USB 设备....
sudo su
echo 'SUBSYSTEM=="usb", MODE="0666", GROUP="usbusers"' >> /etc/udev/rules.d/99-com.rules
rmmod usbtmc
echo 'blacklist usbtmc' > /etc/modprobe.d/nousbtmc.conf
但是 GPIB 设备仍然无法识别