PROTOCOL REFERENCE

Modbus function codes

The function code is part of the request's meaning. It selects an operation and, for data access, the address space. PDU address 0 under FC03 is not the same value as PDU address 0 under FC04.

01

Read coils and discrete inputs

FC01 reads coils: one-bit values that may also be written. FC02 reads discrete inputs: one-bit read-only values. Responses pack the requested states from the least-significant bit of the first data byte.

02

Read holding and input registers

FC03 reads holding registers, which may contain configuration, status, or measurements and may be writable through another function. FC04 reads input registers, the read-only register space. Each register is 16 bits; wider values span consecutive registers according to vendor-defined layout.

03

Write single and multiple values

FC05 writes one coil and uses 0xFF00 for ON or 0x0000 for OFF. FC06 writes one holding register. FC15 writes multiple packed coils; FC16 writes a contiguous block of holding registers. A successful echo confirms protocol acceptance, not physical process movement.

04

Diagnostics and identification

FC08 carries serial-line diagnostic subfunctions. FC11 and FC12 expose communication event state. FC17 reports a legacy server identifier. FC22 applies an AND/OR mask to one holding register. FC43 with MEI type 0x0E reads structured device identification where supported.

05

Exception responses set the high bit

A server that rejects FC03 returns 0x83 followed by an exception code. This is a valid protocol response and should not be reported as a transport timeout. Preserve the original function, address, quantity, Unit ID, and returned exception together.

  • 01 Illegal Function
  • 02 Illegal Data Address
  • 03 Illegal Data Value
  • 04 Server Device Failure
  • 06 Server Device Busy
  • 0A/0B gateway path or target failures
QUESTIONS

Before you connect.

Which function reads 4xxxx registers?+

FC03 reads holding registers commonly documented with the 4xxxx prefix.

Which function reads 3xxxx registers?+

FC04 reads input registers commonly documented with the 3xxxx prefix.

Does a successful FC03 prove FC06 is allowed?+

No. Readability does not prove writability; the device manual and operating state decide whether a write is permitted.

Why is the returned function code above 0x80?+

The server sets the high bit of the requested function code to indicate an exception response.

KEEP THE EVIDENCE

Use the reference beside the live protocol.

Browse documentation→