beautypg.com

10 initializing struct variables from hex streams, Initializing struct variables from hex streams, Assignments for variables with fixed-length fields – Teledyne LeCroy Voyager Exerciser Generation Script Language Manual User Manual

Page 115

background image

Teledyne LeCroy

Voyager USB 3.0 Exerciser Generation Script Language Reference Manual

106

10.10 Initializing Struct Variables from Hex Streams

You can assign structure variables using hex streams. Rather than defining each field within a
structure variable, set the structure variable equal to a hex/byte stream. The fields within the
structure variable are then assigned based on the offset.

10.10.1 Assignments for Variables with Fixed-length Fields

For structure variables composed of fixed length fields (so that the structure variable has fixed
length), assignments by hex streams fill the fields in offset order. Any overflow from the
hex stream is truncated. For example, assigning an eight-byte structure variable to a twelve-byte
hex stream loses the last four bytes of the hex stream.

Example

Packet

GenericSample

{
Field_1 : 8
Field_2 : 32
Field_3 : 16
Field_4 : 4
Field_5 : 3
Field_6 : 1
}

GenericSample $Struct_Var

Main

{
$Struct_Var = {

01

02 03 04 05 06 07 08

}


# The following is the same as the line above.

$Struct_Var{
Field_1 =

1

Field_2 = {

02 03 04 05

}

Field_3 = {

06 07

}

Field_4 =

0

Field_5 =

4

Field_6 =

0

}
}