Python library for KEYENCE KV series Host Link (Upper Link) communication.
Project description
KV Host Link Protocol for Python
High-performance Python library for KEYENCE KV series PLCs using the Host Link (Upper Link) protocol.
This README intentionally covers the recommended high-level helper API only:
open_and_connect, read_typed, write_typed, write_bit_in_word,
read_named, poll, read_words, and read_dwords.
Low-level client methods and protocol-level details are kept in maintainer documentation.
Key Features
- High-level helper API for typed reads, writes, snapshots, and polling
- Typed helpers for
U,S,D,L, and helper-levelF - Mixed snapshots with
read_named - Batch-friendly polling with
poll - Contiguous block helpers with
read_wordsandread_dwords - Hardware-verified against KV-7500
Installation
Install the latest PyPI release:
pip install kv-hostlink
For local development:
git clone https://github.com/fa-yoshinobu/plc-comm-hostlink-python.git
cd plc-comm-hostlink-python
pip install -e .
Published metadata lives at https://pypi.org/project/kv-hostlink/, where wheel/tarball downloads are also available.
Quick Start
import asyncio
from hostlink import open_and_connect, read_named, read_typed, write_typed
async def main() -> None:
async with await open_and_connect("192.168.250.100", 8501) 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)
if __name__ == "__main__":
asyncio.run(main())
Common Workflows
Typed block reads:
words = await read_words(client, "DM100", 10)
dwords = await read_dwords(client, "DM200", 4)
Bit-in-word update:
await write_bit_in_word(client, "DM50", bit_index=3, value=True)
Polling:
async for snapshot in poll(client, ["DM100", "DM101:L", "DM50.3"], interval=1.0):
print(snapshot)
Sample Programs
User-facing high-level examples:
samples/high_level_async.pysamples/high_level_sync.pysamples/basic_high_level_rw.pysamples/named_snapshot.pysamples/polling_monitor.py
API and workflow to sample mapping:
| API / workflow | Primary sample | Purpose |
|---|---|---|
open_and_connect, read_typed, write_typed, read_words, read_dwords, write_bit_in_word, read_named, poll |
samples/high_level_async.py |
End-to-end async walkthrough of the full helper surface |
| Synchronous CLI entrypoint for the same helper surface | samples/high_level_sync.py |
Shows how to wrap the async helper API behind asyncio.run |
read_typed, write_typed |
samples/basic_high_level_rw.py |
Focused typed read/write mirror example |
read_named |
samples/named_snapshot.py |
Mixed typed and bit-in-word snapshot example |
poll |
samples/polling_monitor.py |
Repeated snapshot monitoring loop |
Run examples:
python samples/high_level_async.py --host 192.168.250.100
python samples/high_level_sync.py --host 192.168.250.100
python samples/basic_high_level_rw.py --host 192.168.250.100
python samples/named_snapshot.py --host 192.168.250.100
python samples/polling_monitor.py --host 192.168.250.100 --poll-count 5
Documentation
User documentation:
Maintainer and QA documentation:
Verified Hardware
- CPU: KV-7500, KV-8000, KV-X550
- Ethernet: built-in Ethernet port and KV-XLE02
- Transport: TCP and UDP
Development and Release Checks
run_ci.bat
release_check.bat
run_ci.bat runs lint, format, mypy, high-level docs coverage checks,
user-facing sample validation, and tests.
release_check.bat runs run_ci.bat and then rebuilds the published docs.
License
Distributed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kv_hostlink-0.1.4.tar.gz.
File metadata
- Download URL: kv_hostlink-0.1.4.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5b03ea877c6c69b639a4db7c933da84999737affe3371aaee56305959bd1bf2
|
|
| MD5 |
6583ba0ffa77c4fcd66f03aaf24d113d
|
|
| BLAKE2b-256 |
986843093ea28b8b9da733b25f860599e67b8212abd9cb8395300ba9b919d13c
|
File details
Details for the file kv_hostlink-0.1.4-py3-none-any.whl.
File metadata
- Download URL: kv_hostlink-0.1.4-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02e8072c4b9828e36dd24c4ab2cd17dcadb2160f1883854f8f91fcf718cb436d
|
|
| MD5 |
c91dc3f9c6e9ef61326aadfa9f59c627
|
|
| BLAKE2b-256 |
93d48930472ec5169511e7fc427ec89eb8c795f1c43621a24bde9a79ba07fb1a
|