Template / Sum Protocol Frame
This command calculates the 8-bit sum over some bytes of the already generated destination data. The bytes to include into this calculation are specified by StartPos and Len, which specify the first byte beginning from the destination data and the number of bytes.
InitValue will be added to the sum of the specified bytes. Then all filters specified in Filters will be applied and the result will be stored at the TemplateCommand location.
If a marker is set, StartPos will be ignored and the marker position will be used as start instead (without removing the marker from the marker stack). If furthermore Len is 0xFF, all data up to the end of the destination data will be included in the calculation and the marker will be removed from the marker stack.
Template: 0xFF 0x08 0x19 0xFF Sum 0001 2 0x40 NoFilter
Destination data: 0xFF 0x08 0x19 0xFF 0x61
- Frame value: 0x1B15
|StartPos||Integer (16 bits)||-|
|Len||Integer (8 bits)||-|
|InitValue||Integer (8 bits)||-|
|Filters||Bit mask (8 bits)||
For every of these filter bits, a specific data conversion mechanism is specified. This mechanism is applied to a TemplateCommand if the filterbit is set.
The activated filters are applied ordered by there value. Starting with the smallest value.
|BcdToBin||Boolean (bit 0x80)||
Converts a BCD Number (must only contain nibbles 0-9, not A-F) to a binary number. Input and Output data are MSB encoded.
The length of the destination data is the length of the source data (in bytes) multiplied by 0.83048 (and rounded down to the next byte boundary).
Some source data's binary representation is longer than the calculated destination length. If such source data could occur, an additional leading zerobyte has to be inserted in front of the source data
|BinToAscii||Boolean (bit 0x40)||
Convert Binarydata to ASCII by converting the ASCII
characters 0x00-0x09 to 0x30-0x39 and 0x0A-0x0F to
|Unpack||Boolean (bit 0x20)||
Splits the high and the low nibble of each byte
into two separate bytes, where the high nibble is
set to 0.
|BinToBcd||Boolean (bit 0x10)||
Converts a binary Number to a BCD encoded number. Input and Output data are MSB encoded.
The length of the destination data is the length of the source data in bytes) multiplied by 1.2041 (and rounded up to the next byte boundary).
This is not exactly the inverse of BcdToBin, since the length may differ.
|SwapNibbles||Boolean (bit 0x08)||
Swap the higher nibble (bits 5-7) of each byte with
the lower nibble (bits 0-3).
|Pack||Boolean (bit 0x04)||
Merges two Bytes at a time to a single one by
removing the leading nibble (which has to be 0) of
|AsciiToBin||Boolean (bit 0x02)||
Convert ASCII to Binarydata by converting the ASCII
characters 0x30-0x39 to 0x00-0x09 and 0x41-0x49
(0x61-0x66) to 0x0A-0x0F.
|Reverse||Boolean (bit 0x01)||
Swap the first byte with the last one, the second
one with the next to last one and so on.