pyvisa / pyvisa-py

A pure python PyVISA backend
https://pyvisa-py.readthedocs.io
MIT License
282 stars 120 forks source link

[COM] Communication issue with Siglent SPS5051X using Ubuntu VM #398

Closed ragrylesvani closed 11 months ago

ragrylesvani commented 11 months ago

In the past I was able to get python to derive a lot of information about the connected device (such as Manufacturer ID), but now pyvisa-py fails to identify anything about the device other than the bare basics.

image

PyUSB seems to be able to derive this information, and so is the Linux OS. I am wondering if there is an issue with how the Resource Class in instantiated, or how/why there is a failure to propagate this infromation up into pyvisa-py?

Python 3.8.0 (default, Dec  9 2021, 17:53:27) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import usb.core
>>> dev = usb.core.find(find_all=True)
>>> for cfg in dev:
...  print('Decimal VendorID=' + str(cfg.idVendor) + ' & ProductID=' + str(cfg.idProduct))
...  print('Hexadecimal VendorID=' + hex(cfg.idVendor) + ' & ProductID=' + hex(cfg.idProduct))
... 
Decimal VendorID=62700 & ProductID=5203
Hexadecimal VendorID=0xf4ec & ProductID=0x1453

Instrument details

Output of pyvisa-info

Machine Details: Platform ID: Linux-5.4.0-135-generic-x86_64-with-glibc2.27 Processor: x86_64

Python: Implementation: CPython Executable: ...bin/python Version: 3.8.0 Compiler: GCC 8.4.0 Bits: 64bit Build: Dec 9 2021 17:53:27 (#default) Unicode: UCS4

PyVISA Version: 1.13.0

Backends: ivi: Version: 1.13.0 (bundled with PyVISA) Binary library: Not found py: Version: 0.7.0 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:

MatthieuDartiailh commented 11 months ago

I need to double-check the code, but right now, I suspect that the issue comes from the resource name looking weird (::0 before the INSTR). Typically the device manufacturer and device ID are not read from the bus since they are part of the resource name, but since here the name looks odd it may not have been parsed properly.

How did you obtain that resource name ?

MatthieuDartiailh commented 11 months ago

So it seems I was wrong and the attributes are simply not set. #399 should fix the issue. Could you test ? I have no instrument on hand to test.

ragrylesvani commented 11 months ago

To answer your question, I got the resource name by listing the connected devices through the pyvisa-shell. To my understanding, that is how pyvisa has stored that name for itself locally.

I will try my hand at testing these changes and get back with any results.

ragrylesvani commented 11 months ago

It seems the change is successful in populating the aforementioned fields.

image

Thank you for working on this!

MatthieuDartiailh commented 11 months ago

I will merge and try to release soon