KV Host Link Protocol for Rust
Async Rust implementation of the KEYENCE KV Host Link protocol, aligned with the public Python, .NET, and Node-RED Host Link libraries.
Scope
- TCP and UDP Host Link transport
- full low-level Host Link command surface from the
.NETreference - queued high-level helper API for typed reads/writes, comment reads, named snapshots, and polling
hostlink_verify_clientwrapper binary for diagnostics and compatibility checks
T / C preset writes use Host Link WS / WSS only on KV-8000/7000-series
CPU units. Manuals state that other CPU units do not support those commands
and return abnormal response E1 when they are executed.
AT digital trimmer values are treated as 32-bit device points on PLC families
that support them; AT0 defaults to AT0:D, and AT7:D is a valid endpoint.
AT is not listed in the WR/WRS device table, so write helpers reject AT before
sending.
Installation
The package name is plc-comm-hostlink-rust and the library import path is
plc_comm_hostlink.
Examples and the verification wrapper require --features cli.
Quick Start
use ;
async
High-Level API
HostLinkConnectionOptionsopen_and_connectread_typed/write_typedread_timer_counter/read_timer/read_counterread_commentsdevice_range_catalog_for_modelwrite_bit_in_wordread_namedpollread_words_single_request/read_dwords_single_requestread_words_chunked/read_dwords_chunkedwrite_words_single_request/write_dwords_single_requestwrite_words_chunked/write_dwords_chunked
Comment reads also accept XYM aliases such as D10, E20, F30, M100, L200, X100, and Y100.
read_typed("T10", "D") and read_named(&["T10"]) return the timer/counter
preset value for compatibility. Use read_timer_counter(&client, "T10") or
client.read_timer_counter("T10") when the Host Link composite fields are
needed: status, current, and preset.
Device-range catalogs are also available for UI use cases such as device monitors:
use ;
let catalog = device_range_catalog_for_model?;
let dm = catalog.entry.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
The full static range specification is documented in
docs/DEVICE_RANGES.md.
Verified Hardware
- CPU:
KV-7500 - CPU:
KV-X500 - Transport:
TCPandUDP
Verification
Run formatting, static analysis, and tests:
Build the diagnostic wrapper binary: