Problems using pyvisa, gpib-usb-hs and HP3458A - Page 1
Forum section: electronics / testgear

author: Sphyrna
author_rank: Contributor
timestamp: September 13, 2023, 02:13:29 pm
content: Hello,inspired by xdevs page I would like to script some measurements on a DMM. But I have some problems to get the basic drivers or software running. First I did a step by step installation fromhttps://www.cl.cam.ac.uk/~osc22/tutorials/gpib_usb_linux.html. I installed pyvisa as front end and pyvisa-py and NI-VISA as backends. pyvisa-info gives:Code:pyvisa-infoMachine Details:Platform ID: Linux-6.2.0-32-generic-x86_64-with-glibc2.35Processor: x86_64Python:Implementation: CPythonExecutable: /usr/bin/python3Version: 3.10.12Compiler: GCC 11.4.0Bits: 64bitBuild: Jun 11 2023 05:26:28 (#main)Unicode: UCS4PyVISA Version: 1.13.0Backends:ivi:Version: 1.13.0 (bundled with PyVISA)#1: /usr/lib/x86_64-linux-gnu/libvisa.so.23.5.0:found by: autobitness: 64Vendor: National InstrumentsImpl. Version: 24118528Spec. Version: 7340032py:Version: 0.7.0ASRL INSTR: Available via PySerial (3.5)USB INSTR: Available via PyUSB (1.2.1-1). Backend: libusb1USB RAW: Available via PyUSB (1.2.1-1). Backend: libusb1TCPIP INSTR: AvailableResource discovery:- VXI-11: ok- hislip: okTCPIP SOCKET: AvailableGPIB INSTR: Available via Linux GPIB (b'4.3.6')GPIB INTFC: Available via Linux GPIB (b'4.3.6')VICP INSTR:Please install PyVICP to use this resource type.When I tried it with the pyvisa-py backend and it throws:Code:python3Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import pyvisa>>> rm = pyvisa.ResourceManager('@py')>>> rm.list_resources()libgpib: ibBoardOpen failed to open device file /dev/gpib0libgpib: No such file or directorylibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: ibBoardOpen failed to open device file /dev/gpib0libgpib: No such file or directorylibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptorlibgpib: invalid descriptor('ASRL/dev/ttyS4::INSTR', 'ASRL/dev/ttyS0::INSTR')With the NI-VISA backend it throws:Code:python3Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import pyvisa>>> rm = pyvisa.ResourceManager('@ivi')>>> rm.list_resources()('ASRL1::INSTR', 'ASRL5::INSTR')>>>If I connect the GPIB adapter the udevadm monitor --environment says:Code:UDEV [30086.657642] add /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.4/1-5.4.2/1-5.4.2:1.0 (usb)ACTION=addDEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.4/1-5.4.2/1-5.4.2:1.0SUBSYSTEM=usbDEVTYPE=usb_interfacePRODUCT=3923/709b/101TYPE=0/0/0INTERFACE=255/0/0MODALIAS=usb:v3923p709Bd0101dc00dsc00dp00icFFisc00ip00in00SEQNUM=4209USEC_INITIALIZED=30086650903ID_VENDOR_FROM_DATABASE=National Instruments Corp.ID_MODEL_FROM_DATABASE=GPIB-USB-HSID_PATH=pci-0000:00:14.0-usb-0:5.4.2:1.0ID_PATH_TAG=pci-0000_00_14_0-usb-0_5_4_2_1_0TAGS=:snap_cups_cupsd:snap_cups_ippeveprinter:CURRENT_TAGS=:snap_cups_cupsd:snap_cups_ippeveprinter:UDEV [30086.669265] bind /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.4/1-5.4.2 (usb)ACTION=bindDEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.4/1-5.4.2SUBSYSTEM=usbDEVNAME=/dev/bus/usb/001/011DEVTYPE=usb_deviceDRIVER=usbPRODUCT=3923/709b/101TYPE=0/0/0BUSNUM=001DEVNUM=011SEQNUM=4210USEC_INITIALIZED=30086620303ID_VENDOR=National_InstrumentsID_VENDOR_ENC=National\x20InstrumentsID_VENDOR_ID=3923ID_MODEL=GPIB-USB-HSID_MODEL_ENC=GPIB-USB-HSID_MODEL_ID=709bID_REVISION=0101ID_SERIAL=National_Instruments_GPIB-USB-HS_01268E03ID_SERIAL_SHORT=01268E03ID_BUS=usbID_USB_INTERFACES=:ff0000:ID_VENDOR_FROM_DATABASE=National Instruments Corp.ID_MODEL_FROM_DATABASE=GPIB-USB-HSID_PATH=pci-0000:00:14.0-usb-0:5.4.2ID_PATH_TAG=pci-0000_00_14_0-usb-0_5_4_2ID_FOR_SEAT=usb-pci-0000_00_14_0-usb-0_5_4_2MAJOR=189MINOR=10TAGS=:snap_cups_cupsd:seat:snap_cups_ippeveprinter:CURRENT_TAGS=:seat:snap_cups_cupsd:snap_cups_ippeveprinter:In /etc/udev/rules.d/ I applied the following rules:Code:SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="3923", ATTR{idProduct}=="709", MODE="660", GROUP="plugdev", SYMLINK+="usb_gpib"SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="3923", ATTR{idProduct}=="709", RUN+="/lib/udev/ni_usb_gpib"KERNEL=="gpib[0-9]*", ACTION=="add", MODE="660", GROUP="plugdev"Someone has a hint how to fix this problem?

