from __future__ import division import sys from instrumentComms import InstrumentComms DEBUG = False def wstdout(txt): sys.stdout.write(txt) sys.stdout.flush() def wstderr(txt): sys.stderr.write(txt) sys.stderr.flush() if __name__ == "__main__": ipAddress = "128.118.112.2" httpPort = 80 try: #-- Set up with serial port comms instrument = InstrumentComms(useSerial=True, baud=19200) instrument.simpleSerial(debug=DEBUG) commsType = "serial" except: #-- If that failed, try to set up with Ethernet comms instrument = InstrumentComms(useEthernet=True, ipAddress=ipAddress) commsType = "Ethernet" wstdout("\"" + instrument.query(sys.argv[1]) + "\"")
try: #-- Set up scope comms tekScope = Tek3kComms(useSerial=False, useEthernet=True, ipAddress=ipAddress) scopeIDN = tekScope.query("*IDN?") except: raise Exception("Expected Tek scope on Ethernet port. Aborting.") #============================================================================== #-- Establish comms with DDS #============================================================================== try: #-- Set up DDS comms DDS = InstrumentComms(useSerial=True, useEthernet=False, serCmdTerm='\n', baud=115200, dsrdtr=True) DDS.simpleSerial() commsType = "serial" #-- Grab IDN string DDSIDN = DDS.query("*IDN?") except: raise Exception("Expected DDS on serial port. Aborting.") #============================================================================== #-- Set scope channels, measurements #============================================================================== #============================================================================== #-- Read initial DDS parameters #============================================================================== #==============================================================================
from __future__ import with_statement from __future__ import division import sys from instrumentComms import InstrumentComms def wstdout(txt): sys.stdout.write(txt) sys.stdout.flush() def wstderr(txt): sys.stderr.write(txt) sys.stderr.flush() if __name__ == "__main__": #commsType = "Ethernet" ipAddress = "128.118.112.2" httpPort = 80 try: #-- Set up with serial port comms instrument = InstrumentComms(useSerial=True) instrument.simpleSerial() commsType = "serial" except: #-- If that failed, try to set up with Ethernet comms instrument = InstrumentComms(useEthernet=True, ipAddress=ipAddress) commsType = "Ethernet" instrument.tell(sys.argv[1])