X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=178ebd61d7addb450c323070b4b62ed10945f958;hp=74f6e5d277b83a9ead4f067f743bad424bc2b464;hb=9efdb05e8177ee6925bda8ca39f0a113505bdf57;hpb=24d088eef312fd62fdbe15f08affba24ce498edb diff --git a/client/GoodFET.py b/client/GoodFET.py index 74f6e5d..178ebd6 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -140,6 +140,7 @@ class GoodFET: """Open the serial port""" # Make timeout None to wait forever, 0 for non-blocking mode. import serial; + fixserial=False; if os.name=='nt' and sys.version.find('64 bit')!=-1: print "WARNING: PySerial requires a 32-bit Python build in Windows."; @@ -194,16 +195,25 @@ class GoodFET: #print "'%s'!=\n'%s'" % (self.data,"http://goodfet.sf.net/"); if attemptlimit is not None and attempts >= attemptlimit: return - elif attempts>2: - print "Resyncing. See the GoodFET FAQ about missing info flash."; + elif attempts==2 and os.environ.get("board")!='telosb': + print "See the GoodFET FAQ about missing info flash."; + self.serialport.setTimeout(0.2); + elif attempts == 100: + print "Tried 100 times to connect and failed." + sys.stdout.write("Continuing to try forever.") # No newline + sys.stdout.flush() + self.verbose=True # Something isn't going right, give the user more info + elif attempts > 100 and attempts % 10 == 0: + sys.stdout.write('.') + sys.stdout.flush() #self.serialport.flushInput() #self.serialport.flushOutput() #TelosB reset, prefer software to I2C SPST Switch. - if (os.environ.get("platform")=='telosb' or os.environ.get("board")=='telosb'): + if (os.environ.get("board")=='telosb'): #print "TelosB Reset"; self.telosBReset(); - elif (os.environ.get("board")=='zolertiaz1' or os.environ.get("board")=='z1'): + elif (os.environ.get("board")=='z1'): self.bslResetZ1(invokeBSL=0); elif (os.environ.get("board")=='apimote1') or (os.environ.get("board")=='apimote'): #Explicitly set RTS and DTR to halt board. @@ -238,6 +248,8 @@ class GoodFET: #Here we have a connection, but maybe not a good one. #print "We have a connection." connected=1; + if attempts >= 100: + print "" # Add a newline olds=self.infostring(); clocking=self.monitorclocking(); for foo in range(1,30): @@ -245,8 +257,8 @@ class GoodFET: if self.verbose: print "Comm error on %i try, resyncing out of %s." % (foo, clocking); - connected=0; - break; + connected=0; + break; if self.verbose: print "Connected after %02i attempts." % attempts; self.mon_connected(); self.serialport.setTimeout(12); @@ -573,6 +585,9 @@ class GoodFET: self.writecmd(0,0x03,3,self.data); return ord(self.data[0]); def poke16(self,address,value): + """Set a word of memory by the monitor.""" + self.MONpoke16(address,value); + def MONpoke16(self,address,value): """Set a word of memory by the monitor.""" self.pokebyte(address,value&0xFF); self.pokebyte(address,(value>>8)&0xFF); @@ -666,7 +681,8 @@ class GoodFET: data="The quick brown fox jumped over the lazy dog."; self.writecmd(self.MONITORAPP,0x81,len(data),data); if self.data!=data: - print "Comm error recognized by monitorecho(), got:\n%s" % self.data; + if self.verbose: + print "Comm error recognized by monitorecho(), got:\n%s" % self.data; return 0; return 1;