Skip to content

KV Host Link Python API Reference

This page is generated during the docs-site build from the installed plc-comm-kv-hostlink PyPI package.

It follows the latest package release installed by the site build. Use the handwritten Getting started and Usage guide pages for task-oriented examples, and this page for the complete public Python API surface.

Generated API Details

KEYENCE KV Host Link communication library.

The user-facing surface of this package is the high-level helper API exported from :mod:hostlink.utils:

  • :func:open_and_connect
  • :class:HostLinkConnectionOptions
  • :class:HostLinkAddress
  • :class:TimerCounterValue
  • :func:parse_address
  • :func:try_parse_address
  • :func:format_address
  • :func:normalize_address
  • :func:read_typed
  • :func:read_timer_counter
  • :func:read_timer
  • :func:read_counter
  • :func:write_typed
  • :func:write_bit_in_word
  • :func:read_comments
  • :func:read_comment_bytes
  • :func:read_words_single_request
  • :func:read_dwords_single_request
  • :func:read_expansion_unit_buffer
  • :func:write_expansion_unit_buffer
  • :func:write_bit_in_expansion_unit_buffer
  • :func:read_named
  • :func:poll

The low-level clients remain part of the package for advanced and maintainer workflows, but the helpers above are the recommended entry points for normal application code and generated user documentation.

__version__ = '4.0.0' module-attribute

__all__ = ['HostLinkClient', 'AsyncHostLinkClient', 'ModelInfo', 'HostLinkTrafficStats', 'HostLinkBaseError', 'HostLinkConnectionError', 'HostLinkTimeoutError', 'HostLinkCancelledError', 'HostLinkClosedError', 'HostLinkNotConnectedError', 'HostLinkTransportError', 'HostLinkFailureReason', 'HostLinkOutcomeUnknownError', 'HostLinkError', 'HostLinkProtocolError', 'decode_error_code', 'KvDeviceRangeCatalog', 'KvDeviceRangeCategory', 'KvDeviceRangeEntry', 'KvDeviceRangeNotation', 'KvDeviceRangeSegment', 'KvHostLinkPlcProfile', 'KvHostLinkPlcProfileDescriptor', 'available_plc_profiles', 'device_range_catalog_for_plc_profile', 'display_name', 'normalize_plc_profile', 'plc_profile_descriptors', 'profile_from_name', 'HostLinkAddress', 'HostLinkConnectionOptions', 'HostLinkCommentEncoding', 'TimerCounterValue', 'format_address', 'normalize_address', 'open_and_connect', 'parse_address', 'poll', 'read_comment_bytes', 'read_comments', 'read_counter', 'read_dwords', 'read_dwords_single_request', 'read_named', 'read_timer', 'read_timer_counter', 'read_typed', 'read_words', 'read_words_single_request', 'read_expansion_unit_buffer', 'try_parse_address', 'write_dwords_single_request', 'write_bit_in_word', 'write_bit_in_expansion_unit_buffer', 'write_expansion_unit_buffer', 'write_typed', 'write_words_single_request'] module-attribute

HostLinkClient

Bases: HostLinkBase

Synchronous client for KEYENCE KV Host Link protocol.

traffic_stats()

Return an immutable lifetime traffic-counter snapshot.

connect()

Open the configured TCP or UDP socket if it is not already open.

close()

Immediately retire the active generation and reject queued work.

send_raw(body)

Send one maintainer raw command and return undecoded response body bytes.

change_mode(mode)

Change the PLC operating mode through the Host Link M command.

clear_error()

Clear the current PLC error through the Host Link ER command.

check_error_no()

Read the current PLC error number as raw response text.

query_model()

Query the PLC model code and mapped model name.

confirm_operating_mode()

Return the current PLC operating mode code.

set_time(value)

Set the PLC clock from an explicit value.

forced_set(device)

Force one bit device ON.

forced_reset(device)

Force one bit device OFF.

forced_set_consecutive(device, count)

Force a consecutive bit-device range ON.

forced_reset_consecutive(device, count)

Force a consecutive bit-device range OFF.

read(device, *, data_format=None)

Read one device with the Host Link RD command.

read_consecutive(device, count, *, data_format=None)

Read consecutive devices with the Host Link RDS command.

