Socket Connection¶
TCP/IP socket communication
TCP socket implementation for SCPI communication.
SocketConnection
¶
Bases: BaseConnection
TCP socket connection for SCPI commands over Ethernet.
Initialize socket connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
IP address or hostname of the oscilloscope |
required |
port
|
int
|
TCP port number (default: 5024 for Siglent SCPI) |
5024
|
timeout
|
float
|
Command timeout in seconds (default: 5.0) |
5.0
|
Source code in scpi_control/connection/socket.py
connect
¶
Establish TCP connection to the oscilloscope.
Raises:
| Type | Description |
|---|---|
SiglentConnectionError
|
If connection fails |
SiglentTimeoutError
|
If connection times out |
Source code in scpi_control/connection/socket.py
disconnect
¶
write
¶
Send a SCPI command to the oscilloscope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
SCPI command string |
required |
Raises:
| Type | Description |
|---|---|
SiglentConnectionError
|
If not connected |
SiglentTimeoutError
|
If command times out |
CommandError
|
If command contains non-ASCII characters or fails |
Source code in scpi_control/connection/socket.py
read
¶
Read response from the oscilloscope.
Returns:
| Type | Description |
|---|---|
str
|
Response string from oscilloscope |
Raises:
| Type | Description |
|---|---|
SiglentConnectionError
|
If not connected |
SiglentTimeoutError
|
If read times out |
Source code in scpi_control/connection/socket.py
query
¶
Send a command and read the response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
SCPI query command |
required |
Returns:
| Type | Description |
|---|---|
str
|
Response string from oscilloscope |
Raises:
| Type | Description |
|---|---|
SiglentConnectionError
|
If not connected |
SiglentTimeoutError
|
If command times out |
CommandError
|
If command fails |
Source code in scpi_control/connection/socket.py
read_raw
¶
Read raw binary data from oscilloscope.
Used for reading waveform data in binary format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
Optional[int]
|
Number of bytes to read (None for all available) |
None
|
Returns:
| Type | Description |
|---|---|
bytes
|
Raw binary data |
Raises:
| Type | Description |
|---|---|
SiglentConnectionError
|
If not connected |
SiglentTimeoutError
|
If read times out |
Source code in scpi_control/connection/socket.py
See Also¶
- Oscilloscope - Main oscilloscope control class for SCPI communication
- Exceptions - Custom exception classes