HART-IP Driver
Overview
The IP variant of HART (Highway Addressable Remote Transducer). It performs digital read/write on 4-20 mA industrial instruments through an IP gateway. Based on the HCF public HART-IP specification.
| Item | Value |
|---|---|
opc_type | HART |
| Implementation class | plantpulse.driver.protocol.hart.HARTDriver |
| Library | In-house Java implementation (based on HCF spec, no external library dependencies) |
| read | ✅ (cmd 1, 3, 13) |
| write | ✅ (cmd 6, 17, 18, 19, 22) |
| Security | None (the HART-IP spec itself provides no authentication/encryption) |
| Default port | 5094 (TCP) |
Class Structure
| Class | Role |
|---|---|
HARTDriver | Lifecycle / address parser / read·write dispatch / KeepAlive thread |
HartIpHeader | 13-byte HART-IP header (version, type, id, status, sequence, byteCount BE) |
HartCommand | HART command PDU builder — preamble + 0x82 + 5-byte address + cmd + byteCount + data + XOR |
HartChecksum | Longitudinal XOR (excluding preamble) |
HartDecode | float32 BE / packed-ASCII 6-bit decoder, communication status bit interpretation |
Wire Format
HART-IP 메시지 = 13-byte 헤더 + payload
byte 0 Version 1
byte 1 Message Type 0=Request 1=Response 2=Publish 3=NAK
byte 2 Message ID 0=Session-Init 1=Session-Close 2=KeepAlive 3=PDU
byte 3 Status / Error
byte 4-5 Sequence (BE)
byte 6-7 ByteCount (BE, 헤더 13 byte 포함)
byte 8-12 Reserved (0)
PDU payload (Message ID 3) =
Preamble(0xFF×N) + Start(0x82) + Address(5) + Command(1) + ByteCount(1) + Data(N) + XOR(1)
Handshake: connect() sends Session Init (master-type 1 byte + inactivity-close-time 4 byte BE) → receives Response. Afterwards, a background KeepAlive thread periodically sends Message ID 2.
OPC Registration Options
| Field | Meaning | Default |
|---|---|---|
opc_agent_ip / opc_agent_port | Gateway IP / port | (5094 if port is 0) |
options.master-type | primary / secondary | primary |
options.inactivity-ms | Session inactivity close time | 600000 (10 minutes) |
options.keepalive-ms | KeepAlive send interval | 30000 |
options.connect-timeout | TCP connect timeout | 5000 |
options.read-timeout | read SO timeout | 5000 |
Tag plc_address Format
| Notation | Meaning | Decoding |
|---|---|---|
1 or 1:pv | cmd 1 — Read PV | float32 BE (offset 3, after the 2-byte status) |
3:0 ~ 3:3 or 3:pv/sv/tv/qv | cmd 3 — PV/SV/TV/QV | 4 × float32 BE (simplified model) |
13 or 13:tag | cmd 13 — Tag 8 char | packed-ASCII (3 byte → 4 char) |
write addresses (together with address.getValue()):
| Notation | Meaning | value Format |
|---|---|---|
6 / polling-address | cmd 6 — Write Polling Address | integer 0..63 |
17 / message | cmd 17 — Write Message | 32-char packed-ASCII |
18 / tag / descriptor / date | cmd 18 — Tag/Descriptor/Date | tag|desc|DD/MM/YY or per sub-field |
19 / final-assembly | cmd 19 — Final Assembly Number | 0..16777215 |
22 / long-tag | cmd 22 — Long Tag (32 byte ISO-Latin-1) | arbitrary string |
Unsupported Areas
- WirelessHART (HART 7) burst mode, asynchronous publish reception (Message Type 2).
- Device-discovery commands such as cmd 0/cmd 50/cmd 9 — can be added.
- Short-frame addressing (other than long-frame).
- manufacturer/device-type matching in the 5-byte device address (currently zero-filled).
- Synchronous handling of keepalive responses — for simplicity, keepalive responses are ignored (can be reinforced with a separate receiver thread + seq correlation).
Test Coverage
test/java/plantpulse/driver/protocol/hart/
| Test | Verifies |
|---|---|
HartIpHeaderTest | 13-byte header round-trip |
HartChecksumTest | XOR against known vectors |
HartCommandTest / HartCommandWriteTest | cmd 0/1/3/13/6/17/18/19/22 PDU build |
HartDecodeTest / HartEncodeTest | float32 BE, packed-ASCII (both directions), BCD date |
HARTDriverAddressTest / HARTDriverWriteTest | Address parser + write dispatch |
HartSpecExtraTest | Additional spec conformance |
References
- HART-IP spec — FieldComm Group / HART Communication Foundation (member documentation).
- Code:
plantpulse-edge-driver/src/plantpulse/driver/protocol/hart/. - In production, TCP 5094 must be exposed on the gateway (e.g. ABB AC500-eCo, Pepperl+Fuchs HART Multiplexer).