# Template / ExtractBitField Protocol Frame

This command includes a bit field from the source data (phase 1) and converts it into an ASCII number. It can only be used after a preceding phase 1, see BitDataEnd.

The resulting number is returned with the most significant digits first. LSB-encoded source data will be converted automatically.

The following sample cuts bits 1-6, converts them to ASCII, and extends the number to 4 digits. This results in "0016".

Sample
0x5A
BitDataEnd Msb
ExtractBitField 0001 5 Unpack|BinToAscii 4

The next sample shows the difference between the MSB- and the LSB-first encoding. This command outputs "3456" as it is, but by specifying BitDataEnd Lsb instead, we would obtain "5634", since the input is interpreted as "0x78563412".

Sample
0x12345678
BitDataEnd Msb
ExtractBitField 0008 16 Unpack|BinToAscii 0

## Properties

• Frame value: 0x1B14

## Format

Name Type/Size Description
SrcFieldStartBit Integer (16 bits) Specifies the first bit (beginning with 0) to be taken from the phase 1 data. This is not necessarily a multiple of eight! Please note that 0 always corresponds to bit 0 of the first byte (no matter if LSB or MSB encoding is used).
SrcFieldBits Integer (8 bits)

Specifies the number of bits to be taken from the phase 1 data. This is not necessarily a multiple of eight!

If this value is 0, all data from SrcFieldStartBit to the end of the phase 1 template is taken.

Filter Bit mask (8 bits) Specifies the conversion rules for the data extracted from phase 1. Please note that this filter shall return an ASCII number by convention.

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 ``` 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 ```
DstFieldBytes Integer (8 bits)

Specifies the actual number of bytes of phase 2. If Filter returns ASCII formatted data, this value corresponds to the number of digits.

If this value is 0, it is automaticially set to the length of the SrcFieldBits, rounded up to a multiple of 8 and adapted to the converted format by Filter.

If this value is greater than SrcFieldBits , the most significant digits will be filled with zeros.

If this value is smaller than SrcFieldBits , the most significant digits will be removed.
{"ft_lang_label":"__label__en","ft_lang_prob":0.74810034,"math_prob":0.9506067,"size":4207,"snap":"2021-31-2021-39","text_gpt3_token_len":1234,"char_repetition_ratio":0.11015941,"word_repetition_ratio":0.10584958,"special_character_ratio":0.27739483,"punctuation_ratio":0.07692308,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9581665,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-07-26T16:43:17Z\",\"WARC-Record-ID\":\"<urn:uuid:020fd980-c010-42d9-b551-2e0ac0b12828>\",\"Content-Length\":\"12823\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b06e6c3b-28c5-4522-84c9-3dbaa6acaeaf>\",\"WARC-Concurrent-To\":\"<urn:uuid:81db8494-69bf-41d6-a9c6-d611efb5a1e6>\",\"WARC-IP-Address\":\"213.198.91.172\",\"WARC-Target-URI\":\"https://docs.baltech.de/refman/prot/template/extractbitfield.html\",\"WARC-Payload-Digest\":\"sha1:UPCYA23ZAEPK3OXSOCIDMU6CSHCI4ZVL\",\"WARC-Block-Digest\":\"sha1:M3KK53SCIXLAZMJRBPP6YY7ZHHX3SNFV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046152144.81_warc_CC-MAIN-20210726152107-20210726182107-00480.warc.gz\"}"}