summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-05-31 11:22:18 +0200
committerEddy Pedroni <eddy@0xf7.com>2022-05-31 11:22:18 +0200
commitbff307e33bd1eb6e39d5edc76ce8f4434aba484d (patch)
treec24a2a9c5fdfabb60979d5826c2ae89502c94a34
parentaf1784badbede08bc14cf1f15085f2111c608cfc (diff)
Fixed bug in frequency measurement
-rw-r--r--lab_control/sds1000xe.py4
-rw-r--r--lab_control/test/mock_sds1000xe_device.py3
2 files changed, 4 insertions, 3 deletions
diff --git a/lab_control/sds1000xe.py b/lab_control/sds1000xe.py
index ef6627c..551c9ef 100644
--- a/lab_control/sds1000xe.py
+++ b/lab_control/sds1000xe.py
@@ -4,7 +4,7 @@ from lab_control.oscilloscope import Oscilloscope
class SDS1000XE(Oscilloscope):
PORT = 5025
- TIMEOUT = 0.2
+ TIMEOUT = 1.0
AVAILABLE_CHANNELS = range(1, 5)
def __init__(self, address):
@@ -21,7 +21,7 @@ class SDS1000XE(Oscilloscope):
try:
# TODO add code to regex
response = self._socket.recv(4096).decode()
- m = re.search(r"C(?P<responseChannel>\d):PAVA .+,(?P<rawMeasurement>.+)V", response)
+ m = re.search(r"C(?P<responseChannel>\d):PAVA .+,(?P<rawMeasurement>[0-9.E+-]+)\w+", response)
measurement = float(m.group("rawMeasurement"))
except TimeoutError as e:
measurement = None
diff --git a/lab_control/test/mock_sds1000xe_device.py b/lab_control/test/mock_sds1000xe_device.py
index ce752e9..b4dd222 100644
--- a/lab_control/test/mock_sds1000xe_device.py
+++ b/lab_control/test/mock_sds1000xe_device.py
@@ -54,11 +54,12 @@ class MockSDS1000XEDevice:
if opcode == "PAVA":
arg = m.group("arg")
value = self._channels[channelIndex].get(arg)
+ unit = "Hz" if arg == "FREQ" else "V"
if value is None:
return None
else:
- response = f"C{m.group('channel')}:PAVA {arg},{value:.6E}V"
+ response = f"C{m.group('channel')}:PAVA {arg},{value:.6E}{unit}"
return response
def stop(self) -> None: