From 60a196502ab650f3f20a5d70cfae2623f1df626a Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Thu, 2 Dec 2021 17:26:59 -0500 Subject: made an utility function --- qolab/hardware/scpi.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'qolab/hardware/scpi.py') diff --git a/qolab/hardware/scpi.py b/qolab/hardware/scpi.py index 279ef24..71ab556 100644 --- a/qolab/hardware/scpi.py +++ b/qolab/hardware/scpi.py @@ -2,6 +2,22 @@ provide basic class to operate SCPI capable instruments """ +import re + +def response2numStr(strIn, firstSeparator=None, unit=None): + # Often an instrument reply is in the form 'TDIV 2.00E-08S' (for example Siglent Scope) + # i.e. " + # prefix='TDIV', firstSeparator=' ', numberString='2.00E-08', unit='S' + # this function parses the reply + spltStr = re.split(firstSeparator, strIn) + prefix = spltStr[0] + rstr = spltStr[1] + spltStr = re.split(unit, rstr) + numberString = spltStr[0] + unit = spltStr[1] + return (prefix, numberString, unit) + + class SCPIinstr: """ Basic class which support SCPI commands """ """ -- cgit v1.2.3