+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);