httpPort = 80 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 #==============================================================================
DEBUG = False PAUSE_MEAS = False WAIT_TO_COMPLETE = True startTimeSec = time.time() startTime = time.strftime("%Y-%m-%dT%H%M%S") + \ "{0:+05d}".format(-int(round(time.timezone/3600)*100)) wstderr("\nScript start time: " + startTime + "\n") #-- Instantiate FFT serial comms SR785 = InstrumentComms(useSerial=True, useEthernet=False, serCmdTerm='\r', serCmdPrefix='', argSep=',', baud=19200, bytesize=8, parity='N', stopbits=1, timeout=2, xonxoff=False, rtscts=False, dsrdtr=False) #-- Find which serial port controls the SR785 (if this succeeds, comms work) wstderr("\nFinding instrument...\n") matches = SR785.findInstrument( model="SR785", searchSerial=True, searchEthernet=False, searchGPIB=False, idnQueryStr="OUTX RS232;*IDN?", debug=DEBUG) if len(matches['serial']) == 0: raise Exception("Cannot find a serial port, or SR785 not attached to a serial port") #-- Open the first matching serial port SR785.openPort(matches['serial'][0])
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])
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]) + "\"")
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" response = instrument.listen() wstdout("\"" + response.strip() + "\"\n")