Shared Client Internals
Pure-computation and compatibility methods shared by Client and
AsyncClient. Applications normally access these methods through one of the
concrete clients.
Shared base for the sync Client and async AsyncClient.
Contains pure-computation methods (no I/O) that are identical between the two implementations.
- class snap7.client_base.ClientMixin[source]
Methods shared between Client and AsyncClient.
Every method here is pure computation — no socket or asyncio I/O. Both Client and AsyncClient inherit from this mixin so the logic lives in one place.
- Subclasses must provide the following attributes (set in __init__):
host, local_tsap, remote_tsap, connection_type, session_password, pdu_length, connected, _exec_time, _last_error, _params, _on_operation, _operation_depth
- error_text(error_code: int) → str[source]
Get error text for error code.
- Parameters:
error_code – Error code to look up
- Returns:
Human-readable error text
- get_exec_time() → int[source]
Get last operation execution time.
- Returns:
Execution time in milliseconds
- get_param(param: Parameter) → int[source]
Get client parameter.
- Parameters:
param – Parameter number
- Returns:
Parameter value
- get_pg_block_info(data: bytearray) → TS7BlockInfo[source]
Get block info from raw block data.
- Parameters:
data – Raw block data
- Returns:
Block information structure
- set_connection_params(address: str, local_tsap: int, remote_tsap: int) → None[source]
Set connection parameters.
- Parameters:
address – PLC IP address
local_tsap – Local TSAP
remote_tsap – Remote TSAP