Template / VarDataClip Protocol Frame

Is identical to the VarData TemplateCommand, except that it inserts the data also if the source data's length is shorter than StartPos + Len. In this case the inserted data will be shorter than Len

For Autoread Templates, this command is supported starting with firmware 1100 v2.14.00.

Properties

Format

Name Type/Size Description
StartPos Integer (16 bits) -
Len 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. 0x01 0x23 0x45 => 0x30 0x39

Note the following restrictions:
  • The largest BCD number this filter can convert is the following 39-digit number (20 bytes): 0x03 0x40 0x28 0x23 0x66 0x92 0x09 0x38 0x46 0x34 0x63 0x37 0x46 0x07 0x43 0x17 0x68 0x21 0x14 0x55
  • The destination length (in bytes) is calculated by multiplying the source data length by 0.83048 and rounding down to the next byte boundary.

    If the source data's binary representation is longer than the calculated destination length, the conversion fails. Example: Source data (BCD): 0x12 0x34 Source data length: 2 bytes (4 digits) Converted data (binary): 0x04 0xD2 Actual destination data length: 2 bytes Calculated destination data length: int(2 bytes * 0.83048) = 1 byte

    The maximum BCD number convertible for a given source data length can be calculated as follows: 2 ^ {int(src_len * 0.83048) * 8} - 1

    For example, for a 2-byte BCD number, the largest convertible value is 255: 0x02 0x55 => 0xFF

    If the source data may exceed the maximum convertible BCD number, insert an additional leading zero byte in front of it: 0x00 0x12 0x34 => 0x04 0xD2
BinToAscii Boolean (bit 0x40) Convert Binarydata to ASCII by converting the ASCII characters 0x00-0x09 to 0x30-0x39 and 0x0A-0x0F to 0x41-0x49. 0x01 0x0A -> 0x31 0x41
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. 0x01 CF => 0x00 0x01 0x0C 0x0F
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. 0x04 0xD2 => 0x12 0x34
SwapNibbles Boolean (bit 0x08) Swap the higher nibble (bits 5-7) of each byte with the lower nibble (bits 0-3). 0x12 0x34 0xEF => 0x21 0x43 0xFE
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 each byte. 0x03 0x0F -> 0x3F
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. 0x31 0x41 -> 0x01 0x0A
Reverse Boolean (bit 0x01) Swap the first byte with the last one, the second one with the next to last one and so on. 0x12 0x3D 0xEF => 0xEF 0x3D 0x12