From: rmspeers Date: Thu, 24 Feb 2011 20:55:06 +0000 (+0000) Subject: rmspeers on GoodFETCCSPI fixing RF_autocrc and adding support to act like a TinyOS... X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=426452e03b65bd972aa0d1df48af55e190ff1114;hp=945e0c205122421188e9ee25c973b9236f2e4038 rmspeers on GoodFETCCSPI fixing RF_autocrc and adding support to act like a TinyOS CountToRadio demo application git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@953 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- diff --git a/client/GoodFETCCSPI.py b/client/GoodFETCCSPI.py index 10e94be..3e17532 100644 --- a/client/GoodFETCCSPI.py +++ b/client/GoodFETCCSPI.py @@ -258,8 +258,7 @@ class GoodFETCCSPI(GoodFET): return; def RF_autocrc(self,autocrc=1): mdmctrl0=self.peek(0x11); - return; - if autocrc==1: + if autocrc==0: mdmctrl0=mdmctrl0&(~0x0020); else: mdmctrl0=mdmctrl0|0x0020; diff --git a/client/goodfet.ccspi b/client/goodfet.ccspi index d63ea4c..80e9fae 100755 --- a/client/goodfet.ccspi +++ b/client/goodfet.ccspi @@ -152,14 +152,52 @@ if(sys.argv[1]=="txtest"): 0xff, 0xff, 0xff, 0xff, 0xde, 0xad, 0xbe, 0xef, 0xba, 0xbe, 0xc0]); +if(sys.argv[1]=="txtoscount"): + ''' + Clone of what TinyOS's BlinkToLED demo code does. + Specify a channel a TinyOS mote programmed with BlinkToLED is on, and this will act as the second device. + ''' + client.RF_promiscuity(1); + client.RF_autocrc(1); + if len(sys.argv)>2: + freq=eval(sys.argv[2]); + if freq>100: + client.RF_setfreq(freq); + else: + client.RF_setchan(freq); + client.CC_RFST_RX(); + print "Listening as %010x on %i MHz" % (client.RF_getsmac(), client.RF_getfreq()/10**6); + print "Transmitting like the TinyOS CountToRadio program on %i MHz" % (client.RF_getfreq()/10**6); + #i = 0; + #countpkt = [0x0f, 0x41, 0x88, 0xFF, 0x22, 0x00, 0xff, 0xff, 0x01, 0x00, 0x3f, 0x06, 0xFF, 0x00, 0x00]; + while 1: + packet=None; + while packet==None: + packet=client.RF_rxpacket(); + print "Recd:", + client.printpacket(packet); + pkt = packet[:14]# + "\x00\x00"; + print "Sent:", + client.printpacket(pkt) + client.RF_txpacket(pkt); + #TODO expand to actually do increments itself, if desired: + #pkt = countpkt[:]; + #pkt[3] = i; + #for j in pkt: + # print hex(j)[2:],; + #print; + #client.RF_txpacket(pkt); + #if i >= 31: i = 0; + #else: i += 1; + #time.sleep(1); -if(sys.argv[1]=="txpiptest"): +if(sys.argv[1]=="txpiptest"):# or sys.argv[1]=="txpipscapy"): if len(sys.argv)>2: freq=eval(sys.argv[2]); if freq>100: client.RF_setfreq(freq); else: - print "Channels not yet supported." + client.RF_setchan(freq); print "Transmitting on as %010x on %i MHz" % ( client.RF_getsmac(), client.RF_getfreq()/10**6); @@ -179,7 +217,6 @@ if(sys.argv[1]=="txpiptest"): 0xde, 0xad, 0xbe, 0xef, 0xba, 0xbe, 0xc0, - #Preamble 0x00, 0x00, 0x00, #SFD