[Tinyos-help] AMSend.send segmentation fault in RadioCountToLedsC

Philip Levis pal at cs.stanford.edu
Wed Apr 7 08:29:19 PDT 2010


Run it in gdb and figure out where the segfault is. Just because the segfault is on that application does not mean the application file is at fault. It could be how you configure the simulator, etc.

Phil

On Apr 7, 2010, at 6:13 AM, avinash chaurasia wrote:

> this is code RadioCountToLedsC
> module RadioCountToLedsC @safe() {
>   uses {
>     interface Leds;
>     interface Boot;
>     interface Receive;
>     interface AMSend;
>     interface Timer<TMilli> as MilliTimer;
>     interface SplitControl as AMControl;
>     interface Packet;
>   }
> }
> implementation {
> 
>   message_t packet;
> 
>   bool locked;
>   uint16_t counter = 0;
>   
>   event void Boot.booted() {
>     call Leds.led0On();
>     dbg("Boot,RadioCountToLedsC", "Application booted.\n");
>     dbg("RadioCountToLedsC", "Application booted again.\n");
>     dbg("Boot", "Application booted a third time.\n");
>     call AMControl.start();
>   }
> 
>   event void AMControl.startDone(error_t err) {
>     if (err == SUCCESS) {
>       call MilliTimer.startPeriodic(250);
>     }
>     else {
>       call AMControl.start();
>     }
>   }
> 
>   event void AMControl.stopDone(error_t err) {
>     // do nothing
>   }
>   
>   event void MilliTimer.fired() {
>     counter++;
>     dbg("RadioCountToLedsC", "RadioCountToLedsC: timer fired, counter is %hu.\n", counter);
>     if (locked) {
>       return;
>     }
>     else {
>       radio_count_msg_t* rcm = (radio_count_msg_t*)call Packet.getPayload(&packet, sizeof(radio_count_msg_t));
>       if (rcm == NULL) {
>     return;
>       }
> 
>       rcm->counter = counter;
>       if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(radio_count_msg_t)) == SUCCESS) {
>     dbg("RadioCountToLedsC", "RadioCountToLedsC: packet sent. %hu\n", counter);    
>     locked = TRUE;
>       }
>     }
>   }
> 
>   event message_t* Receive.receive(message_t* bufPtr, 
>                    void* payload, uint8_t len) {
>     dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
>     if (len != sizeof(radio_count_msg_t)) {return bufPtr;}
>     else {
>       radio_count_msg_t* rcm = (radio_count_msg_t*)payload;
>       if (rcm->counter & 0x1) {
>     call Leds.led0On();
>       }
>       else {
>     call Leds.led0Off();
>       }
>       if (rcm->counter & 0x2) {
>     call Leds.led1On();
>       }
>       else {
>     call Leds.led1Off();
>       }
>       if (rcm->counter & 0x4) {
>     call Leds.led2On();
>       }
>       else {
>     call Leds.led2Off();
>       }
>       return bufPtr;
>     }
>   }
> 
>   event void AMSend.sendDone(message_t* bufPtr, error_t error) {
>     dbg("RadioCountToLedsC", "SendDone called.\n");
>     if (&packet == bufPtr) {
>       locked = FALSE;
>     }
>   }
> 
> }
> 
> 
> on simulation it gives segmentation fault
>  1   2   -54.0
>   2   1   -55.0
>   1   3   -60.0
>   3   1   -60.0
>   2   3   -64.0
>   3   2   -64.0
> Creating noise model for  0
> Creating noise model for  1
> Creating noise model for  2
> Creating noise model for  3
> DEBUG (0): Application booted.
> DEBUG (0): Application booted again.
> DEBUG (1): Application booted.
> DEBUG (1): Application booted again.
> DEBUG (2): Application booted.
> DEBUG (2): Application booted again.
> DEBUG (3): Application booted.
> DEBUG (3): Application booted again.
> DEBUG (1): RadioCountToLedsC: timer fired, counter is 1.
> DEBUG (1): RadioCountToLedsC: packet sent.
> DEBUG (0): RadioCountToLedsC: timer fired, counter is 1.
> DEBUG (0): RadioCountToLedsC: packet sent.
> DEBUG (2): RadioCountToLedsC: timer fired, counter is 1.
> DEBUG (2): RadioCountToLedsC: packet sent.
> DEBUG (3): RadioCountToLedsC: timer fired, counter is 1.
> DEBUG (3): RadioCountToLedsC: packet sent.
> Segmentation fault
> 
> 
> Please help me.
> 
> 
> Thanks
> Avinash Kumar Chaurasia
> 
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help




More information about the Tinyos-help mailing list