A BLOCK has the following structure:
STX BN data ETX LRC DRC
Where
BN Block Number (Modulo-2). This number is bumped by 1 for each
Transmitted Block except in the case of re-transmission.
data Up to 512 bytes of LOGICAL LAYER DATA. If each byte of data
required a DLE sequence then 1024 bytes would be present
LRC LONGITUDINAL REDUNDANCY CHECK. The EVEN PARITY of all
LOGICAL LAYER DATA characters bit columns (excluding the STX
and all DLE characters) but including the ETX character. Note that the
LRC may take on a value of one of the used CONTROL
CHARACTERS but NO DLE is needed since the LRC ALWAYS follows
the ETX character.
DRC DIAGONAL REDUNDANCY CHECK. The even parity of all
LOGICAL LAYER DATA characters bit diagonals (excluding the STX
all DLE characters) but including the ETX character. This is formed
using the following algorithm:
DRC = (Rotate Right DRC) XOR (Character).
Note that the DRC may take on a value of the control characters but no
DLE is needed, since the DRC always follows the ETX and LRC character.
2.3. Steps in calculating DRC
1. Set the first character after STX as the initial value of the DRC variable.
2. Rotate DRC right one Bit position. Example.- Byte hex 3D becomes hex 9E after
rotation (0011 1101 -> 1001 1110).
3. Get next character from the message block. Exclusive OR this character with
the Rotated DRC and place the result into DRC.
4. If this character was an ETX, then DRC calculation done.
5. Otherwise, go to step 2.
For example, the block, <STX>0<SOM>SM;A;BA<EOM><ETX> will produce
DRC as hex 34.
Partager