Question

I'm using pyvisa to control a Signal recovery sr7225 lockin amplifier. Almost everything works as expected. There is only one problem, when the queried value is exactly zero and one queries in the floating point mode the following is returned

>>>import visa
>>>lockin = visa.instrument('GPIB::08')
>>>lockin.ask('X.') # Query X value in floating point mode
0.0E+00\x00

An ascii value is appended to the response string. I guess the appended ascii value of \x00 is a bug, but it means that I cannot use float() to convert the string response to float. How would you handle this?

Was it helpful?

Solution

simply

float(x.strip('\x00')) ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top