X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=9bf627ca2d14d68670658b8c3f9695f021eadf77;hp=0d32cca97be02a86b4d2d4f7bc2946d320e8a8b4;hb=9ba7e4f5ec74d83c1c167655dbd0de02db15e9f9;hpb=5080c116b2f2b94172c597ef4f07e3f369665c61 diff --git a/client/GoodFET.py b/client/GoodFET.py index 0d32cca..9bf627c 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -5,7 +5,7 @@ # # This code is being rewritten and refactored. You've been warned! -import sys, time, string, cStringIO, struct, glob, serial, os; +import sys, time, string, cStringIO, struct, glob, os; import sqlite3; fmt = ("B", "= attemptlimit: return elif attempts>2: print "Resyncing."; self.serialport.flushInput() self.serialport.flushOutput() - #Explicitly set RTS and DTR to halt board. - self.serialport.setRTS(1); - self.serialport.setDTR(1); - #Drop DTR, which is !RST, low to begin the app. - self.serialport.setDTR(0); #TelosB reset, prefer software to I2C SPST Switch. - if(os.environ.get("platform")=='telosb'): + if(os.environ.get("platform")=='telosb' or os.environ.get("board")=='telosb'): #print "TelosB Reset"; self.telosBReset(); + else: + #Explicitly set RTS and DTR to halt board. + self.serialport.setRTS(1); + self.serialport.setDTR(1); + #Drop DTR, which is !RST, low to begin the app. + self.serialport.setDTR(0); - #self.serialport.write(chr(0x80)); #self.serialport.write(chr(0x80)); #self.serialport.write(chr(0x80)); #self.serialport.write(chr(0x80)); - self.serialport.flushInput() - self.serialport.flushOutput() + #self.serialport.flushInput() + #self.serialport.flushOutput() #time.sleep(60); attempts=attempts+1; self.readcmd(); #Read the first command. + #print "Got %02x,%02x:'%s'" % (self.app,self.verb,self.data); #Here we have a connection, but maybe not a good one. #print "We have a connection." connected=1; olds=self.infostring(); clocking=self.monitorclocking(); - #if(os.environ.get("platform")!='arduino'): for foo in range(1,30): if not self.monitorecho(): if self.verbose: @@ -280,8 +345,14 @@ class GoodFET: try: #print "Reading..."; self.app=ord(self.serialport.read(1)); - #print "APP=%2x" % self.app; + #print "APP=%02x" % self.app; self.verb=ord(self.serialport.read(1)); + + #Fixes an obscure bug in the TelosB. + if self.app==0x00: + while self.verb==0x00: + self.verb=ord(self.serialport.read(1)); + #print "VERB=%02x" % self.verb; self.count=( ord(self.serialport.read(1)) @@ -538,7 +609,7 @@ class GoodFET: self.MONpoke16(0x56, clock); def monitorgetclock(self): """Get the clocking value.""" - if(os.environ.get("platform")=='arduino'): + if(os.environ.get("platform")=='arduino' or os.environ.get("board")=='arduino'): return 0xDEAD; #Check for MSP430 before peeking this. return self.MONpeek16(0x56); @@ -546,7 +617,7 @@ class GoodFET: # every client. def infostring(self): - if(os.environ.get("platform")=='arduino'): + if(os.environ.get("platform")=='arduino' or os.environ.get("board")=='arduino'): return "Arduino"; else: a=self.MONpeek8(0xff0);