HDLC encoding protocol

202 views Asked by At

I will have to use the HDLC protocol on a synchronous RS485, but I don't understand the encoding algorithm very well.

If I have, for example, this condition:

  • Address: 0x01 (1 byte)
  • Control: 0x02 (1 byte)
  • Data arary: [0]0x03 [1]0x04 [2]0xFF [3]0x05 [4]0x06 [5]0x07 (6 byte)
  • FCS: 0xC8A1 (2 byte) (calculated CRC-CCITT 16bit HDLC)

1) Is the FCS correct (0xC8A1)? (I calculated the FCS on Address, Control and Data: "0x01 0x02 0x03 0x04 0xFF 0x05 0x06 0x07")

2) Which is the HDLC packet correct?

  • "0x7E 0x01 0x02 0x03 0x04 0xFF 0x05 0x06 0x07 C8 A1 0x7E"
  • "0x7E 0x01 0x02 0x07 0x06 0x05 0xFF 0x04 0x03 A1 C8 0x7E" (Reverse data)

3) Whitch is the "bit train" before applying the "bit stuffing method"? (referring to the first example above)

  • 00000001 00000010 00000011 00000100 11111111 00000101 00000110 00000111 11001000 10100001
  • 10000000 01000000 11000000 00000011 11111111 10100000 01100000 11100000 00010011 10000101 (Reverse all bits)

4) Is correct, for the "bit stuffing method" start from the left?: (referring to the first example above)

  • 00000001 00000010 00000011 00000100 11111111 00000101 00000110 00000111 11001000 10100001
  • result: 00000001 00000010 00000011 00000100 11111011 10000010 10000011 00000011 11100010 00101000 01000000 (added two 0 bits (after 5 1bit) and added 0 bits for complete the byte on the right)

5) Is the correct order for send the data on RS485? (referring to the first example above after bit stuffing)

  • 00000001 00000010 00000011 00000100 11111011 10000010 10000011 00000011 11100010 00101000 01000000

    [0]0x7E [1]0x01 [2]0x02 [3]0x03 [4]0x04 [5]0xFB [6]0x82 [7]0x83 [8]0x03 [9]0xE2 [10]0x28 [11]0x40 [12]0x7E

thank you

0

There are 0 answers