Keysight VISA.NET Help
Formatting Raw Binary Data

Formatting Raw Binary Data

An array argument to be formatted as a raw binary array has a format specifier in the following form:

%y%[!ol|!ob][h|l|ll|z|Z]y

Modifier

Interpretation

Default Functionality

The argument is interpreted as an array of integers or floating point numbers.

Flags

!ol, !ob

Indicates whether the array elements are formatted as little-endian or big-endian.

'!ol' indicates little endian.

'!ob' indicates big endian, which is the default.

Length modifiers

H,l,ll

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.

Note that 'z' and 'Z' are not supported for raw binary blocks.

Size modifiers are required when formatting raw binary 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 raw binary arrays are not defined in IEEE-488.2 for messages that are sent to an instrument, but may be useful for non-IEEE 488.2 instruments.

Raw Binary Array Formatting Code Snippets

Remember that Printf is adding bytes to the formatted write buffer. In this case, Printf is writing the standard format for raw binary arrays.  Assume that the io variable is a valid reference to IMessageBasedFormattedIO.

Printf
Copy Code
Int16[] data = new Int16[] { 1, 2, 3};

// Adds a raw binary array of big-endian 16-bit integers.
io.Printf("%!obhy", data);
PrintfArray
Copy Code
unsafe
{
    Int16[] data = new Int16[] { 1, 2, 3 };
    fixed (Int16* pdata = data)
    {
        // Adds a raw binary array of big-endian 16-bit integers.
        io.PrintfArray("%!obhy", pdata);
    }
}

 

 

 

 


© Keysight Technologies 2015-2025