X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=d5e132f6c59956e1644132153725fc00396f5e52;hp=1caad81ecf3e64fefb04033023461366a4c84d0d;hb=3b792eaee038953bb9d73f29a80aaebcf6399655;hpb=effb18af1d73fbdf0f1e8aa57478e289935d353c diff --git a/client/GoodFET.py b/client/GoodFET.py index 1caad81..d5e132f 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -52,18 +52,23 @@ class GoodFETbtser: """py-bluez class for emulating py-serial.""" def __init__(self,btaddr): import bluetooth; - while btaddr==None or btaddr=="none" or btaddr=="bluetooth": + if btaddr==None or btaddr=="none" or btaddr=="bluetooth": print "performing inquiry..." nearby_devices = bluetooth.discover_devices(lookup_names = True) print "found %d devices" % len(nearby_devices) for addr, name in nearby_devices: print " %s - '%s'" % (addr, name) + #TODO switch to wildcards. if name=='FireFly-A6BD': btaddr=addr; + if name=='RN42-A94A': + btaddr=addr; + + print "Please set $GOODFET to the address of your device."; + sys.exit(); print "Identified GoodFET at %s" % btaddr; - # BlueFET doesn't run the Service Discovery Protocol. - # Instead we manually use the portnumber. + # Manually use the portnumber. port=1; print "Connecting to %s on port %i." % (btaddr, port); @@ -170,7 +175,7 @@ class GoodFET: a=1; baud=115200; - if(os.environ.get("platform")=='arduino'): + if(os.environ.get("platform")=='arduino' or os.environ.get("board")=='arduino'): baud=19200; #Slower, for now. self.serialport = serial.Serial( port, @@ -195,7 +200,7 @@ class GoodFET: self.serialport.flushOutput() #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: @@ -222,7 +227,6 @@ class GoodFET: 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: @@ -609,7 +613,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); @@ -617,7 +621,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);