diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-02 17:26:59 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-02 17:26:59 -0500 |
commit | 60a196502ab650f3f20a5d70cfae2623f1df626a (patch) | |
tree | 9801e674badae7496d3324b4a14a0774b1ba951a /qolab/hardware/scpi.py | |
parent | 508db69a6b0a16d26cbccd2a1a1840310687d8e7 (diff) | |
download | qolab-60a196502ab650f3f20a5d70cfae2623f1df626a.tar.gz qolab-60a196502ab650f3f20a5d70cfae2623f1df626a.zip |
made an utility function
Diffstat (limited to 'qolab/hardware/scpi.py')
-rw-r--r-- | qolab/hardware/scpi.py | 16 |
1 files changed, 16 insertions, 0 deletions
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><firstSeparator><numberString><unit> + # 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 """ """ |