changeset 18:9bb8a9f3df6b

Update examples to match new code.
author Daniel O'Connor <darius@dons.net.au>
date Wed, 10 Aug 2011 15:18:26 +0930
parents 20df02be818a
children cba1c44060f5
files rs_fsp7_example.py tek2024b_example.py
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rs_fsp7_example.py	Wed Aug 10 15:17:57 2011 +0930
+++ b/rs_fsp7_example.py	Wed Aug 10 15:18:26 2011 +0930
@@ -55,14 +55,16 @@
 
     # Wait up to 10 seconds for it to be done
     r.write("*OPC?")
-    print "OPC - " + r.read(10)
+    opc = scpi.getdata(r.read(10), int)
+    print "OPC - %d" % (opc)
 
     # Set peak excursion
     r.write("CALC:MARK:PEXC 6DB")
     # Find 3rd order intercept & get result
     r.write("CALC:MARK:FUNC:TOI ON")
     r.write("CALC:MARK:FUNC:TOI:RES?")
-    print "Result " + r.read(10)
+    toi = scpi.getdata(r.read(1))
+    print "Result = %.2f" % (toi)
 
     # Set data format
     r.write("FORM REAL,32")
--- a/tek2024b_example.py	Wed Aug 10 15:17:57 2011 +0930
+++ b/tek2024b_example.py	Wed Aug 10 15:18:26 2011 +0930
@@ -52,13 +52,13 @@
 
     # Fetch horizontal scale
     u.write("HOR:MAIN:SCALE?")
-    hscale = float(u.read(1).split()[1])
-    print "Horizontal scale is %f sec/div" % (hscale)
+    hscale = scpi.getdata(u.read())
+    print "Horizontal scale is %f nsec/div" % (hscale * 1e9)
 
     # Make sure the previous commands have been executed
     u.write("*WAI")
 
-    # Fetch curve data (wait up to 1 second)
+    # Fetch curve data (wait up to 1 second) since the read takes a little while
     u.write("CURVE?")
     then = time.time()                            
     result = u.read(1.0)
@@ -66,7 +66,7 @@
     print "CURVE read took %f milliseconds" % ((now - then) * 1000.0)
 
     # Parse data
-    ary = scpi.bindecode(result, header = ':CURVE ', dtype = numpy.dtype('>h'))
+    ary = scpi.bindecode(result, dtype = numpy.dtype('>h'))
 
     # Convert to volts
     ary = ary / 32768.0 * vscale