read_consecutive_legacy(device, count, *, data_format=None)

Read consecutive devices with the legacy Host Link RDE command.

write(device, value, *, data_format=None)

Write one device with the Host Link WR command.

write_bit_in_word(device, bit_index, value)

Set or clear one bit through an explicit 16-bit read-modify-write.

The complete target, index, and Boolean value are validated before FIFO admission. After activation, one local FIFO turn and one absolute transaction deadline cover exactly one read and one write, even when the bit already has the requested value. There is no fallback, retry, or success readback. The operation is not PLC-atomic: another connection or PLC logic can change the word between requests and that change can be lost. Use PLC-side coordination when the complete word is shared.

write_consecutive(device, values, *, data_format=None)

Write consecutive devices with the Host Link WRS command.

write_consecutive_legacy(device, values, *, data_format=None)

Write consecutive devices with the legacy Host Link WRE command.

write_set_value(device, value, *, data_format=None)

Write one timer or counter preset/current value with WS.

write_set_value_consecutive(device, values, *, data_format=None)

Write consecutive timer or counter values with WSS.

register_monitor_bits(*devices)

Register bit devices for later monitor reads.

register_monitor_words(entries)

Register word devices for later monitor reads.

read_monitor_bits()

Read the currently registered bit monitor values.

read_monitor_words()

Read the currently registered word monitor values.

read_comment_bytes(device)

Read exact PLC comment payload bytes without CR/LF framing.

read_comments(device, encoding)

Read PLC comment text using exactly the selected encoding.

switch_bank(bank_no)

Switch the active Host Link bank number.

read_expansion_unit_buffer(unit_no, address, count, *, data_format)

Read an expansion unit buffer range with URD.

write_expansion_unit_buffer(unit_no, address, values, *, data_format)

Write an expansion unit buffer range with UWR.

write_bit_in_expansion_unit_buffer(unit_no, address, bit_index, value)

Set or clear one bit through one explicit URD/UWR pair.

The route is fixed to unit_no and address and the format is one unsigned 16-bit word. Validation finishes before FIFO admission. One absolute deadline covers the read and write after activation. The operation is not PLC-atomic and performs no fallback, retry, or success readback.

AsyncHostLinkClient

Bases: HostLinkBase

Asynchronous client for KEYENCE KV Host Link protocol.

traffic_stats()

Return an immutable lifetime traffic-counter snapshot.

connect() async

Open the configured TCP or UDP transport if it is not already open.

close() async

Immediately retire the active generation and reject queued work.

send_raw(body) async

Send one maintainer raw command and return undecoded response body bytes.

change_mode(mode) async

Change the PLC operating mode through the Host Link M command.

clear_error() async

Clear the current PLC error through the Host Link ER command.

check_error_no() async

Read the current PLC error number as raw response text.

query_model() async

Query the PLC model code and mapped model name.

confirm_operating_mode() async

Return the current PLC operating mode code.

set_time(value) async

Set the PLC clock from an explicit value.

forced_set(device) async

Force one bit device ON.

forced_reset(device) async

Force one bit device OFF.

forced_set_consecutive(device, count) async

Force a consecutive bit-device range ON.

forced_reset_consecutive(device, count) async

Force a consecutive bit-device range OFF.

read(device, *, data_format=None) async

Read one device with the Host Link RD command.

read_consecutive(device, count, *, data_format=None) async

Read consecutive devices with the Host Link RDS command.

read_consecutive_legacy(device, count, *, data_format=None) async

Read consecutive devices with the legacy Host Link RDE command.

write(device, value, *, data_format=None) async

Write one device with the Host Link WR command.

write_bit_in_word(device, bit_index, value) async

Set or clear one bit through an explicit 16-bit read-modify-write.

The complete target, index, and Boolean value are validated before FIFO admission. After activation, one local FIFO turn and one absolute transaction deadline cover exactly one read and one write, even when the bit already has the requested value. There is no fallback, retry, or success readback. The operation is not PLC-atomic: another connection or PLC logic can change the word between requests and that change can be lost. Use PLC-side coordination when the complete word is shared.

write_consecutive(device, values, *, data_format=None) async

Write consecutive devices with the Host Link WRS command.

write_consecutive_legacy(device, values, *, data_format=None) async

