X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=673ffded9b21dbb29dbedfc23a83b51b8ac7d8b1;hp=e60c31a17c37318e0bad43f61892ca69cccce032;hb=4e119f07426373a75db57b798e65a485bfc39322;hpb=dea6bf631cff92a6682f8898ec17315de1a305de diff --git a/client/GoodFET.py b/client/GoodFET.py index e60c31a..673ffde 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -72,7 +72,7 @@ class GoodFET: return self.symbols.get(name); def timeout(self): print "timeout\n"; - def serInit(self, port=None, timeout=2): + def serInit(self, port=None, timeout=2, attemptlimit=None): """Open the serial port""" # Make timeout None to wait forever, 0 for non-blocking mode. @@ -90,6 +90,10 @@ class GoodFET: glob_list = glob.glob("/dev/ttyUSB*"); if len(glob_list) > 0: port = glob_list[0]; + if port is None: + glob_list = glob.glob("/dev/ttyU0"); + if len(glob_list) > 0: + port = glob_list[0]; if os.name=='nt': from scanwin32 import winScan; scan=winScan(); @@ -115,7 +119,9 @@ class GoodFET: connected=0; while connected==0: while self.verb!=0x7F or self.data!="http://goodfet.sf.net/": - if attempts>2: + if attemptlimit is not None and attempts >= attemptlimit: + return + elif attempts>2: print "Resyncing."; self.serialport.flushInput() self.serialport.flushOutput() @@ -153,6 +159,8 @@ class GoodFET: if self.verbose: print "Connected after %02i attempts." % attempts; self.mon_connected(); self.serialport.setTimeout(12); + def serClose(self): + self.serialport.close(); def telosSetSCL(self, level): self.serialport.setRTS(not level) def telosSetSDA(self, level):