drs4.ctrl.scpi module#
- drs4.ctrl.scpi.connect(host: str, port: int, timeout: float | None = None) CustomSocket[source]#
Connect to an SCPI server and returns a custom socket object.
- Parameters:
host – IP address or host name of the server.
port – Port of the server.
timeout – Timeout value in units of seconds.
- Returns:
Custom socket object.
Examples
To send an SCPI command to a server:
with connect('192.168.1.3', 5000) as sock: sock.send('*CLS')
To receive a message from a server:
with connect('192.168.1.3', 5000) as sock: sock.send('SYST:ERR?') print(sock.recv())
- drs4.ctrl.scpi.send_commands(commands: IO[str] | Sequence[str] | str, host: str, port: int, timeout: float | None = None, encoding: str = 'ascii', autorecv: bool = True, bufsize: int = 4096) None[source]#
Send SCPI command(s) to a server.
- Parameters:
commands – Sequence of SCPI commands.
host – IP address or host name of the server.
port – Port of the server.
timeout – Timeout value in units of seconds.
encoding – Encoding format for the commands.
autorecv – If True and a command ends with ‘?’, receive a message and record it to a logger.
bufsize – Maximum byte size for receiving a message.
- Returns:
This function returns nothing.
Examples
To send an SCPI command to the server:
send_commands('*CLS', '192.168.1.3', 5000)
To send SCPI commands to the server:
send_commands(['*RST', '*CLS'], '192.168.1.3', 5000)
- drs4.ctrl.scpi.send_commands_in(path: PathLike[str] | str, host: str, port: int, timeout: float | None = None, encoding: str = 'ascii', autorecv: bool = True, bufsize: int = 4096) None[source]#
Send SCPI command(s) written in a file to a server.
- Parameters:
path – Path of the file.
port – Port of the server.
timeout – Timeout value in units of seconds.
encoding – Encoding format for the commands.
autorecv – If True and a command ends with ‘?’, receive a message and record it to a logger.
bufsize – Maximum byte size for receiving a message.
- Returns:
This function returns nothing.
Examples
If a text file, commands.txt, has SCPI commands:
*RST *CLS
then the following two commands are equivalent:
send_commands(['*RST', '*CLS'], '192.168.1.3', 5000) send_commands_in('commands.txt', '192.168.1.3', 5000)