Indefinite-Length Block Response Data
The indefinite-length block data format allows any type of binary device-dependent data to be transmitted over the system interface as a series of 8-bit binary data bytes. Examples of querying definite-length block data would be integers, reals (floats), and large quantities of data or 8-bit extended ASCII codes. To ensure the correct interpretation of the queried data, you must know the following:
- The data type being returned (for example, integers, floats).
- The endianness of the returned data.
Before we explain these two subjects, here is a small snippet of Python code that demonstrates the return of indefinite-length block data.
Example Code Snippet
import pyvisa # PyVISA package
...
endianness = Infiniium.query(':SYSTem:BORDer?')
Infiniium.write(':SYSTem:BORDer LENDian')
data = Infiniium.query_binary_values(':WAVeform:YFORmat:IBLock:FLOat:YDATa?',
datatype='f',
container=list,
is_big_endian=False)
Infiniium.write(':SYSTem:BORDer ' + endianness)
...
...
Data Type Returned
When your program receives indefinite-length block data, the program needs to know the data type being returned. That is how many bytes are used to express an integer or a floating-point number. The program must know this to successfully convert the bytes to a number. Otherwise, the numbers returned will be spectacularly wrong.
You must specify this data type in your program language's command that you use to query the data. In this help, descriptions of commands that return indefinite-length block data will indicate the data type being queried. The specifiers for your language will most likely follow the IEEE standard. The following table shows the specifiers use in Python's PyVISA package. Refer to the documentation for your programming language for the exact command and specifiers that you should use.
| Specifier | Data Type | Number of Bytes |
|---|---|---|
| c | ASCII char (unsigned) | 1 |
| B | bytes, binary (unsigned) | 1 |
| i | integer (signed) | 4 |
| I | integer (unsigned) | 4 |
| h | short integer (signed) | 2 |
| H | short integer (unsigned | 2 |
| l | long integer (signed) | 4 |
| L | long integer (unsigned) | 4 |
| e | float | 2 |
| f | float | 4 |
| d | double | 8 |
Block Format
With indefinite-length blocks, there is no limit on the number of waveform data points that are returned. It is recommended that any new programs use indefinite-length blocks to send waveform data points. The waveform data response for indefinite-length blocks is as follows.
The syntax is a pound sign (#) followed by one zero digit. This is followed by the actual data. For example, when transmitting 3000 bytes of data, the syntax would be:
#0<3000 bytes of data>
Where:
- 0 indicates that an indefinite-length block follows.
Endianness of Returned Block Data
To correctly interpret block data, you must know the endianness (byte order) of the returned data (integers or real), and you will most likely have to specify this same endianness in your program language's command that is used to query the data. Endianness can be set to "little endian" order in which the least significant byte is sent first and the most significant byte sent last. Or, the endianness can be set to "big endian" order in which the most significant byte is sent first and the least significant byte sent last.
To specify or query the endianness setting for binary block data, use the :SYSTem:BORDer command. The endianness setting applies to all binary queries except for :DISK:FILE:READ? query.
If you plan to change Infiniium's current endian setting, it is a good practice to query Infiniium's current endian setting and restore the setting when your program completes. This will avoid other programs having errors due to assuming a particular endianness setting.
After a factory default (:SYSTem:FACTory), little endian is set. A default setup (:SYSTem:DEFault) does not affect endianness.
Be aware that VXI plug-and-play drivers can change the endianness setting. As a result always explicitly set the endianness in your program before transferring any binary data.