--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/load_gpib_plot.py Mon Dec 10 20:05:39 2007 +0100 @@ -0,0 +1,54 @@ +import sys +import time +import serial +p = serial.Serial(port="/dev/ttyUSB0", baudrate=115200, timeout=0.1) + +p.write('++addr 5\r') # set address to 0 +p.write('++mode 0\r') # read listen only mode +p.write('++mode\r') +for i in range(10): + mode = p.readline().strip() + if mode != "": + break + time.sleep(0.1) +print "mode = ", mode +if mode == '': + print "strange" + sys.exit() + +res = "" +i=0 + +replies={ + "OE": "0", + "OH": "0,0,10000,7500", + "OI": "7470A", + "OP": "0,0,10000,7500", + "OO": "0,1,0,0,0,0,0,0", + "OF": "40,40", + "OS": "24", + } + +while i<15: + l = p.readline().strip() + if l == "": + i += 1 + for k, v in replies.items(): + if res.endswith(k) or res.endswith(k+';'): + print "got commend", k + p.write("%s"%v) + if k == "OS": + replies[k] = "16" + break + p.write('\r') + time.sleep(0.1) + continue + print "got a new line (%s chars) [i=%s]"%(len(l), i) + res += l + "\n" + i = 0 +print "over" +print "res = ", res + +open('out.gpib', 'w').write(res) + +