Write consecutive devices with the legacy Host Link WRE command.

write_set_value(device, value, *, data_format=None) async

Write one timer or counter preset/current value with WS.

write_set_value_consecutive(device, values, *, data_format=None) async

Write consecutive timer or counter values with WSS.

register_monitor_bits(*devices) async

Register bit devices for later monitor reads.

register_monitor_words(entries) async

Register word devices for later monitor reads.

read_monitor_bits() async

Read the currently registered bit monitor values.

read_monitor_words() async

Read the currently registered word monitor values.

read_comment_bytes(device) async

Read exact PLC comment payload bytes without CR/LF framing.

read_comments(device, encoding) async

Read PLC comment text using exactly the selected encoding.

switch_bank(bank_no) async

Switch the active Host Link bank number.

read_expansion_unit_buffer(unit_no, address, count, *, data_format) async

Read an expansion unit buffer range with URD.

write_expansion_unit_buffer(unit_no, address, values, *, data_format) async

Write an expansion unit buffer range with UWR.

write_bit_in_expansion_unit_buffer(unit_no, address, bit_index, value) async

Set or clear one bit through one explicit URD/UWR pair.

The route is fixed to unit_no and address and the format is one unsigned 16-bit word. Validation finishes before FIFO admission. One absolute deadline covers the read and write after activation. The operation is not PLC-atomic and performs no fallback, retry, or success readback.

ModelInfo dataclass

PLC model response returned by query_model.

HostLinkTrafficStats dataclass

Immutable lifetime traffic counters for one client.

TCP receive bytes include the response body and its first CR/LF terminator; extra separator bytes are consumed but excluded. UDP receive bytes include the complete datagram.

HostLinkBaseError

Bases: Exception

Base class for all Host Link errors.

HostLinkConnectionError

Bases: HostLinkBaseError, ConnectionError

Compatibility base for machine-readable connection failures.

HostLinkTimeoutError

Bases: HostLinkConnectionError, TimeoutError

Raised when a configured connect or transaction deadline expires.

HostLinkCancelledError

Bases: HostLinkBaseError

Raised when an asynchronous Host Link operation is cancelled.

HostLinkClosedError

Bases: HostLinkConnectionError

Raised when local close retires an active or queued transport generation.

HostLinkNotConnectedError

Bases: HostLinkConnectionError

Raised when an operation is attempted without a connected transport.

HostLinkTransportError

Bases: HostLinkConnectionError

Raised for non-timeout socket or transport I/O failure.

HostLinkFailureReason

Bases: Enum

Stable reason retained by :class:HostLinkOutcomeUnknownError.

HostLinkOutcomeUnknownError dataclass

Bases: HostLinkBaseError

A state-changing request may have reached the PLC without confirmation.

HostLinkError dataclass

Bases: HostLinkBaseError

Raised when PLC returns an error response (E0/E1/E2/E4/E5/E6).

HostLinkProtocolError

Bases: HostLinkBaseError, ValueError

Raised when a frame/response is malformed.

KvDeviceRangeCatalog dataclass

Resolved KV device range catalog for one canonical PLC profile.

entry(device_type)

Return the catalog entry matching a device type or segment alias.

KvDeviceRangeCategory

Bases: Enum

Broad device category used by the maintained KV range catalog.

KvDeviceRangeEntry dataclass

Catalog entry for one logical Host Link device family.

KvDeviceRangeNotation

Bases: Enum

Address number notation used by one device range row.

KvDeviceRangeSegment dataclass

One concrete segment from a published KV device range row.

KvHostLinkPlcProfile dataclass

One canonical KEYENCE KV PLC profile.

KvHostLinkPlcProfileDescriptor dataclass

Metadata used to present and select one canonical KV PLC profile.

HostLinkAddress dataclass

Parsed public Host Link address helper result.

Attributes:

Name Type Description
text str

Canonical address text, preserving logical helper notation such as "DM100:F" or "DM100.A".

base_device str

Canonical base device token used by low-level Host Link commands.

dtype str

Logical data type code such as "U", "D", "F", "COMMENT", or "BIT_IN_WORD".

bit_index int | None

Bit index for "BIT_IN_WORD" addresses, otherwise None.

is_bit_in_word property

