You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with an instrument that only provides responses terminated with CRLF ('\r\n'). I see that VISA doesn't support multi-character read terminations, instead treating the final character, e.g. LF, as a termchar. I also see that pyvisa provides some minimal support on top of that by raising a warning if a read yields a string that ends with the termchar but not the full termination string:
"read string doesn't end with ""termination characters", stacklevel=2
)
returnmessage
In my case, the instrument actually returns multi-line responses (with LF as delimiter) terminated with a final CRLF, so the only workaround would be to do multiple VISA reads until we get a CRLF and concatenate the responses. I do plan on implementing this, but I am wondering: would it make sense for pyvisa to provide this kind of added support for multi-character read terminations? I think it would be natural to implement this workaround at the pyvisa level rather than in client code, but there's of course an argument to be made to keep the library more a wrapper around VISA routines rather than to introduce additional features/complexity/abstraction.
The text was updated successfully, but these errors were encountered:
For the case of multiple reads to collect a response.
I did this last week for a power meter with known number of reads to collect calibration data from it:
inst.write('SI') # Command for calibration data, follow with read() 31 timescalibration_data= [inst.read().strip() foriinrange(1,32)]
Just to be clear — I'm aware that one can just call MessageBasedResource.read() multiple times to read a multi-line response. As I wrote, I'm opening this issue to ask whether it makes sense to include support in pyvisa to handle the situation where a single logical response (terminated by a multi-char string) must be read by VISA as a sequence of individual reads because the final character of the termination string occurs in the body of the response.
I'm working with an instrument that only provides responses terminated with CRLF (
'\r\n'
). I see that VISA doesn't support multi-character read terminations, instead treating the final character, e.g. LF, as a termchar. I also see thatpyvisa
provides some minimal support on top of that by raising a warning if a read yields a string that ends with the termchar but not the full termination string:pyvisa/pyvisa/resources/messagebased.py
Lines 493 to 497 in 6bca992
In my case, the instrument actually returns multi-line responses (with LF as delimiter) terminated with a final CRLF, so the only workaround would be to do multiple VISA reads until we get a CRLF and concatenate the responses. I do plan on implementing this, but I am wondering: would it make sense for
pyvisa
to provide this kind of added support for multi-character read terminations? I think it would be natural to implement this workaround at thepyvisa
level rather than in client code, but there's of course an argument to be made to keep the library more a wrapper around VISA routines rather than to introduce additional features/complexity/abstraction.The text was updated successfully, but these errors were encountered: