Skip to main content

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.

ItemValue
opc_typeHART
Implementation classplantpulse.driver.protocol.hart.HARTDriver
LibraryIn-house Java implementation (based on HCF spec, no external library dependencies)
read✅ (cmd 1, 3, 13)
write✅ (cmd 6, 17, 18, 19, 22)
SecurityNone (the HART-IP spec itself provides no authentication/encryption)
Default port5094 (TCP)

Class Structure

ClassRole
HARTDriverLifecycle / address parser / read·write dispatch / KeepAlive thread
HartIpHeader13-byte HART-IP header (version, type, id, status, sequence, byteCount BE)
HartCommandHART command PDU builder — preamble + 0x82 + 5-byte address + cmd + byteCount + data + XOR
HartChecksumLongitudinal XOR (excluding preamble)
HartDecodefloat32 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

FieldMeaningDefault
opc_agent_ip / opc_agent_portGateway IP / port(5094 if port is 0)
options.master-typeprimary / secondaryprimary
options.inactivity-msSession inactivity close time600000 (10 minutes)
options.keepalive-msKeepAlive send interval30000
options.connect-timeoutTCP connect timeout5000
options.read-timeoutread SO timeout5000

Tag plc_address Format

NotationMeaningDecoding
1 or 1:pvcmd 1 — Read PVfloat32 BE (offset 3, after the 2-byte status)
3:0 ~ 3:3 or 3:pv/sv/tv/qvcmd 3 — PV/SV/TV/QV4 × float32 BE (simplified model)
13 or 13:tagcmd 13 — Tag 8 charpacked-ASCII (3 byte → 4 char)

write addresses (together with address.getValue()):

NotationMeaningvalue Format
6 / polling-addresscmd 6 — Write Polling Addressinteger 0..63
17 / messagecmd 17 — Write Message32-char packed-ASCII
18 / tag / descriptor / datecmd 18 — Tag/Descriptor/Datetag|desc|DD/MM/YY or per sub-field
19 / final-assemblycmd 19 — Final Assembly Number0..16777215
22 / long-tagcmd 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/

TestVerifies
HartIpHeaderTest13-byte header round-trip
HartChecksumTestXOR against known vectors
HartCommandTest / HartCommandWriteTestcmd 0/1/3/13/6/17/18/19/22 PDU build
HartDecodeTest / HartEncodeTestfloat32 BE, packed-ASCII (both directions), BCD date
HARTDriverAddressTest / HARTDriverWriteTestAddress parser + write dispatch
HartSpecExtraTestAdditional 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).