Whether this address targets one bit inside a word device.

HostLinkConnectionOptions dataclass

Stable connection settings for one Host Link session.

The dataclass is the preferred input for :func:open_and_connect because it keeps endpoint and timeout options together in one explicit object.

Attributes:

Name Type Description
host str

PLC hostname or IP address.

plc_profile str

Canonical KEYENCE KV PLC profile for the session.

port int

Host Link port number.

transport str

Transport name such as "tcp" or "udp".

timeout float

Absolute per-request transaction deadline in seconds.

connect_timeout float

Separate connection-establishment deadline in seconds.

HostLinkCommentEncoding

Bases: str, Enum

Explicit codec choices for Host Link RDC comment payloads.

TimerCounterValue dataclass

Composite timer/counter read result.

Host Link RD Tn.D and RD Cn.D replies contain the contact/status, current value, and preset value in that order.

decode_error_code(code)

Return a readable message for a Host Link error code.

available_plc_profiles()

Return canonical PLC profile strings supported by the library.

device_range_catalog_for_plc_profile(plc_profile)

Resolve and return the device range catalog for a canonical PLC profile.

display_name(plc_profile)

Return the canonical human-readable display name for a PLC profile.

normalize_plc_profile(plc_profile)

Return the canonical PLC profile string for a supported profile.

plc_profile_descriptors()

Return presentation and connection metadata for every canonical KV profile.

profile_from_name(plc_profile)

Resolve a canonical PLC profile string.

format_address(address)

Return canonical Host Link helper address text.

Parsed objects are formatted from their semantic fields and validated by the same device/data-type rules as :func:parse_address. The text field is not trusted as an alternate representation.

Parameters:

Name Type Description Default
address HostLinkAddress | str

A parsed :class:HostLinkAddress or raw address string.

required

Returns:

Type Description
str

Canonical address text.

normalize_address(address)

Return the canonical Host Link device string.

The helper normalizes device-family spelling, trims whitespace, and keeps explicit dtype or bit-in-word intent when present.

Parameters:

Name Type Description Default
address str

User-facing address such as "dm100:u", "dm100:f", or "DM100.a".

required

Returns:

Type Description
str

Canonical uppercase address text.

open_and_connect(options) async

Create and connect an :class:AsyncHostLinkClient.

This is the recommended entry point for user code and examples because it returns a ready-to-use client in one step.

Parameters:

Name Type Description Default
options HostLinkConnectionOptions

Fully specified Host Link endpoint and timeout settings.

required

Returns:

Type Description
AsyncHostLinkClient

A connected :class:AsyncHostLinkClient.

Usage::

options = HostLinkConnectionOptions(
    "192.168.250.100",
    port=8501,
    transport="tcp",
    plc_profile="keyence:kv-8000",
)
client = await open_and_connect(options)
async with client:
    values = await read_words(client, "DM100", 10)

parse_address(address)

Parse a public Host Link helper address.

This is the public companion to :func:normalize_address. It keeps UI and adapter code from duplicating private parser details while preserving the logical helper forms accepted by :func:read_named.

Parameters:

Name Type Description Default
address str

User-facing address such as "dm100:u", "dm100:f", or "dm100.a". Bare base-device addresses are rejected because the data type must be explicit.

required

Returns:

Name Type Description
A HostLinkAddress

class:HostLinkAddress with canonical text and parsed metadata.

Examples:

Parse a bit-in-word address::

parsed = parse_address("dm100.a")
assert parsed.text == "DM100.A"
assert parsed.bit_index == 10

poll(client, addresses, interval, *, comment_encoding=None) async

Continuously yield read results for the specified addresses.

Address parsing and return values follow the same rules as :func:read_named. The optimized read plan is compiled once and reused on every iteration. Each complete cycle owns one FIFO turn; yielding the sample and waiting for the post-cycle interval occur after releasing that turn.

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
addresses list[str]

Address strings in :func:read_named format.

required
interval float

Delay in seconds between read results.

required
comment_encoding HostLinkCommentEncoding | None

Required explicit codec when any address uses :COMMENT; omit it for collections without comments.

None

Yields:

Type Description
AsyncIterator[dict[str, int | float | bool | str]]

A dictionary for each polling cycle, keyed by the original address

