Utilities
This section shows general objects and helper functions that are used with this package.
Note
This BalderHub project doesn’t have any utilities.
- class balderhub.scpi.lib.utils.BaseSocketConnector(ip_address: str, port=5025, receive_buffer_size=4096, timeout: float = 30)
Bases:
objectThis class provides a manager class for connecting and interacting with a remove socket. It can be used for sync communication with the remote device.
- connect()
Connects the socket to the remote device
- disconnect()
- Returns:
disconnects the socket connection
- read_all_from_socket(timeout: float, max_wait_for_followup_msg_time: float = 0.5) bytes | None
Receives data from a socket until no further data is available for more than
max_wait_for_followup_msg_timeseconds and the termination char is received.This implementation is used, because most of the devices terminate their response with
\n, but they can also send\ncharacters within their data. When waiting for up tomax_wait_for_followup_msg_timeseconds, this will increase the certainty that the received char is really the response termination char.- Parameters:
timeout – timeout in seconds
max_wait_for_followup_msg_time – max wait time for follow-up messages
- Returns:
The received message as bytes (including the termination character) or None on timeout
- send_query(cmd: bytes, no_response=False) bytes | None
Sends a command to the remote device. If
no_responseis True, the method will not wait for a response, otherwise the method will wait up to the global defined timeout for a response.The method raises an TimeoutError if it does not receive a response within the global defined timeout.
- Parameters:
cmd – the command to sent
no_response – True, if the caller expects a response for the command, False otherwise
- Returns:
the response or None
- property termination_chars: bytes
- Returns:
specifies the expected termination character