Hi,
I think your two questions might be related. I had a similar problem
once where it turned out that the ACKs were received too late. In my
case it helped to enable hardware acknowledgments. You can try this by
adding the following line to your Makefile:
CFLAGS+=-DCC2420_HW_ACKNOWLEDGEMENTS
Then rebuild the application with the following command:
"make clean && make micaz"
(Use the "make clean" to ensure that the app will be completely rebuilt).
Cheers,
Urs
On 12/09/2010 08:12 AM, cui wrote:
> I modified the apps/EasyCollection to add a counter in the message, and
> I found that the Root received every message for many times(about 30).
> Is that normal and how can I avoid this.
> part of my code
> ---------------------------------------------
> module NodeC {
> uses interface Boot;
> uses interface SplitControl as RadioControl;
> uses interface StdControl as RoutingControl;
> uses interface Send;
> uses interface Leds;
> uses interface Timer<TMilli>;
> uses interface RootControl;
> uses interface Receive;
> }
> implementation {
> message_t packet;
> bool sendBusy = FALSE;
> uint16_t counter = 0;
> event void Boot.booted() {
> call RadioControl.start();
> }
> event void RadioControl.startDone(error_t err) {
> if (err != SUCCESS)
> call RadioControl.start();
> else {
> call RoutingControl.start();
> call Timer.startPeriodic(2000);
> }
> }
> event void RadioControl.stopDone(error_t err) {}
> void sendMessage() {
> SensorMsg* msg =
> (SensorMsg*)call Send.getPayload(&packet, sizeof(SensorMsg));
> msg->nodeid = TOS_NODE_ID;
> msg->sensorType = SENSOR_TYPE_SOUND;
> msg->data = counter++;
> if (call Send.send(&packet, sizeof(SensorMsg)) != SUCCESS)
> call Leds.led0On();
> else
> sendBusy = TRUE;
> }
> event void Timer.fired() {
> if (!sendBusy) {
> call Leds.led2Toggle();
> sendMessage();
> }
> }
> event void Send.sendDone(message_t* m, error_t err) {
> if (err != SUCCESS)
> call Leds.led0On();
> sendBusy = FALSE;
> }
> }
> ************************************************
> module RootC {
> uses interface Boot;
> uses interface SplitControl as RadioControl;
> uses interface SplitControl as SerialControl;
> uses interface StdControl as RoutingControl;
> uses interface AMSend as UartAMSend;
> uses interface AMPacket as UartAMPacket;
> uses interface Packet as UartPacket;
> uses interface Leds;
> uses interface Timer<TMilli>;
> uses interface RootControl;
> uses interface Receive;
> }
> implementation {
> message_t packet;
> SensorMsg *sensorMsg;
> bool UartSendBusy = FALSE;
> event void Boot.booted() {
> call RadioControl.start();
> call SerialControl.start();
> }
> event void RadioControl.startDone(error_t err) {
> if (err != SUCCESS)
> call RadioControl.start();
> else {
> call RoutingControl.start();
> call RootControl.setRoot();
> }
> }
> event void RadioControl.stopDone(error_t err) {}
> event void SerialControl.startDone(error_t error) {
> if( error == SUCCESS ) {
> call Leds.led0Toggle();
> } else {
> call SerialControl.start();
> call Leds.led2Toggle();
> }
> }
> event void SerialControl.stopDone(error_t err) {};
> event void UartAMSend.sendDone(message_t *msg, error_t err) {
> if(&packet==msg) {
> UartSendBusy = FALSE;
> }
> }
> event void Timer.fired() {
> }
> event message_t*
> Receive.receive(message_t* msg, void* payload, uint8_t len) {
> SensorMsg *btrpkt = (SensorMsg *)call UartPacket.getPayload(&packet, NULL);
> sensorMsg = (SensorMsg*)payload;
> btrpkt->nodeid = sensorMsg->nodeid;
> btrpkt->sensorType = sensorMsg->sensorType;
> btrpkt->data = sensorMsg->data;
> call Leds.led1Toggle();
> if( (call UartAMSend.send(AM_BROADCAST_ADDR, &packet,
> sizeof(SensorMsg)))==SUCCESS) {
> UartSendBusy = TRUE;
> }
> return msg;
> }
> 2010-12-09
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help