AsyncIterator[dict[str, int | float | bool | str]]

strings.

Usage::

async for read_result in poll(client, ["DM100:U", "DM200:F"], interval=0.5):
    print(read_result)

read_comment_bytes(client, device) async

Read exact PLC comment payload bytes without CR/LF framing.

read_comments(client, device, encoding) async

Read one PLC comment string using exactly the selected codec.

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
device str

Base device address such as "DM100".

required
encoding HostLinkCommentEncoding

Explicit UTF-8 or CP932/Windows-31J selection.

required

Returns:

Type Description
str

The PLC comment text for device.

read_counter(client, device) async

Read a counter composite value.

read_dwords(client, device, count) async

Read contiguous unsigned 32-bit values starting at device.

Adjacent word pairs are combined in low-word, high-word order, which matches the helper-layer interpretation used by :func:read_typed for dtype="D" and dtype="F".

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
device str

Starting base device address such as "DM0".

required
count int

Number of 32-bit values to read.

required

Returns:

Type Description
list[int]

A list of Python int values.

read_dwords_single_request(client, device, count) async

Read contiguous unsigned dwords using one PLC request.

Adjacent word pairs are combined in low-word, high-word order. The helper never silently splits the logical request.

read_named(client, addresses, *, comment_encoding=None) async

Read multiple named values and return a snapshot dictionary.

Each input string describes both the base device and the desired interpretation. The returned dictionary preserves the original address strings as keys.

Address format examples:

  • "DM100:U" -- unsigned 16-bit int
  • "DM100:F" -- float
  • "DM100:S" -- signed 16-bit int
  • "DM100:D" -- unsigned 32-bit int
  • "DM100:L" -- signed 32-bit int
  • "CR000:BIT" -- direct bit device (bool)
  • "DM100.3" -- bit 3 within word (bool)
  • "DM100.A" -- bit 10 within word (bool); bits 10-15 use hex digits A-F
  • "DM100:COMMENT" -- PLC comment text (str)

Bit-in-word indices use hexadecimal notation (0-F), matching the KEYENCE address format. Bits 0-9 can be written as decimal digits; bits 10-15 must be written as A-F. For example, bit 12 is "DM100.C", not "DM100.12".

The entire input is validated before admission. Wire reads are grouped by device type in first-occurrence order, sorted by address within each group, and compatible contiguous or overlapping spans are merged up to request limits without splitting an individual entry. All requests run during one FIFO turn. Public keys remain in caller order. A multi-request result is not one atomic PLC-time observation, and an error returns no partial dictionary.

Keys must be semantically unique after device family, numeric address, dtype, bit index, and scalar count are normalized. Spelling variants are rejected, while distinct dtype views, bit indices, and overlapping spans remain valid. Returned keys retain their original input spelling.

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
addresses list[str]

Address strings to read as one logical collection result.

required
comment_encoding HostLinkCommentEncoding | None

Required explicit codec when any address uses :COMMENT; omit it for collections without comments.

None

Returns:

Type Description
dict[str, int | float | bool | str]

Dictionary mapping each original address string to its decoded value.

Examples:

Read mixed integer, float, and bit-in-word values::

read_result = await read_named(client, ["DM10:U", "DM20:F", "DM30.A"])

read_timer(client, device) async

Read a timer composite value.

read_timer_counter(client, device) async

Read a timer/counter composite value as status, current, and preset.

The response status must be exactly 0 or 1.

Existing :func:read_typed and :func:read_named keep their compatibility behavior of returning the preset value for T/C devices. Use this helper when the contact/status or current value is required too.

read_typed(client, device, dtype) async

Read a single device value through the high-level helper API.

The base device address is supplied separately from the data type code. For example, use device="DM100" and dtype="D" rather than the low-level style "DM100.D".

Supported data type codes are:

  • "U": unsigned 16-bit integer
  • "S": signed 16-bit integer
  • "D": unsigned 32-bit integer
  • "L": signed 32-bit integer
  • "F": IEEE 754 float32
  • "H": hexadecimal 16-bit word text

The "F" helper is implemented by reading two consecutive .U words and converting them into a Python float.

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
device str

Base device address such as "DM100".

required
dtype str

High-level data type code.

required

Returns:

Type Description
int | float | bool | str

