Keysight VISA.NET Help
Reading Raw Binary Data

Reading 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]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 also 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.

For Scanf, output array sizes are calculated from the size of the data. For ScanfArray, which is unsafe, the calling program must allocate an array that is guaranteed to be large enough to hold the parsed array.

Size modifiers are required when formatting raw binary arrays. The default is 8-bit integers.

If an element in the block exceeds the maximum value of the type specified by the length modifier or the output argument, the Scanf method will throw an exception.

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 Scanf 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.

IEEE 488.2 Binary Block Parsing Code Snippets

Remember that Scanf is reading bytes from the formatted read buffer. In this case, Scanf is reading the standard format for raw binary arrays.  Assume that the io variable is a valid reference to IMessageBasedFormattedIO.

Flags
Copy Code

// The read buffer contains an raw binary array with 5 16-bit integers with

//   values { 1, 2, 3, 4, 5 }

 

// Returns nothing and consumes the buffer.

Int32[] out1;

io.Scanf("%*lb", out out1);

ScanfArray
Copy Code

// The read buffer contains a raw binary array with 5 16-bit integers with

//   values { 1, 2, 3, 4, 5 }

 

// Returns { 1, 2, 3, 4, 5 } and consumes the buffer.  Memory must be allocated

//   by the calling program.

Int32[10] out1;

io.ScanfArray("%lb", out1);

 

 

 

 


© Keysight Technologies 2015-2025