author: ch_scr
author_rank: Frequent Contributor
timestamp: September 13, 2023, 02:47:46 pm
content: Looking at the "udevadm monitor" output, there are the lines:Code:TAGS=:snap_cups_cupsd:seat:snap_cups_ippeveprinter:CURRENT_TAGS=:seat:snap_cups_cupsd:snap_cups_ippeveprinter:Not sure if that is normal or if the printer driver snatched it up blocking it somehow?Don't have one to test and compare, but it seems strange at least?

author: alm
author_rank: Super Contributor
timestamp: September 13, 2023, 02:56:56 pm
content: Not sure if it's related, but I wouldn't install both NI-VISA and PyVISA-py. Last time I checked, NI-VISA for Linux only supports GPIB USB devices on ancient kernel versions. So I'd skip NI-VISA lest it breaks something, and focus on getting linux-gpib to work.

author: tszaboo
author_rank: Super Contributor
timestamp: September 13, 2023, 03:40:47 pm
content: Quote from: alm on September 13, 2023, 02:56:56 pmI think it's absolutely related. Having the right package is paramount, and I think in this case you indeed need to have pyvisa-py installed. Though this was a while ago, but I think I had the same issue on an unrelated python script.

author: alm
author_rank: Super Contributor
timestamp: September 13, 2023, 03:44:50 pm
content: First /dev/gpib0 needs to exist. Until that time, there's a problem with linux-gpib drivers that aren't being loaded, not with PyVISA-py.That guide is for Ubuntu versions from 2010. If you have a somewhat recent Ubuntu version, check if the link in my signature has packages that work on your system. The kernel package should contain the necessary udev scripts.

author: Sphyrna
author_rank: Contributor
timestamp: September 14, 2023, 06:28:06 am
content: Quote from: alm on September 13, 2023, 02:56:56 pmThe NI-VISA version I installed supportes jummy and focal (https://www.ni.com/pdf/manuals/ni-visa-linux-2023-q3.html). But I will try to install the packages from alm on a clean debian system. Maybe you are right and isn't possible to have two backends installed. I will try to have a look into that cups driver tags.

author: alm
author_rank: Super Contributor
timestamp: September 14, 2023, 07:59:02 am
content: Quote from: Sphyrna on September 14, 2023, 06:28:06 amYes, but it doesn't support the GPIB-USB-HS on Linux. Select GPIB-USB-HShereand see what it says for Linux. It used to be limited to kernels <= 2.6.24 (released in 2008), but I guess now they completely dropped support.

author: Sphyrna
author_rank: Contributor
timestamp: September 14, 2023, 11:12:41 am
content: Thank you for the infos alm. I wasn't able to get it running on debian, too. But I have to admit that I am not a Linux pro user. I got it running on windows now. I just installed the NI drivers and adapted the PATH variables and pyvisa lists the intruments. Now I will start with some scripting yippiiiih.

author: raphaelcasimir
author_rank: Contributor
timestamp: February 17, 2025, 04:56:20 pm
content: Just for future reference: were you inside a Python virtual environment (venv)? I had issues when the libraries were installed through a venv. The guide onhttps://pyvisa.comexplicitely warns against it.