The converted value. Integer formats return int, "F" returns

int | float | bool | str

float, and "H" returns uppercase hexadecimal str.

Raises:

Type Description
HostLinkProtocolError

If the PLC reply does not contain a value.

Examples:

Read an unsigned word::

value = await read_typed(client, "DM100", "U")

Read a float32 from two words::

temperature = await read_typed(client, "DM200", "F")

read_words(client, device, count) async

Read contiguous 16-bit unsigned words starting at device.

This helper wraps the low-level consecutive read and converts the PLC reply to Python int values.

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
device str

Starting base device address such as "DM100".

required
count int

Number of 16-bit words to read.

required

Returns:

Type Description
list[int]

A list of unsigned word values in PLC order.

read_words_single_request(client, device, count) async

Read contiguous unsigned words using one PLC request.

The helper never splits or combines multiple PLC requests.

read_expansion_unit_buffer(client, unit_no, address, count, *, data_format) async

Read buffer memory in an expansion unit.

This high-level helper exposes the existing Host Link URD command through the same helper namespace as typed and contiguous access. Validation and command framing remain owned by the connected client.

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
unit_no int

Expansion unit number, 0 to 48.

required
address int

Buffer memory address, 0 to 59999.

required
count int

Number of values to read.

required
data_format str

Required Host Link data suffix such as "U", "S", "D", "L", or "H".

required

Returns:

Type Description
list[int | str]

Values returned by the PLC after Host Link token parsing.

Examples:

Read two unsigned buffer words from unit 1::

values = await read_expansion_unit_buffer(client, 1, 100, 2, data_format="U")

try_parse_address(address)

Try to parse a public Host Link helper address.

Parameters:

Name Type Description Default
address str

User-facing address text.

required

Returns:

Type Description
HostLinkAddress | None

A parsed :class:HostLinkAddress, or None if validation fails.

write_dwords_single_request(client, device, values) async

Write contiguous unsigned dwords using one PLC request.

Each Python int is encoded as two .U words in low-word, high-word order before the consecutive write is sent.

write_bit_in_word(client, device, bit_index, value) async

Set or clear one bit through an explicit 16-bit read-modify-write.

The complete plan is validated before FIFO admission. One local FIFO turn and one absolute deadline then cover exactly one read and one write, even when the requested state is unchanged. This operation is not PLC-atomic: PLC logic or a different connection can update the word between requests, and that update can be lost. It performs no fallback, retry, or readback.

write_bit_in_expansion_unit_buffer(client, unit_no, address, bit_index, value) async

Set or clear one expansion-buffer bit through explicit URD/UWR.

The client validates the complete immutable unit/address route before FIFO admission and retains one turn and one absolute deadline across exactly one unsigned-word read and one write. This operation is not PLC-atomic and performs no fallback, retry, or success readback.

write_expansion_unit_buffer(client, unit_no, address, values, *, data_format) async

Write buffer memory in an expansion unit.

This high-level helper exposes the existing Host Link UWR command without adding hidden chunking or fallback behavior.

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
unit_no int

Expansion unit number, 0 to 48.

required
address int

Buffer memory address, 0 to 59999.

required
values Sequence[int | str]

Values to write in one request.

required
data_format str

Required Host Link data suffix such as "U", "S", "D", "L", or "H".

required

Examples:

Write two signed buffer words to unit 1::

await write_expansion_unit_buffer(client, 1, 200, [-1, 2], data_format="S")

write_typed(client, device, dtype, value) async

Write a single device value through the high-level helper API.

Supported data type codes are the same as :func:read_typed. For dtype="F", the helper converts the Python value to IEEE 754 float32 and writes two consecutive .U words.

Parameters:

Name Type Description Default
client AsyncHostLinkClient

Connected asynchronous Host Link client.

required
device str

Base device address such as "DM100".

required
dtype str

High-level data type code.

required
value int | float | bool | str

Value to write. float is supported only with dtype="F".

required

Examples:

Write a signed 16-bit value::

await write_typed(client, "DM10", "S", -123)

Write a float32 value::

await write_typed(client, "DM200", "F", 12.5)

write_words_single_request(client, device, values) async

Write contiguous unsigned words using one PLC request.

The helper rejects the entire operation before send if one value is invalid.