stoner_measurement.instruments.transport.ethernet_transport.EthernetTransport¶
- class stoner_measurement.instruments.transport.ethernet_transport.EthernetTransport(host: str, port: int, timeout: float = 2.0)[source]¶
Bases:
BaseTransportTCP/IP socket transport for network-connected instruments.
- Variables:
Examples
>>> from stoner_measurement.instruments.transport import EthernetTransport >>> t = EthernetTransport(host="192.168.1.100", port=5025) >>> t.host '192.168.1.100' >>> t.port 5025
- flush() None[source]¶
Drain any unread data from the socket receive buffer.
Temporarily sets the socket to non-blocking mode and discards any data already in the receive buffer.
- open() None[source]¶
Connect to the instrument over TCP.
- Raises:
ConnectionError – If the TCP connection cannot be established.
- read(num_bytes: int | None = None) bytes[source]¶
Receive one response frame from the instrument.
- Parameters:
num_bytes (int | None) – Optional maximum frame size for this read. When
None, the protocol-defined frame-size limit is used.- Returns:
Bytes received from the instrument.
- Return type:
(bytes)
- Raises:
ConnectionError – If the socket is not open.
TimeoutError – If no data arrives within
timeoutseconds.
- property transport_address: str¶
Return the remote endpoint as
"<host>:<port>".- Returns:
Ethernet address string, e.g.
"192.168.1.100:5025".- Return type:
(str)
Examples
>>> from stoner_measurement.instruments.transport import EthernetTransport >>> EthernetTransport(host="192.168.1.100", port=5025).transport_address '192.168.1.100:5025'