diff -r 3ccb0023cf41 -r a04bea92c509 gpib_plotter.py --- a/gpib_plotter.py Mon Dec 17 18:57:18 2007 +0100 +++ b/gpib_plotter.py Mon Dec 17 18:58:00 2007 +0100 @@ -2,7 +2,9 @@ import time import gpib -class GPIBplotter(gpib.GPIB): +import gpib +from prologix import GPIB +class GPIBplotter(GPIB): _replies={ "OE": "0", "OH": "0,0,10000,7500", @@ -13,7 +15,7 @@ "OS": "24", } def __init__(self, device="/dev/ttyUSB0", baudrate=115200, timeout=0.1, - address=0): + address=5): super(GPIBplotter, self).__init__(device, baudrate, timeout, address, mode=0) def load_plot(self, wait_timeout=0): @@ -35,27 +37,34 @@ self._cnx.timeout = wait_timeout firstloop = True + newdata = False while i (self._retries/2): + # ie. we just received new stuffs (i is reset in the else block) for k, v in replies.items(): - eres = res.strip() + # check wether we should reply smthg + eres = res.replace('\n', '').strip() if eres.endswith(k) or eres.endswith(k+';') or eres.endswith(k+';OE'): self._cnx.write("%s"%v) if k == "OS": replies[k] = "16" break self._cnx.write('\r') - if i > self._retries/2: - time.sleep(self._timeout) + #time.sleep(0.1) + i += 1 else: - res += l + "\n" + if not res: + print "Plotting..." + res += l + '\n' i = 0 + #time.sleep(0.1) + if res: + print "DONE (received %d characters)"%len(res) return res if __name__ == '__main__': @@ -105,7 +114,7 @@ loop = True nloop = 0 while loop: - plot = plotter.load_plot(wait_timeout=1) + plot = plotter.load_plot(wait_timeout=0.1) if options.verbose: sys.stderr.write('.') if plot: