zen_tcpip#
zen_api_utils.zen_tcpip
#
Classes:
-
ZenTCPConnection–Buffered line-oriented TCP connection used by ZEN's PythonScript interface.
-
ZenCommands–Represents a collection of commands to be executed on a ZEN device using TCP-IP connection.
-
ZenTCPIP–
ZenTCPConnection
#
ZenTCPConnection(connection: socket)
Buffered line-oriented TCP connection used by ZEN's PythonScript interface.
ZenCommands
#
ZenCommands(commandlist: list[str], timeout: int = 200, port: int = 52757, verbose=True)
Represents a collection of commands to be executed on a ZEN device using TCP-IP connection.
Parameters:
-
commandlist(List[str]) –A list of commands to be executed.
-
timeout(int, default:200) –The timeout value for the TCP-IP connection. Defaults to 200.
-
port(int, default:52757) –The port number for the TCP-IP connection. Defaults to 52757.
-
verbose(bool, default:True) –Whether to print the executed commands. Defaults to True.
Initializes a new instance of the ZenCommands class.
Parameters:
-
commandlist(List[str]) –A list of commands to be executed.
-
timeout(int, default:200) –The timeout value for the TCP-IP connection. Defaults to 200.
-
port(int, default:52757) –The port number for the TCP-IP connection. Defaults to 52757.
-
verbose(bool, default:True) –Whether to print the executed commands. Defaults to True.
Methods:
-
execute–Executes the commands on the ZEN device using TCP-IP connection.
ZenTCPIP
#
ZenTCPIP()
Initialize the object to connect with ZEN over the TCP-IP port.
Methods:
-
tcp_open_port–Open a connection to ZEN with a specified timeout and port number
-
tcp_eval_expression_and_wait_for_ok–Evaluate the given python expression within ZEN and expect
-
tcp_eval_expression–Evaluate the given python expression within ZEN
-
tcp_read_answer–Read the answer after sending an OAD command.
-
tcp_read_all–Read everything from the buffer.
tcp_open_port
#
tcp_open_port(timeout: int = 200, port: int = 52767, verbose=False) -> ZenTCPConnection
Open a connection to ZEN with a specified timeout and port number
:param timeout: time in [s] the longest command is expected to take. When finishing earlier the next command will be send., defaults to 200 :type timeout: int, optional :param port: port number used for the connection, defaults to 52767 :type port: int, optional :param verbose: option to show or suppress additional output :type verbose: bool, optional :return: TCP connection :rtype: ZenTCPConnection
tcp_eval_expression_and_wait_for_ok
#
tcp_eval_expression_and_wait_for_ok(telnet: ZenTCPConnection, expression: str, timeout: float, verbose=False) -> tuple[bool, str]
Evaluate the given python expression within ZEN and expect an "OK" answer within given timeout (in seconds). Return True if "OK" was received within given timeout
:param telnet: ZEN TCP connection :type telnet: ZenTCPConnection :param expression: ZEN OAD command to be sent :type expression: string :param timeout: time in [s] the longest command is expected to take. When finishing earlier the next command will be send., defaults to 200 :type timeout: int, optional :param verbose: option to show or suppress additional output :type verbose: bool, optional :return: answer :rtype: str
tcp_eval_expression
#
tcp_eval_expression(telnet: ZenTCPConnection, expression: str) -> None
Evaluate the given python expression within ZEN
:param telnet: ZEN TCP connection :type telnet: ZenTCPConnection :param expression: ZEN OAD command to be sent :type expression: string
tcp_read_answer
#
tcp_read_answer(telnet: ZenTCPConnection, timeout: float = 0.1) -> str
Read the answer after sending an OAD command.
:param telnet: ZEN TCP connection :type telnet: ZenTCPConnection :param timeout: time in [s] waiting for an answer :type timeout: int, optional
tcp_read_all
#
tcp_read_all(telnet: ZenTCPConnection) -> None
Read everything from the buffer.
:param telnet: ZEN TCP connection :type telnet: ZenTCPConnection