Host Link Communication Python
A Python client library for KEYENCE KV series PLCs using the Host Link Communication protocol.
This published site intentionally focuses on the recommended high-level helper API:
HostLinkConnectionOptionsopen_and_connectnormalize_addressread_typedwrite_typedread_words_single_requestread_dwords_single_requestread_words_chunkedread_dwords_chunkedwrite_bit_in_wordread_namedpoll
Low-level token-oriented client methods are intentionally left out of the published user site and remain repository-maintainer material.
Key Features
- High-level typed reads and writes for
U,S,D,L, andF - Mixed named snapshots with
read_named - Repeated snapshot streaming with
poll - Explicit contiguous helpers for
single_requestandchunkedreads - Strict lint, type-check, and test coverage in CI
Quick Start
Basic Usage
from hostlink import HostLinkConnectionOptions, open_and_connect, read_named, read_typed, write_typed
async def main() -> None:
options = HostLinkConnectionOptions(host="192.168.250.100", port=8501)
async with await open_and_connect(options) as client:
dm0 = await read_typed(client, "DM0", "U")
await write_typed(client, "DM10", "U", dm0)
snapshot = await read_named(client, ["DM0", "DM1:S", "DM2:D", "DM4:F", "DM10.0"])
print(snapshot)
Documentation
Development & CI
This project enforces strict quality standards via run_ci.bat.
Quality Checks
Local CI Run
run_ci.bat
Validates the code and builds a standalone CLI tool in the publish/ directory.
License
Distributed under the MIT License.