# Module of functions to access the TDS 1012B using visa32.dll and PyVisa from visa import * from string import * def FindScope() : a = get_instruments_list() for b in a : if b.find('USB') > -1 : h = instrument(b) return h # Return the handle def ClearQueue(h) : h.write('*esr?') return h.read() def SetChannel(h, c) : h.write('data:source ch'+str(c)) class ScalingParameters : def __init__(self, h, c): # c = channel, a number # h = the scope # assume x increment is in seconds h.write('wfmpre:xunit?') self.xunit = h.read() h.write('wfmpre:xincr?') self.xinc = float(h.read()) h.write('wfmpre:yunit?') self.yunit = h.read() h.write('wfmpre:ymult?') self.ymult = float(h.read()) h.write('wfmpre:yoff?') self.yoff = float(h.read()) h.write('wfmpre:yzero?') self.yzero = float(h.read()) def GetWaveform(h, mode) : # mode is ascii or bin error = '' if lower(mode).find('asc') > -1 : h.write('data:encdg ascii') else : error = 'Only ascii mode is supported.' return error, [] h.write('curve?') return error, h.read().split(',') def FunctionsTest(): print FindScope() # Execute if __name__ == '__main__': FunctionsTest()