Keysight VISA.NET Help
Formatting IEEE 488.2 Arbitrary Blocks

Formatting IEEE 488.2 Arbitrary Blocks

An array argument to be formatted as an IEEE 4882 arbitrary block has a format specifier in one of the following forms:

%b%[h|l|ll|z|Z]b

%B%[h|l|ll|z|Z]B

Modifier

Interpretation

Default Functionality

The argument is interpreted as an IEEE 488.2 arbitrary block containing an array of integers or floating point numbers.

Length modifiers

h,l,ll,z

Indicates the length of the elements in the binary data portion of the block:

  • No modifier indicates 8-bit integers.
  • 'h' indicates 16-bit integers.
  • 'l' (lowercase 'L') indicates 32-bit integers.
  • 'll' (lowercase 'LL') indicates 64-bit integers.
  • 'z' indicates 32-bit reals in IEEE 754 format.

Note that 'Z', which would indicate 64-bit reals in IEEE 754 format, is not supported for IEEE 488.2 blocks at this time.

All integers are formatted into IEEE blocks in big-endian format.

Size modifiers are required when formatting IEEE blocks. The default is 8-bit integers.

Size modifiers are required when formatting IEEE 488.2 arbitrary blocks and raw binary arrays. In these cases, the type of the array argument to Printf that corresponds to the format specifier must match the size modifier. For example, if the format specifier is "%ly", the corresponding argument must be an array of 32-bit integers.

Note that Printf automatically adds '\n' + END to the end of an indefinite length arbitrary block, so that the buffer is automatically sent to the instrument and flushed. This is how the instrument knows where the end of the block is.

IEEE 488.2 Binary Block Formatting Code Snippets

Remember that Printf is adding bytes to the formatted write buffer. The format of IEEE 488.2 arbitrary blocks is documented in the IEEE 488.2 specification, sections 8.7.9 and 8.7.10. Refer to this documentation for a precise description of what Formatted I/O is writing to the write buffer when formatting IEEE arbitrary blocks.

Note that an IEEE 488.2 indefinite-length arbitrary block includes a terminating newline and end, which causes the buffer to be written to the device and flushed as soon as the block has been successfully written to the Formatted I/O write buffer.

Assume that the io variable is a valid reference to IMessageBasedFormattedIO.

Printf
Copy Code
float[] data = new float[] { 1.1f, 1.2f, 1.3f};

// Adds an IEEE definite-length block of 32-bit reals.
io.Printf("%zb", data);

// Adds an IEEE indefinite-length block of 32-bit reals,
//   then sends buffer & flushes.
io.Printf("%zB", data);
PrintfArray
Copy Code
unsafe
{
    Int16[] data = new Int16[] { 1, 2, 3 };
    fixed (Int16* pdata = data)
    {
        // Adds an IEEE indefinite-length block of 16-bit integers,
        //   then sends buffer & flushes.
        io.PrintfArray("%hB", pdata);
    }
}

 

 

 

 


© Keysight Technologies 2015-2025