PortDock

Using a PC as a Modbus TCP ↔ RTU gateway

Bridge Modbus TCP SCADA/HMIs to RS-485 RTU devices via the PC's COM port with PortDock Serial (from 0.10.0): one request at a time, exceptions 0B/0A, unit ID 0.

Tools for this guideSerial Windows program · freeModbus Master Windows program · freeModbus RTU ↔ TCP Frame Converter web · no installModbus Frame Decoder web · no install

SCADA, HMIs and PC programs often speak only Modbus TCP, while the devices (drives, temperature controllers, power meters) are RS-485 Modbus RTU. The usual answer is a gateway box, but for testing, commissioning or a small machine a PC with an RS-485 adapter can do the job. PortDock Serial's «Port sharing» mode «Modbus TCP ↔ RTU gateway» (from 0.10.0) does exactly that.

1. What the gateway does

A Modbus TCP request is a 7-byte MBAP header (transaction ID 2 · protocol ID 2 (always 0) · length 2 · Unit ID 1) followed by the PDU (function code + data). RTU is a 1-byte unit address + the same PDU + a 2-byte CRC. The gateway moves the Unit ID into the address byte, appends the CRC and sends it on the bus; from the reply it strips address and CRC and returns it with the same transaction ID.

BytesMeaning
00 01 00 00 00 06 03 03 00 00 00 02TCP request — transaction 1, length 6, Unit ID 3, FC03 two registers from 0
03 03 00 00 00 02 C5 E9RTU request on the bus — unit 3, same PDU, CRC E9C5 (low byte first)
03 03 04 00 64 00 C8 99 BADevice RTU reply — values 100, 200
00 01 00 00 00 07 03 03 04 00 64 00 C8TCP reply — transaction 1 unchanged, length 7
00 01 00 00 00 03 03 83 0BNo reply — exception 0B (gateway target failed to respond)

2. Preparation

3. Turning it on

Windows lets you open ports below 1024 without administrator rights, so 502 works as is. If another Modbus server (a Modbus Slave simulator, for example) already has 502, starting tells you which program — pick another number. For SCADA on another PC, turn on «Allow other PCs to connect (0.0.0.0)» — Modbus has no authentication, so only on a network you trust.

4. One request at a time — why it can look slow

Two-wire RS-485 is half-duplex: only one frame can be on the bus at a time. So the gateway puts requests from all clients in one line, sends the next one only after the previous reply (or timeout), and keeps 3.5 characters (1.75 ms above 19200 bps) between frames. However fast the TCP side is, the serial speed sets the throughput.

5. Unit ID 0 and broadcast

In RTU, address 0 is broadcast — every device takes the write and nobody replies. By default the gateway does not pass Unit ID 0 on to RS-485 and answers with exception 0A (no route), so a stray request cannot write to every device on the bus. With «Unit ID 0» set to «Broadcast» (and, if you set an allowed-unit list, 0 included in it) the gateway sends to address 0, waits for no reply and sends none to the client (use it for write functions only). Some SCADA packages always send Unit ID 0; for those choose «Send to the default unit» and enter the device address.

6. Reading the log and statistics

7. When to buy a gateway box

If the PC shuts down or sleeps, the gateway stops too. Around-the-clock machines, sites with no room for a PC, or several separate buses call for a dedicated gateway. A PC gateway is good for commissioning, testing, temporary links — and for checking SCADA settings and device replies before you buy the box.

Sources

Published 2026-10-31