Transport
- class TcpTransport(ip: str, port: int, timeout: float | None = 5.0)
Defines TCP Transport for a XiBIF Board.
- close() None
Close the connection to a XiBIF board
- Raises:
SocketClosedError – The connection does not exist. It cannot be closed.
- property isConnected
Defines whether the TcpTransport object is connected.
- Returns:
connected (boolean) – True if a connection exists, False otherwise
- open() None
Open a connection to a XiBIF board
A socket connection to will be opened to the configured IP and port. If a connection is already established, it will be closed.
- Raises:
SocketConnectionError: – Connection could not be opened
- receive(length: int) bytes | bytearray | memoryview
Receive a number of bytes over a TCP connection.
Receives the specified number of bytes over the configured TCP connection if it exists. Upon successfully receiving the number of bytes specified, the data is returned.
- Parameters:
length (int) – Number of bytes to read from a socket
- Returns:
data (SendableData) – Received data
- Raises:
SocketClosedError: – No connection exists or the connection was unexpectedly closed during transmission.
SocketTimeoutError: – Timeout while reading the socket. Either the connection is unresponsive or tried to read more bytes than available.
- send(data: bytes | bytearray | memoryview) None
Send data over a TCP connection.
Send the given data over the configured TCP connection if it exists.
- Parameters:
data (SendableData) – Data to send
- Raises:
SocketClosedError: – No connection exists, cannot send data.