Latest posts

A Failed Wi-Fi Gateway for a Delta PLC: What a Packet Log Taught Me About Unverified Assumptions

A short case study for researchers, developers and engineering students.

TL;DR

I designed a sub-$7 wireless programming gateway for a Delta DVP-14SS2 PLC (ESP32 + RS-485 transceiver + arbitration relay). The whole design rested on one assumption: that Delta's COMMGR "Ethernet" driver sends raw serial frames over TCP. Before buying any hardware, I tested that assumption with a PC-side script that impersonated the gateway and logged what COMMGR sent.

The assumption was false. COMMGR sends Modbus TCP (with the 7-byte MBAP header), not raw serial data. A software layer translating Modbus TCP to Modbus ASCII kept COMMGR talking, but ISPSoft still rejected the connection with a model/firmware warning. The project failed as designed, and it failed cheaply.

1. Background and Design

On the target machine, the PLC's COM2 (RS-485) port is permanently wired to an HMI that acts as Modbus master and polls continuously. Two masters on one half-duplex bus corrupt each other, so the PLC can't be programmed from COM2 without disconnecting the HMI.

The proposed gateway placed an ESP32 and an RS-485 transceiver on COM2 through a normally-closed relay:

  • Idle: the relay is de-energised, the HMI stays connected and polling is uninterrupted. Power loss also leaves the HMI in control (fail-safe).
  • Session: when the PC opens a TCP connection, the ESP32 energises the relay, isolating the HMI and connecting itself. After an idle timeout, the relay releases.
  • Bridge: a transparent TCP-to-UART bridge, forwarding bytes unchanged in both directions.

2. The Hypothesis

H1: COMMGR's Ethernet driver, when pointed at an IP and port, sends the same bytes it would send on a serial line (Modbus ASCII, typically 7E1 on Delta COM2).

If H1 holds, a transparent bridge works. If it is false, the PLC receives bytes it cannot parse, no matter how correct the hardware is. H1 was the weakest link in the design, and it was testable at zero cost.

3. Method

A Python script on the PC listened on the TCP port configured in COMMGR (8899) and logged every packet it received. In COMMGR, I created an Ethernet driver pointing at the PC's own Wi-Fi adapter address, with:

  • the listening port,
  • 3 connect retries,
  • a 30 × 100 ms (3 s) connection timeout.

I then connected from ISPSoft to a real project and observed the traffic.

The script was then extended to emulate the full chain:

  1. Receive from COMMGR.
  2. Translate into a Modbus ASCII frame, as the PLC would see it.
  3. Generate a PLC reply.
  4. Translate the reply back and send it to COMMGR.

Note: step 3 was produced by the script, not by a physical PLC. This experiment therefore tests COMMGR/ISPSoft behaviour, not real PLC behaviour.

4. Results

Finding 1: H1 is false. COMMGR speaks Modbus TCP.

Every request began with an MBAP header. Example, decoded:

2b 7e | 00 00 | 00 06 | 00 | 03 | 14 0c | 00 01
  |       |       |      |    |     |       |
TransID Protocol Length UnitID FC  Start   Quantity
(0x2B7E)  (0)    (6)     (0)  (Read   (0x140C) (1)
                               Holding Regs)

A raw serial stream would have begun with 3A (the ASCII colon that starts a Modbus ASCII frame). It did not.

Finding 2: Translation is mechanically simple.

Dropping the MBAP header, mapping the unit ID to the station address, and wrapping the PDU in ASCII with an LRC checksum reproduces a valid Modbus ASCII frame. For the request above:

:0003140C0001DC

The LRC is -(00+03+14+0C+00+01) mod 256 = 0xDC.

The reply :0003020000FB converted back to 2b 7e 00 00 00 05 00 03 02 00 00, with the length field updated and the transaction ID echoed. I verified these checksums by hand.

Finding 3: The traffic is not only standard reads.

The log showed:

  • function codes 0x03 and 0x01,
  • a request for function 0x11 (Report Slave ID in standard Modbus) at the start of the session,
  • a function 0x67 request that I could not match to any public Modbus function. I did not determine its meaning.

Finding 4: ISPSoft rejected the link.

Even with translation working at frame level, ISPSoft displayed:

"Not support for current model type or firmware version!"

This is consistent with ISPSoft validating the device identity returned during the handshake, with the emulated replies not matching what it expects. I have not confirmed that cause. A real PLC replying through a correct gateway might pass this check, or might not.

5. Discussion

  • The failure was in an interface I didn't control. The ESP32, relay and firmware were not the problem. The vendor's protocol was.
  • Design artefacts are not evidence. Schematics, a bill of materials and firmware existed before the one decisive test, and none of them reduced the risk.
  • A transparent bridge is the wrong abstraction for this driver. The gateway must be protocol-aware: a Modbus TCP server on one side and a Modbus ASCII master on the other.
  • Vendor-specific behaviour dominates. Standard-looking Modbus traffic hid non-standard function codes and an identity check, so "it speaks Modbus" is not enough to guarantee compatibility.

6. Limitations

  • One PC, one ISPSoft version, one project, one PLC family.
  • No real PLC took part in the experiment, so Finding 4 can't be attributed to a specific cause.
  • Timing behaviour over Wi-Fi was not studied.

7. Where to Go from Here

  1. Protocol-translating gateway. It must forward the real PLC's identification replies faithfully, and it needs testing with real hardware.
  2. Virtual COM port on the PC (for example HW VSP3 or com0com) with a transparent bridge. This sidesteps the Ethernet driver, at the cost of PC-side software.
  3. Commercial hardware: a Delta Ethernet module, or an RS-485-to-Ethernet gateway with Modbus TCP support.

8. Takeaways

  1. List your assumptions and test the one that would sink the project first.
  2. Prefer tests that can fail cheaply, such as a packet logger.
  3. Treat vendor software as a dependency with unknown behaviour.
  4. A falsified hypothesis, documented honestly, is a valid engineering result.

Reproducibility note: the logger is about 80 lines of Python using only the standard library. Point any vendor driver at it and read the first bytes before building anything.

Leave a comment