RS-485 Modbus RTU Hex Frame Validator & CRC-16 Checker

Paste any captured RS-485 Modbus RTU hex dump to verify CRC-16/MODBUS integrity, spot swapped CRC bytes and inspect t1.5 / t3.5 bus timing.

Jump to results

Inputs

Frame mode & addressing
Raw validation & RS-485 bus
Include trailing 2-byte CRC (Lo then Hi). Used in Validate mode.

Results

Estimates
Frame CRC Valid01 03 00 00 00 0A C5 CD
Computed CRC-16
0xCDC5
Wire CRC order (Lo Hi)
C5 CD
Slave ID & Function
ID 1 · Read Holding Registers (0x03)
Frame length / air time
8 bytes · 9.17 ms
Inter-char timeout (t1.5)
1,719 µs
Frame silent gap (t3.5)
4,010 µs
RTU frame byte map · 8 bytes
B0 01 B1 03 B2 00 B3 00 B4 00 B5 0A B6 C5 B7 CD CRC-16/MODBUS: 0xCDC5 · Wire order: C5 CD (Lo → Hi)
  • Slave ID
  • Function Code
  • Address / Payload
  • CRC-16 Lo / Hi
Frame field breakdown
FieldBytes (Hex)Byte count
Slave ID011
Func 0x03031
PDU Data00 00 00 0A4
CRC LoC51
CRC HiCD1
Copyable C99 & Python 3 CRC-16/MODBUS functions
#include <stddef.h>
#include <stdint.h>

/* CRC-16/MODBUS: init 0xFFFF, reflected polynomial 0xA001, wire order Lo then Hi */
uint16_t modbus_crc16(const uint8_t *buf, size_t len) {
  uint16_t crc = 0xFFFFU;
  for (size_t i = 0; i < len; ++i) {
    crc ^= (uint16_t)buf[i];
    for (int bit = 0; bit < 8; ++bit) {
      if (crc & 0x0001U) crc = (uint16_t)((crc >> 1) ^ 0xA001U);
      else crc >>= 1;
    }
  }
  return crc;
}

/* Test vector: 01 03 00 00 00 0A C5 CD (CRC=0xCDC5, wire: 0xC5 0xCD) */
static const uint8_t frame_pdu[6] = { 0x01, 0x03, 0x00, 0x00, 0x00, 0x0A };
def modbus_crc16(data: bytes) -> int:
    crc = 0xFFFF
    for b in data:
        crc ^= b
        for _ in range(8):
            crc = ((crc >> 1) ^ 0xA001) if (crc & 1) else (crc >> 1)
    return crc & 0xFFFF

pdu = bytes.fromhex("01 03 00 00 00 0A")
crc = modbus_crc16(pdu)
rtu_frame = pdu + crc.to_bytes(2, "little")
assert rtu_frame.hex(" ").upper() == "01 03 00 00 00 0A C5 CD"
print(rtu_frame.hex(" ").upper())

Received CRC 0xCDC5 matches computed CRC-16/MODBUS 0xCDC5.

Debug captured RS-485 logic-analyzer and serial hex dumps

When bringing up a new RS-485 bus, a single flipped bit, missing 120 Ω termination resistor or swapped CRC byte order causes silent slave drops. Paste raw space-separated or `0x`-prefixed hex bytes directly in Validate mode to verify the trailing 2-byte CRC immediately.

If the checksum fails, the calculator displays both the received CRC and the exact expected CRC in wire order so you can distinguish a byte-swap bug from physical line noise.

Formulas

  • Received CRC = (Frame[N−1] << 8) | Frame[N−2]
  • Valid iff Received CRC == CRC-16/MODBUS(Frame[0 .. N−3])
  • 9600 bps framing: t1.5 = 1,719 µs, t3.5 = 4,010 µs

Worked example

Validating `01 03 00 00 00 0A C5 CD` confirms Slave ID 1, FC03, computed CRC 0xCDC5 matching received 0xCDC5 (Valid). Changing the final byte to CC immediately flags CRC Invalid.

Frequently asked questions

How can I tell if my firmware swapped CRC high and low bytes?

If the expected CRC hex digits are the exact byte-reversal of your received CRC (e.g. 0xC5CD instead of 0xCDC5), reverse the transmit order to send CRC Lo first.

Why do captured RS-485 frames have leading 0xFF or trailing 0x00 bytes?

Releasing the RS-485 DE/RE driver enable too early or lacking fail-safe bias resistors lets the differential line float, injecting phantom glitch bytes.

Can I validate Modbus slave response frames as well as master requests?

Yes. CRC-16/MODBUS applies identically across the entire PDU of both master requests and slave responses of any length from 4 to 256 bytes.