HostServices

Scoped host services: clocks, transport, and evidence recording.

Usage

Source

HostServices()

One services object is bound to an adapter session at open. Adapters reach the device only through transfer and take time only from monotonic and utc_now.

See Also

Adapter

receives these services at open.

OperationContext

per-operation deadline and cancellation state.

Methods

Name Description
close_transport() Close the transport bound to this adapter session.
monotonic() Return the current reading of the host’s monotonic clock in seconds.
record_evidence() Append one evidence entry to the operation’s evidence record.
transfer() Perform one bounded transport exchange with the device.
utc_now() Return the current UTC time as an ISO-8601 string.

close_transport()

Close the transport bound to this adapter session.

Usage

Source

close_transport(context)

monotonic()

Return the current reading of the host’s monotonic clock in seconds.

Usage

Source

monotonic()

record_evidence()

Append one evidence entry to the operation’s evidence record.

Usage

Source

record_evidence(entry, context)

transfer()

Perform one bounded transport exchange with the device.

Usage

Source

transfer(transaction, context)
Parameters
transaction: dict[str, Any]

Exchange description, for example {"kind": "stream_exchange", "data": b"ID?\n", "max_bytes": 128, "termination": "lf"}; the host enforces the declared bounds.

context: OperationContext
The operation context; a cancelled or expired operation fails instead of transmitting.
Returns
dict
The raw device response, for example {"data": b"3.3\n"}.
Raises
TimeoutError

If the operation is cancelled or past its deadline.

ConnectionError
If the transport has been lost.

utc_now()

Return the current UTC time as an ISO-8601 string.

Usage

Source

utc_now()