drs4.ctrl.scpi module#
- drs4.ctrl.scpi.connect(host: None, port: str, /, *, timeout: float | None = DEFAULT_TIMEOUT) CustomSerial[source]#
- drs4.ctrl.scpi.connect(host: str, port: int, /, *, timeout: float | None = DEFAULT_TIMEOUT) CustomSocket
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: None, port: str, timeout: float | None = DEFAULT_TIMEOUT, encoding: str = DEFAULT_ENCODING, autorecv: bool = DEFAULT_AUTORECV, bufsize: int = DEFAULT_BUFSIZE) tuple[str, ...][source]#
- drs4.ctrl.scpi.send_commands(commands: IO[str] | Sequence[str] | str, /, *, host: str, port: int, timeout: float | None = DEFAULT_TIMEOUT, encoding: str = DEFAULT_ENCODING, autorecv: bool = DEFAULT_AUTORECV, bufsize: int = DEFAULT_BUFSIZE) tuple[str, ...]
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 contains ‘?’, receive a message and record it to a logger.
bufsize – Maximum byte size for receiving a message.
- Returns:
Tuple of the received messages.
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: None, port: str, timeout: float | None = DEFAULT_TIMEOUT, encoding: str = DEFAULT_ENCODING, autorecv: bool = DEFAULT_AUTORECV, bufsize: int = DEFAULT_BUFSIZE) tuple[str, ...][source]#
- drs4.ctrl.scpi.send_commands_in(path: PathLike[str] | str, /, *, host: str, port: int, timeout: float | None = DEFAULT_TIMEOUT, encoding: str = DEFAULT_ENCODING, autorecv: bool = DEFAULT_AUTORECV, bufsize: int = DEFAULT_BUFSIZE) tuple[str, ...]
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 contains ‘?’, receive a message and record it to a logger.
bufsize – Maximum byte size for receiving a message.
- Returns:
Tuple of the received messages.
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)