summaryrefslogtreecommitdiffstats
path: root/lab_control/sds1000xe.py
diff options
context:
space:
mode:
Diffstat (limited to 'lab_control/sds1000xe.py')
-rw-r--r--lab_control/sds1000xe.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/lab_control/sds1000xe.py b/lab_control/sds1000xe.py
index 859b1bf..67fc29b 100644
--- a/lab_control/sds1000xe.py
+++ b/lab_control/sds1000xe.py
@@ -1,31 +1,44 @@
+"""
+Implements partial support for Siglent SDS1000X-E series oscilloscopes.
+"""
+
import socket
import re
from lab_control.oscilloscope import Oscilloscope
+def _checkChannel(channel):
+ assert channel in SDS1000XE.AVAILABLE_CHANNELS, "SDS1000X-E: Invalid channel {channel}"
+
class SDS1000XE(Oscilloscope):
+ """
+ Instances of this class connect to the SDS1000X-E IP
+ and port and offer an API to control the device.
+ """
PORT = 5025
TIMEOUT = 1.0
AVAILABLE_CHANNELS = range(1, 5)
def __init__(self, address):
+ super().__init__()
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.connect((address, SDS1000XE.PORT))
self._socket.settimeout(SDS1000XE.TIMEOUT)
- def _measure(self, channel: int, code: str) -> float:
- assert channel in SDS1000XE.AVAILABLE_CHANNELS, "SDS1000X-E: Invalid channel {channel}"
+ def _measure(self, channel: int, code: str) -> float:
+ _checkChannel(channel)
+ pattern = r"C(?P<responseChannel>\d):PAVA .+,(?P<rawMeasurement>[\d.E+-]+)\w+"
query = f"C{channel}:PAVA? {code}\r\n"
self._socket.sendall(query.encode())
try:
# TODO add code to regex
response = self._socket.recv(4096).decode()
- m = re.search(r"C(?P<responseChannel>\d):PAVA .+,(?P<rawMeasurement>[\d.E+-]+)\w+", response)
- measurement = float(m.group("rawMeasurement"))
- except TimeoutError as e:
+ matches = re.search(pattern, response)
+ measurement = float(matches.group("rawMeasurement"))
+ except TimeoutError:
measurement = None
-
+
return measurement
def measureAmplitude(self, channel: int) -> float:
@@ -39,4 +52,3 @@ class SDS1000XE(Oscilloscope):
def measureFrequency(self, channel: int) -> float:
return self._measure(channel, "FREQ")
-