Skip to main content

CRC32 calculation example for serial frame

Payload string (before framing):

command=/check_status&data=eyJkb2N1bWVudEV4dElEIjoiT1JERVItMTAwMSJ9&sign=ZWIyMmVmNWNhY2Q3ZWViZjJmMzc2ZjZlYWQzMWI4ZGM5NDllM2M4Mg==

CRC input rules:

  • Encode payload as UTF-8 bytes.
  • Compute CRC32 over payload bytes.
  • Replace CRC bytes 0x03 with 0x20 before writing CRC to frame.

Computed CRC:

  • crc32_hex = 61387ab8
  • CRC32_BE bytes = 61 38 7a b8

Final frame layout:

02 <payload_utf8_bytes> 61 38 7a b8 03

Where:

  • 02 is STX
  • 03 is ETX