Hi Torsten, Florian, Gregor, and Kevin,
first of all I would like to thank all of you for your excellent efforts on providing this truly helpful library.
I am attempting to fetch values in 64-bit binary floating format from an HP network analyzer trough an NI USB2488HS device.
I turned the device into the desired mode (64-bit binary float).
Now using "my_instrument.ask_for_values('DT1')" fails at this point (as expected) and returns:
File "C:\Python27\lib\site-packages\pyvisa\visa.py", line 449, in read_values
if format & 0x01 == ascii:
TypeError: unsupported operand type(s) for &: 'str' and 'int'
Using the documentation on:
http://pyvisa.readthedocs.org/en/latest/instruments.html#reading-binary-data
did not help solving the problem.
First I tried the following line
my_instrument = instrument("GPIB0::11", values_format = double) to replace
my_instrument = instrument("GPIB0::11")
However, I had to change the argument into a string 'double' since there is no other way to assign a value to the **keyw. This made me already a little suspicious.
Hunting through "visa.py" (in "$Revision: 344 $") I noticed that in line 306 to 309 the translation is set as:
ascii = 0
single = 1
double = 3
big_endian = 4
This lead me to the assumption that the help (link) is misleading and an integer should be used instead: For instance to read double:
my_instrument = instrument("GPIB0::11", values_format = 3) or
my_instrument.ask_for_values('ask', format=3).
Now, assigning 0 for ASCII works fine just like the previous code. However changing the response of the instrument again to 64-bit binary with values_format = 3, triggers a new error:
File "C:\Python27\lib\site-packages\pyvisa\visa.py", line 463, in read_values
raise InvalidBinaryFormat
pyvisa.visa_exceptions.InvalidBinaryFormat: unrecognized binary data format
I have tried all values 1,2,3,and 4 without success.
Using 0, the “ascii”-mode seems to fetch data. But I am only receiving a list of 57 entries which are wrong values while the device is in binary mode.
First of all is this an error in the documentation and for single the value 1 and for double the value 3 should be assigned to values_format and format, respectively?
And moreover, do you have any solution or idea for me in order to allow to fetch data in binary mode in my specific case?
Thank you very much for your help,
Tobi