Definite-Length Block Response Data

The definite-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 (eg, integers, floats).
  • The endianness of the returned data.
  • The data's header bytes (IEEE format) that indicates the number of bytes being returned.

Before we explain these three subjects, here is a small snippet of Python code that demonstrates the return of definite-length block data.

Example Code Snippet

Copy

import visa  # import VISA library
...
FlexDCA.read_termination = ''
FlexDCA.write_termination = ''
endianness = FlexDCA.query(':SYSTem:BORDER?')
FlexDCA.write(':SYSTem:BORDER LENDian')
data = FlexDCA.query_binary_values(:WAVeform:EYE:INTeger:DAta?,
    datatype=L,
    container=list,
    is_big_endian=False,
    header_fmt='ieee')
FlexDCA.write(':SYSTem:BORDER ' + endianness)
...
...

    

Data Type Returned

When your program receives definite-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. FlexOTO command topics in this help that return definite-length block data 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 library. Refer to the documentation for your programming language for the exact command and specifiers that you should use.

Common Data Type Specifiers
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

Data Header Bytes

It is very likely that when querying definite-length block data you use a command that is provided by your programming language that automatically strips out the IEEE header. In this case, all you'll need to do is maybe specify in the command that the header's format is IEEE. If not, the rest of this section shows you how to manually interpret this header so as to know how many actual data bytes are returned.

The syntax is a pound sign (#) followed by a non-zero digit representing the number of following digits (decimal integer) that define the number of 8-bit data bytes being sent. This is followed by the actual data. For example, when transmitting 3000 bytes of data, the syntax would be:

#43000<3000 bytes of data>

Where:

  • 4 represents the number of characters used to state the number of data bytes.
  • 3000 represents the number of bytes to be transmitted.

Endianness of Returned Definite-Length Block Data

To correctly interpret definite-length block data, you must know the endianness (byte order) of the returned data (integers or real) from FlexOTO and you will must likely need 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.

If you plan to change FlexOTO's current endian setting, it is a good practice to query FlexOTO'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 preset (:SYSTem:FACTory), sets little endian. 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.

The ability to specify endianness requires FlexDCA revision A.04.00 and above. Prior to revision A.04.00, the endianness of returned block data was always LSB (Least Significant Byte) first.

Queries That Returns Block Data