Default JEDEC entry for M25P80 on Telos B.
[goodfet] / client / goodfet.ccspi
index d5b869c..8e84ba7 100755 (executable)
@@ -26,6 +26,10 @@ if(len(sys.argv)==1):
     print "%s bsniff [chan]" % sys.argv[0];
     print "%s sniffdissect" % sys.argv[0];
     
+    
+    print;
+    print "%s txtoscount [-i|-r]   TinyOS BlinkToLED" % sys.argv[0];    
+    
     sys.exit();
 
 #Initialize FET and set baud rate
@@ -92,6 +96,7 @@ if(sys.argv[1]=="rssi"):
 if(sys.argv[1]=="sniff" or sys.argv[1]=="sniffdissect"):
     #Promiscuous mode.
     client.RF_promiscuity(1);
+    client.RF_autocrc(0);
     
     if len(sys.argv)>2:
         freq=eval(sys.argv[2]);
@@ -116,6 +121,7 @@ if(sys.argv[1]=="bsniff"):
     #Just broadcast.
     client.RF_promiscuity(0);
     client.RF_setsmac(0xFFFFFFFF);
+    client.RF_autocrc(1);
     
     if len(sys.argv)>2:
         freq=eval(sys.argv[2]);
@@ -150,39 +156,98 @@ 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.
+    '''
+    if (len(sys.argv)<=3):
+        print "Provide -r to work via replays or -i to work via incrementing itself.";
+        sys.exit(1);
+    if (sys.argv[3]=="-r"):
+        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);
+    if (sys.argv[3]=="-r"):
+        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);
+    if (sys.argv[3]=="-i"):
+        i = 0;
+        countpkt = [0x0f, 0x41, 0x88, 0xFF, 0x22, 0x00, 0xff, 0xff, 0x01, 0x00, 0x3f, 0x06, 0x00, 0xFF];
+    while 1:
+        if (sys.argv[3]=="-r"): #give -r to do via replays from the other device
+            packet=None;
+            while packet==None:
+                packet=client.RF_rxpacket();
+            #print "Recd:",
+            #client.printpacket(packet);
+            pkt = packet[:14];
+            #print "Sent:",
+            #client.printpacket(pkt)
+            client.RF_txpacket(pkt);
+        elif (sys.argv[3]=="-i"): #give -i to have it increment and send
+            #Use this code for it to actually do increments itself:
+            pkt = countpkt[:];
+            pkt[3] = i;
+            pkt[13] = i+1;
+            #for j in pkt:
+            #    print hex(j)[2:],;
+            #print;
+            client.RF_txpacket(pkt);
+            if i >= 31: i = 0;
+            else:       i += 1;
+            time.sleep(0.5);
 
-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);
     
+    client.RF_setsync(0xFFFF);
+    
     while 1:
-        client.RF_txpacket([0x2f, 0x01, 0x08, 0x82,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xde, 0xad, 0xbe, 0xef,
-                            0xba, 0xbe, 0xc0,
-                            
-                            0x00, 0x00, 0x00, 0x00,
-                            0x7a,
-                            0x0f, 0x01, 0x08, 0x82,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xde, 0xad, 0xbe, 0xef,
-                            0xba, 0xbe, 0xc0,
-                            
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            0xff, 0xff, 0xff, 0xff,
-                            ]);
+        client.RF_txpacket([
+                0x7f, 
+                #Real header, must begin with SFD.
+                0x00, 0x00, 0x00,
+                0x00, 0xA7,
+                
+                #Length
+                0x1f, 0x01, 0x08, 0x82,
+                0xDF, 0xff, 0xff, 0xff,
+                0xde, 0xad, 0xbe, 0xef,
+                0xba, 0xbe, 0xc0,
+                
+                #Preamble
+                0x00, 0x00, 0x00,
+                #SFD
+                0x00, 0xA7,  #CC2420 SFD
+                #Packet In Packet
+                0x0f, 0x01, 0x08, 0x82,
+                0xff, 0xff, 0xff, 0xff,
+                0xde, 0xad, 0xbe, 0xef,
+                0xba, 0xbe, 0xc0,
+                
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff,
+                ]);
 
 if(sys.argv[1]=="peek"):
     start=0x0000;