Reliable sniffing of 802.15.4 on the TelosB.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Mon, 21 Feb 2011 05:15:53 +0000 (05:15 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Mon, 21 Feb 2011 05:15:53 +0000 (05:15 +0000)
No missed packets this time.

git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@932 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETCCSPI.py
firmware/apps/radios/ccspi.c

index 1d27c24..612ce3e 100644 (file)
@@ -141,7 +141,7 @@ class GoodFETCCSPI(GoodFET):
         """
         
         # TODO -- Flush only if there's an overflow.
         """
         
         # TODO -- Flush only if there's an overflow.
-        self.strobe(0x08); #SFLUSHRX
+        #self.strobe(0x08); #SFLUSHRX
         
         data="\0";
         self.data=data;
         
         data="\0";
         self.data=data;
index ec0e207..5a3d5d6 100644 (file)
@@ -140,23 +140,34 @@ void ccspi_handle_fn( uint8_t const app,
     break;
   case CCSPI_RX:
     #ifdef FIFOP
     break;
   case CCSPI_RX:
     #ifdef FIFOP
-    //Wait for any incoming packet to finish.
-    //while(!SFD);
-    while(SFD);
-    delay(1000);
     
     
+     //Has there been an overflow?
+    if((!FIFO)&&FIFOP){
+      debugstr("Clearing overflow");
+      CLRSS;
+      ccspitrans8(0x08); //SFLUSHRX
+      SETSS;
+    }
     
     //Is there a packet?
     
     //Is there a packet?
-    if((!SFD) && FIFOP){ // &&FIFOP to do address verification.
+    if(FIFOP&&FIFO){
+      //Wait for completion.
+      while(SFD);
+      
       //Get the packet.
       CLRSS;
       //Get the packet.
       CLRSS;
-      //ccspitrans8(CCSPI_RXFIFO);
-      ccspitrans8(0x3F|0x40);
-      cmddata[1]=0xff; //to be replaced with length
-      for(i=0;i<cmddata[1];i++)
+      ccspitrans8(CCSPI_RXFIFO | 0x40);
+      //ccspitrans8(0x3F|0x40);
+      cmddata[0]=0xff; //to be replaced with length
+      for(i=0;i<cmddata[0];i++)
        cmddata[i]=ccspitrans8(0xde);
       SETSS;
        cmddata[i]=ccspitrans8(0xde);
       SETSS;
-      txdata(app,verb,cmddata[0]);
+      
+      //Flush buffer.
+      CLRSS;
+      ccspitrans8(0x08); //SFLUSHRX
+      SETSS;
+      txdata(app,verb,i);
     }else{
       //No packet.
       txdata(app,verb,0);
     }else{
       //No packet.
       txdata(app,verb,0);