문제

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?

도움이 되었습니까?

해결책

simply

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top