X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETCCSPI.py;h=612ce3e685ca2f4bb2f9c0ae2946db9114179e06;hp=2e69d464f4eb07665b1068790de8105f0ec2958c;hb=1c6017d0b18be5b685a6ce257d2e2da110e597a4;hpb=47036ca60e6550e1ace4e2f02363e3da02db1240 diff --git a/client/GoodFETCCSPI.py b/client/GoodFETCCSPI.py index 2e69d46..612ce3e 100644 --- a/client/GoodFETCCSPI.py +++ b/client/GoodFETCCSPI.py @@ -130,7 +130,7 @@ class GoodFETCCSPI(GoodFET): return 0xdeadbeef; def RF_getrssi(self): """Returns the received signal strenght, with a weird offset.""" - rssival=self.peek(0x13)&0xFF; #raw RSSI register, should normalize this + rssival=self.peek(0x13)&0xFF; #raw RSSI register return rssival^0x80; lastpacket=range(0,0xff); def RF_rxpacket(self): @@ -139,6 +139,25 @@ class GoodFETCCSPI(GoodFET): implementation works by comparing the buffer to the older contents. """ + + # TODO -- Flush only if there's an overflow. + #self.strobe(0x08); #SFLUSHRX + + data="\0"; + self.data=data; + self.writecmd(self.CCSPIAPP,0x80,len(data),data); + buffer=self.data; + + self.lastpacket=buffer; + if(len(buffer)==0): + return None; + return buffer; + def RF_rxpacket_old(self): + """Get a packet from the radio. Returns None if none is waiting. In + order to not require the SFD, FIFO, or FIFOP lines, this + implementation works by comparing the buffer to the older + contents. + """ self.strobe(0x03); #SRXON self.strobe(0x08); #SFLUSHRX @@ -147,7 +166,7 @@ class GoodFETCCSPI(GoodFET): buffer=self.trans(buffer); new=False; - for foo in range(2,20): + for foo in range(0,ord(buffer[0])): if buffer[foo]!=self.lastpacket[foo]: new=True; if not new: @@ -159,6 +178,14 @@ class GoodFETCCSPI(GoodFET): def RF_carrier(self): """Hold a carrier wave on the present frequency.""" print "Don't know how to hold a carrier."; + def RF_promiscuity(self,promiscuous=1): + mdmctrl0=self.peek(0x11); + print "mdmctrl0 was %04x" % mdmctrl0; + mdmctrl0=mdmctrl0&(~0x800); + print "mdmctrl0 is now %04x" % mdmctrl0; + self.poke(0x11,mdmctrl0); + return; + packetlen=16; def RF_setpacketlen(self,len=16): """Set the number of bytes in the expected payload."""