Modbus Function Code 24 (0x18): Read FIFO Queue Specification & Hex Guide
When a remote controller, power quality meter, or sequence-of-events recorder buffers timestamped faults or batch measurements internally, polling static Holding Registers (FC 03) risks missing rapid state transitions between SCADA scan cycles. To retrieve buffered 16-bit register records cleanly in chronological order, the Modbus Application Protocol Specification V1.1b3 defines Function Code 24 (0x18) — Read FIFO Queue.
Unlike standard register reads that take a starting address and quantity, FC 24 points to a single FIFO Pointer Address and lets the remote server return the exact count and contents of queued 16-bit words (up to 31 registers). This engineering guide breaks down the PDU layout, hex byte framing, exception rules, Python pymodbus implementation, and simulation in ModbusSimulator.
1. How Function Code 24 Works (V1.1b3 Specification)
Function Code 0x18 reads a First-In-First-Out (FIFO) queue of 16-bit registers located in the 4xxxx holding register address space:
- FIFO Pointer Address (2 Bytes): The master specifies the 16-bit 0-based wire address (
0x0000–0xFFFF) of the FIFO Pointer register, which tells the slave which queue to read—not a direct register count. - 16-Bit Byte Count & FIFO Count: Unlike FC 03 (which uses a 1-byte Byte Count), FC 24 uses a 2-byte Byte Count followed by a 2-byte FIFO Count (0 to 31), followed by
N16-bit Big-Endian register values. - 31-Register Ceiling: Because the Modbus serial/TCP PDU payload is capped,
FIFO Countmust be≤ 31(0x001F), yielding a maximumByte Countof64bytes (0x0040= 2 + 31×2).
2. Request & Response Hex Frame Analysis
Suppose a SCADA master queries FIFO Pointer Address 0x04DE (decimal 1246, corresponding to PLC register 41247) on Slave ID 1, and the queue currently holds two 16-bit event words: 0x01B8 and 0x1284.
Modbus RTU Request Frame (6 Bytes)
[Slave] [FC] [FIFO Pointer Hi Lo] [CRC-16 Lo Hi]
01 18 04 DE [CRC]
Modbus TCP Request ADU (12 Bytes)
[Trans ID] [Proto] [Len] [Unit] [FC] [FIFO Pointer]
00 01 00 00 00 06 01 18 04 DE
Modbus TCP Normal Response ADU
[Trans ID] [Proto] [Len] [Unit] [FC] [ByteCount] [FIFOCount] [Word 0] [Word 1]
00 01 00 00 00 0A 01 18 00 06 00 02 01 B8 12 84
| PDU Field | Hex Value | Size & Meaning |
|---|---|---|
| Function Code | 0x18 | 1 byte — Read FIFO Queue (decimal 24) |
| Byte Count | 0x0006 | 2 bytes — Remaining response payload bytes (2 + 2 × 2 = 6) |
| FIFO Count | 0x0002 | 2 bytes — Number of queued registers returned (2 words) |
| FIFO Value Register 0 | 0x01B8 | 2 bytes — Oldest queued 16-bit word (440 decimal) |
| FIFO Value Register 1 | 0x1284 | 2 bytes — Next queued 16-bit word (4740 decimal) |
3. Standard Exception Codes for FC 24
If the remote device rejects an FC 24 query, it replies with function code 0x98 (0x18 | 0x80) plus one of the standard Modbus exception codes:
| Exception Code | Name | Root Cause in FC 24 |
|---|---|---|
0x01 | Illegal Function | Target PLC/meter does not implement Function Code 24. |
0x02 | Illegal Data Address | The specified FIFO Pointer Address does not exist in the slave map. |
0x03 | Illegal Data Value | FIFO Count inside the slave exceeds the 31-register protocol limit. |
0x04 | Server Device Failure | Internal queue memory read error or hardware fault on the remote node. |
4. Python Implementation Using Pymodbus
from pymodbus.client import ModbusTcpClient
def poll_fifo_queue(host="127.0.0.1", port=502, pointer_addr=1246, slave_id=1):
client = ModbusTcpClient(host=host, port=port, timeout=2.0)
if not client.connect():
raise ConnectionError(f"Failed to connect to {host}:{port}")
resp = client.read_fifo_queue(address=pointer_addr, slave=slave_id)
if resp.isError():
print(f"FC 24 Error: {resp}")
else:
print(f"FIFO Count: {len(resp.values)} registers")
for idx, word in enumerate(resp.values):
print(f" FIFO[{idx}] = 0x{word:04X} ({word})")
client.close()
if __name__ == "__main__":
poll_fifo_queue()
5. Debugging Modbus Register Maps With ModbusSimulator
When commissioning SCADA telemetry or validating register maps before connecting to plant PLCs, use ModbusSimulator (Windows Modbus emulator, Modbus slave simulator, and Modbus TCP simulator) alongside raw hex logs to isolate address offsets, 16-bit vs 32-bit byte order, and timeout issues. Compare FC 24 against FC 23 (Read/Write Multiple Registers) and FC 07 (Read Exception Status).
Test Modbus TCP & RTU Devices Without Hardware
Download ModbusSimulator for Windows — unified Master + Slave simulator with live register grids, hex frame capture, and 30-day free trial.
Download Free 30-Day TrialFrequently Asked Questions
What is Modbus Function Code 24 (0x18)?
Function Code 24 is Read FIFO Queue, a Modbus command that retrieves up to 31 queued 16-bit registers from a FIFO buffer identified by a single 16-bit pointer address.
Why does FC 24 cap responses at 31 registers?
The Modbus V1.1b3 specification caps FIFO Count at 31 words so the entire response fits comfortably inside the standard 253-byte PDU ceiling.
What happens if the FIFO queue is empty?
The slave returns a normal 0x18 response with Byte Count = 0x0002 and FIFO Count = 0x0000 (zero data words).
How is Byte Count calculated in FC 24?
It is a 16-bit field equal to 2 + (2 × FIFO Count), accounting for the 2-byte FIFO Count field plus 2 bytes per returned register.