X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=8c5d945d645c958caaa6ab64babb4139e7ee8bc7;hp=89362dfa1249d5f1f030a7164b368056cabb441f;hb=670d14e88094aa5230087cacc420db1381711432;hpb=f82ed46ca4aa832f487c57eb0609ef6f62c24155 diff --git a/client/GoodFET.py b/client/GoodFET.py index 89362df..8c5d945 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -48,7 +48,52 @@ class SymbolTable: "values(?,?,?,?,?);", ( adr,name,memory,size,comment)); #print "Set %s=%s." % (name,adr); +class GoodFETbtser: + """py-bluez class for emulating py-serial.""" + def __init__(self,btaddr): + import 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) + if name=='FireFly-A6BD': + btaddr=addr; + print "Please set $GOODFET to the address of your device."; + sys.exit(); + print "Identified GoodFET at %s" % btaddr; + # Manually use the portnumber. + port=1; + + print "Connecting to %s on port %i." % (btaddr, port); + sock=bluetooth.BluetoothSocket(bluetooth.RFCOMM); + self.sock=sock; + sock.connect((btaddr,port)); + sock.settimeout(10); #IMPORTANT Must be patient. + + ##This is what we'd do for a normal reset. + #str=""; + #while not str.endswith("goodfet.sf.net/"): + # str=self.read(64); + # print str; + + # Instead, just return and hope for the best. + return; + + def write(self,msg): + """Send traffic.""" + import time; + self.sock.send(msg); + #time.sleep(0.1); + return; + def read(self,length): + """Read traffic.""" + data=""; + while len(data)