Let's start building our decoder. We will start out with the bare bones and build from there. Some of the terms you have already seen in the preceding pages, while others are going to be new.
We will start our decoder by writing a decoder for FP's Set Actuator command. The structure for this command is:
"Fictitious Protocol" 0x7f000000
DECODE
FIELD command_code (Fixed 1 Byte) (Hex) "Command"
FIELD actuator_number (Fixed 1 Byte) (Decimal) "Actuator Number"
FIELD actuator_value (Fixed 2 Bytes) (Decimal) "Value to set"
FIELD checksum (Fixed 1 Byte) (Hex) "Checksum"
END_MAIN_PATH
The first element in the file is the string "Ficititious Protocol". This is the name of the decoder as you wish it to appear in the protocol analyzer. As you remember, this is the Heading section. The name appears in the Protocol Stack Wizard and also in the Summary and Decode panes on the Frame Display.
The second element is the Decoder ID. Every decoder must have a unique Decoder ID. The Decoder ID can be expressed in either decimal or hexadecimal, but as they are rather large numbers, we use hexadecimal by convention. You recognize this as a part of the Reference section.
The next element is a statement reading simply "DECODE", which must be placed just prior to the first executable statement.
One thing to note here as we continue is that writing decoders is not a linear process. Even though a script is made up of sections that should appear in a certain order, you will commonly work in different parts of the script and different times.
Let's start with the Field Statement. Field Statements are found in the Executable section.