I have a Rhode&Schwarz NRP-Z21 power meter, for which a passport driver exists to make it work with VISA. Unfortunately, PyVISA assumes it can set several attributes that are not supported by this driver.
Attached is a patch with three changes:
- in visa.__set_term_chars() do not fail when trying to
clear VI_ATTR_TERMCHAR_EN in the case that
term_chars=None
- in visa.__set_send_end(), do not fail if the argument
passed is None
- in vpp32.parse_resource_extended(), do not emit
warning messages.
This allows me to use the NRP successfully:
import visa
# it happens to be first in the list
i=visa.instrument(visa.get_instruments_list()[0],
send_end=None,term_c
File Added: pyvisa-passport.patch
patch fixing the problem for me
That code snippet should read:
import visa
# it happens to be first in the list
i=visa.instrument(visa.get_instruments_list()[0],send_end=None,term_chars=None)
print i.ask("*IDN?")
PyVISA is an inactive project waiting for a new maintainer. If you are interested, send an email to bronger@physik.rwth-aachen.de
One thing I don't like about the attached patch is that term_chars=None already has a particular meaning, and it doesn't seem prudent to attach another meaning to that, being the attribute is unsupported by the hardware, especially since that leads to the blind try/except in __set_term_chars. My instinct says that we should have an `Unsupported` object to clarify that the attribute is unsupported, and then your instrument could be constructed as:
visa.instrument(visa.get_instruments_list()[0],send_end=visa.Unsupported,term_chars=visa.Unsupported)
Another disagreement is the change to check_status when calling viParseRsrcEx. These warnings are useful for certain instruments, and eliminating them all for everyone seems heavy-handed.