Query over TCPIP that should timeout instead returns a blank string?
See original GitHub issueAlthough it should be raising a timeout error, all I get back is the empty string and PyVisa continues on as if everything is alright.
I’ve traced it all the way down to rpc.Client.make_call()
(link) and the query is definitely returning error code 15
, which represents a timeout according to the vxi11.ErrorCodes
enum (link).
It looks like the only possible places that the error would be raised are in highlevel.PyVisaLibrary._return_handler()
(link) and highlevel.PyVisaLibrary.list_resources()
(link), and neither of those seem to be hit for some reason.
I’m having a hard time tracking this down, but it’s forcing us to roll back to installing a more commonly used VISA lib, and we dislike that very much. 😉
Any thoughts as to why this might be happening?
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (9 by maintainers)
Top GitHub Comments
Hey @hgrecco,
I’ve researched a bit more, and it looks like
highlevel.PyVisaLibrary._return_handler()
(link) might never actually be called, which would explain why read and write timeouts aren’t being handled properly. In fact, a comment from the docstring explicitly statesTODO: THIS IS JUST COPIED PASTED FROM NIVisaLibrary.
Debugging my way through a query that times out using the standard NI Visa (and thus
pyvisa.ctwrapper.highlevel.NIVisaLibrary
), I believe I discovered a handful of things.NIVisaLibrary._init()
callsfunctions.set_signatures(self.lib, errcheck=self._return_handler)
(link), which is what I believe is settingNIVisaLibrary._return_handler()
to handle return data fromNIVisaLibrary.read()
andNIVisaLibrary.write()
.PyVisaLibrary
doesn’t seem to do anything equivalent to that, which is why I think errors like timeout are getting ignored when they’re clearly detected at lower levels._init()
instead of the built-in__init__()
. Is there a reason for creating your own init function instead of making use of the one Python provides?vxi11.ErrorCodes
enum (link) has a nice (but still pared down, I believe) list of error codes to use,tcpip.TCPIPInstrSession.read()
incorrectly returns all errors asStatusCode.error_io
(link). This means that even when timeout errors are detected properly, they (and all other errors) are masked under the genericStatusCode.error_io
label (which translates toVI_ERROR_IO
in the output.)These two things seem pretty major as far as parity with the NI Visa backend goes, and I’d love to get them resolved so we can keep using this backend ourselves.
For now, I’ve made the following changes to pyvisa-py files on our end that seems to get us in the right direction:
highlevel.PyVisaLibrary.read()
andhighlevel.PyVisaLibrary.write()
to properly handle translation (and raising!) of pyvisa error codes. The modifications look like this:tcpip.TCPIPInstrSession.read()
andtcpip.TCPIPInstrSession.write()
, although I’m not confident this is the correct way to handle things, and even if it is they could do with being fleshed out beyond this:Please feel free to correct me if I’m wrong on any point(s), since I’m by no means well versed in the code structure. I’m just someone with a vested interest in a pure-Python VISA backend and trying to make sure the problems we encounter are our own and not the packages we use. 😉
Let me know what’s the best way I can help, or if there’s anything else you need from me, but I’d love to see this get resolved. I’ve always hated having to install a full VISA lib, so pyvisa-py really is a godsend for me.
Closed by #100