Look carefully at the arguments in these two calls from sendDone()
and then send us a new question:
call SendMsg1.send(TOS_BCAST_ADDR, &msg1 ,sizeof(struct TreeReqMsg));
....
call SendMsg2.send(TOS_BCAST_ADDR, sizeof(struct TreeReqMsg),&msg2);
MS
Mitra Baratchi wrote:
> Dear all
>
> I am writing an application in which two consecutive messages are needed to
> be
> sent. Although I check the busy flag ,I get a segment fault error trying to
> simulate it with TOSSIM (right after when it tries to send the second
> message).
> Could anyone help me with this?
> Here is the actual code which gets the seg fault.
>
> testC.nc
>
>
> #include "test.h"
>
> module testC{
>
> uses interface Boot;
> uses interface AMSend as SendMsg1;
> uses interface AMSend as SendMsg2;
> uses interface SplitControl as AMControl;
>
>
> }
>
> implementation{
>
> message_t msg1;
> message_t msg2;
> bool busy = FALSE;
>
>
> event void Boot.booted(){
> call AMControl.start();
> dbg("BOOT", "Booted\n");
>
> }
>
>
> event void AMControl.startDone(error_t err){
> if (err ==SUCCESS)
> if(call SendMsg1.send(TOS_BCAST_ADDR, &msg1 ,sizeof(struct TreeReqMsg))==
> SUCCESS)
> busy =TRUE;
>
> }
>
> event void AMControl.stopDone(error_t err){}
>
> event void SendMsg1.sendDone(message_t* msg, error_t error)
> {dbg("BOOT", "msg1 sent done \n");
>
> if (&msg1 == msg)
> busy = FALSE;
> else {
> call SendMsg1.send(TOS_BCAST_ADDR, &msg1 ,sizeof(struct TreeReqMsg));
> }
>
> if (busy == FALSE)
> call SendMsg2.send(TOS_BCAST_ADDR, sizeof(struct TreeReqMsg),&msg2);
> ///
> here I get the error
> }
> event void SendMsg2.sendDone(message_t* mg, error_t error){}
>
> }
>
>
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help