سؤال

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