From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-25-2018 12:41 PM
Hi,
I'm using python to talk to instruments over GPIB. My full script runs successfully, but I always get an error thrown in the python window at the very end of the run. I truncated my code to just the root of the issue, shown below. The error is also shown. Due to the error type, I've tried closing all my instruments and types, but no success. The error thrown is the same with and without the bottom portion of the code.
Also, I wasn't able to successfully talk to the instruments without the make_default_gpib() command. Calling this solved my issues, so it seems to be required for me.
import visa
import gpib_ctypes
from gpib_ctypes import make_default_gpib
make_default_gpib()
rm = visa.ResourceManager("C:\\Windows\\System32\\visa32.dll")
instr = rm.open_resource("GPIB0::5::INSTR")
Everything Below is code added to try to solve the issue
#Issue exist with and without below code
instr.__del__()
instr.close()
rm.close()
del instr
rm.__del__()
del rm
Error:
Exception ignored in: <function Gpib.__del__() at 0x02f60bb8>
Traceback (most recent call last):
File "C:\Python37-32\lib\site-packages\gpib_ctypes\Gpib.py", line 37, in __del__
File "C:\Python37-32\lib\site-packages\gpib_ctypes\gpib\gpib.py", line 230, in close
gpib_ctypes.gpib.gpib.GpibError: close() error: Iberr 23, invalid handle
Any help is greatly appreciated.
10-26-2018 02:42 PM
This error seems to be related to a mismatch of handles passed into that specific function. From the NI Error Documentation:
Error Condition: Input Handle is invalid.
Possible Cause: Several GPIB commands take in the input handle of the board or the device as an input parameter which can be the source of this error. This error can occur under several circumstances. Some scenarios are listed below:
Solutions:
Hope this helps,
10-26-2018 03:38 PM
The script still runs properly and completes. It's only as python closes that I see the error thrown. How does Python and pyVisa close? It seems to call a deconstructor that I either use incorrectly or it has a bug.
10-29-2018 01:32 PM
If you want to look at the exact way this closes, you can look into this at the PyVISA GitHub, but as PyVISA itself is an open-source wrapper and not an NI product, I'm not going to be the best resource on this. If you think that this is a bug, you can report it at https://github.com/pyvisa/pyvisa/issues.