Hello,

I want to send messages periodically through this program, the messages are
broadcasted fine and I get a sendDone message, but the problem is that
these messages are not recieved well, I would really appreciate any help to
find out where the problem is?

includes lqer;


module lqer_M{
 provides {
           interface SplitControl;
           interface AMSend[am_id_t id];
           interface Receive[uint8_t id];

       };

    uses {
        interface SplitControl as AMControl;

        interface Timer<TMilli> as LQERTimer;


        interface Random;
        interface AMPacket;
        interface AMSend as SendPacket;

        interface Receive as ReceivePacket;


            interface PacketAcknowledgements;
         interface Packet;

    }
}
implementation{

        message_t lqer_msg_;
        message_t* p_lqer_msg_;
        lqer_table l_table[LQER_FT_SIZE];

        node_info info;
        uint8_t max=0, Pos=0;
        message_t* newADV;
        bool busy = FALSE;

    command error_t SplitControl.start() {
     int i,j;
     p_lqer_msg_ = &lqer_msg_;
    info.hop=1000;
    for(i=0; i<16; i++){
        info.m[i]=1;
    }

    for(i = 0; i< LQER_FT_SIZE; i++) {
             l_table[i].nid = INVALID_NODE_ID;
        l_table[i].hop  = 1000;
        for (j=0; j<16; j++)
        {
            l_table[i].m[j]=1;

        }
        }

        call AMControl.start();
        return SUCCESS;
    }
    command error_t SplitControl.stop() {
        call AMControl.stop();
        return SUCCESS;
    }



  event void AMControl.startDone( error_t e ) {
    if ( e == SUCCESS ) {
      call LQERTimer.startPeriodic( LQER_DEFAULT_PERIOD );
      signal SplitControl.startDone(e);
    } else {
      call AMControl.start();
    }
  }



  event void AMControl.stopDone(error_t e){
    call LQERTimer.stop();
    signal SplitControl.stopDone(e);
  }


event void LQERTimer.fired() {
        message_t* lqer_adv_msg;

        lqer_adv_hdr* new_ADV=(lqer_adv_hdr*)(lqer_adv_msg->data);
        am_addr_t me = call AMPacket.address();




        if (me==0001){
            new_ADV->src = me;

            new_ADV->hop = 0;

            newADV= (message_t*)(&new_ADV);

            dbg("GRAPE_DBG", "%s\t LQER: Sink address: %d\n",
sim_time_string(), me);
                  call PacketAcknowledgements.requestAck(newADV);
            call SendPacket.send( AM_BROADCAST_ADDR, newADV, call
Packet.payloadLength(newADV) );

        }


  }







event message_t* ReceivePacket.receive( message_t* p_msg, void* payload,
uint8_t len ) {


    lqer_adv_hdr* lqer_hdr = (lqer_adv_hdr*)(p_msg->data);
    lqer_adv_hdr* msg_lqer_hdr =(lqer_adv_hdr*)(p_lqer_msg_->data);
    uint8_t i;

    lqer_adv_hdr* new_ADV =(lqer_adv_hdr*)(p_lqer_msg_->data);

    dbg("GRAPE_DBG", "%s\t ADV: RecievedADV dst: \n", sim_time_string());
       msg_lqer_hdr->src = lqer_hdr->src;
       msg_lqer_hdr->hop = lqer_hdr->hop;


        new_ADV->src = msg_lqer_hdr->src;

        new_ADV->hop = msg_lqer_hdr->hop;

        newADV= (message_t*)(&new_ADV);
        call PacketAcknowledgements.requestAck( newADV );
        call SendPacket.send( AM_BROADCAST_ADDR, newADV, call
Packet.payloadLength(newADV) );


    return p_msg;


}


 command error_t AMSend.cancel[am_id_t id](message_t* msg) {
    return call SendPacket.cancel(msg);
  }


  command uint8_t AMSend.maxPayloadLength[am_id_t id]() {
    return call Packet.maxPayloadLength();
  }


  command void* AMSend.getPayload[am_id_t id](message_t* m, uint8_t len) {
    return call Packet.getPayload(m, 0);
  }



  default event void AMSend.sendDone[uint8_t id](message_t* msg, error_t
err) {
    return;
  }

  default event message_t* Receive.receive[am_id_t id](message_t* msg,
void* payload, uint8_t len) {
    return msg;
  }
 command error_t AMSend.send[am_id_t id](am_addr_t addr, message_t* msg,
uint8_t len)
  {


    call SendPacket.send( TOS_BCAST_ADDR , msg, call
Packet.payloadLength(msg) );

    return SUCCESS;

  }
  event void SendPacket.sendDone(message_t* p_msg, error_t e) {

    dbg("GRAPE_DBG", "%s\t ADV: SendDone\n", sim_time_string());

        if( p_msg== newADV)
         busy=FALSE;




 }


}





On Sun, Jun 3, 2012 at 3:22 PM, Ali Saoud <alih...@gmail.com> wrote:

> Hello,
>
> I have a problem receiving a message sent periodically, There is no
> receive DBG statement apearing here is the code, I would really appreciate
> it if someone would help me find out why this is happening:
>
> includes lqer;
>
>
> module lqer_M{
>  provides {
>            interface SplitControl;
>            interface AMSend[am_id_t id];
>            interface Receive[uint8_t id];
>
>        };
>
>     uses {
>         interface SplitControl as AMControl;
>
>         interface Timer<TMilli> as LQERTimer;
>
>
>         interface Random;
>         interface AMPacket;
>         interface AMSend as SendPacket;
>         interface Receive as ReceivePacket;
>         interface PacketAcknowledgements;
>         interface Packet;
>
>     }
> }
> implementation{
>
>         message_t lqer_msg_;
>         message_t* p_lqer_msg_;
>         lqer_table l_table[LQER_FT_SIZE];
>
>         node_info info;
>         uint8_t max=0, Pos=0;
>         message_t* newADV;
>         bool busy = FALSE;
>
>     command error_t SplitControl.start() {
>        int i,j;
>        p_lqer_msg_ = &lqer_msg_;
>        info.hop=1000;
>        for(i=0; i<16; i++){
>         info.m[i]=1;
>     }
>
>     for(i = 0; i< LQER_FT_SIZE; i++) {
>              l_table[i].nid = INVALID_NODE_ID;
>           l_table[i].hop  = 1000;
>         for (j=0; j<16; j++)
>         {
>             l_table[i].m[j]=1;
>
>         }
>         }
>
>         call AMControl.start();
>         return SUCCESS;
>     }
>     command error_t SplitControl.stop() {
>         call AMControl.stop();
>         return SUCCESS;
>     }
>
>   event void AMControl.startDone( error_t e ) {
>     if ( e == SUCCESS ) {
>       call LQERTimer.startPeriodic( LQER_DEFAULT_PERIOD );
>       signal SplitControl.startDone(e);
>     } else {
>       call AMControl.start();
>     }
>   }
>
>   event void AMControl.stopDone(error_t e){
>     call LQERTimer.stop();
>     signal SplitControl.stopDone(e);
>   }
>
>
> event void LQERTimer.fired() {
>         message_t* lqer_adv_msg;
>
>         lqer_adv_hdr* new_ADV=(lqer_adv_hdr*)(lqer_adv_msg->data);
>         am_addr_t me = call AMPacket.address();
>
>
>
>
>         if (me==0001){
>             new_ADV->src = me;
>
>             new_ADV->hop = 0;
>
>             newADV= (message_t*)(&new_ADV);
>
>             dbg("GRAPE_DBG", "%s\t LQER: Sink address: %d\n",
> sim_time_string(), me);
>                   call PacketAcknowledgements.requestAck(newADV);
>             call SendPacket.send( AM_BROADCAST_ADDR, newADV, call
> Packet.payloadLength(newADV) );
>
>         }
>
>
>   }
>
>
>
>
>
>
>
>
>
> void shiftTable(){
> uint8_t i,j;
>     for(i = LQER_FT_SIZE; i> 0; i--) {
>              l_table[i].nid = l_table[i-1].nid;
>         l_table[i].hop = l_table[i-1].hop;
>         for(j=0; j<16; j++)
>         {
>             l_table[i].m[j] = l_table[i-1].m[j];
>         }
>         }
> }
>
>
>
> event message_t* ReceivePacket.receive( message_t* p_msg, void* payload,
> uint8_t len ) {
>
>
>     lqer_adv_hdr* lqer_hdr = (lqer_adv_hdr*)(p_msg->data);
>     lqer_adv_hdr* msg_lqer_hdr =(lqer_adv_hdr*)(p_lqer_msg_->data);
>     uint8_t i;
>
>     lqer_adv_hdr* new_ADV =(lqer_adv_hdr*)(p_lqer_msg_->data);
>
>     dbg("GRAPE_DBG", "%s\t ADV: RecievedADV dst: \n", sim_time_string());
>        msg_lqer_hdr->src = lqer_hdr->src;
>        msg_lqer_hdr->hop = lqer_hdr->hop;
>
>
>     for (i=0;i<16;i++)
>     {
>      msg_lqer_hdr->m[i] = lqer_hdr->m[i];
>     }
>     dbg("GRAPE_DBG", "%s\t ADV: RecievedADV 2 dst: \n", sim_time_string());
>     if(msg_lqer_hdr->hop+1 < info.hop)
>     {
>         info.hop= msg_lqer_hdr->hop+1;
>
>         shiftTable();
>         l_table[1].nid = msg_lqer_hdr->src ;
>         l_table[1].hop= msg_lqer_hdr->hop;
>         for(i=0; i<16; i++)
>         {
>             l_table[1].m[i]= msg_lqer_hdr->m[i];
>         }
>
>         dbg("GRAPE_DBG", "%s\t ADV: RecievedADV 3 dst: \n",
> sim_time_string());
>         new_ADV->src = msg_lqer_hdr->src;
>
>         new_ADV->hop = msg_lqer_hdr->hop;
>
>         newADV= (message_t*)(&new_ADV);
>         call PacketAcknowledgements.requestAck( newADV );
>         call SendADV.send( AM_BROADCAST_ADDR, newADV, call
> Packet.payloadLength(newADV) );
>
>
>     }
>     else if (msg_lqer_hdr->hop+1 == info.hop)
>     {
>         shiftTable();
>         l_table[1].nid= msg_lqer_hdr->src;
>         l_table[1].hop= msg_lqer_hdr->hop;
>         for(i=0; i<16; i++)
>         l_table[1].m[i]=msg_lqer_hdr->m[i];
>         dbg("GRAPE_DBG", "%s\t ADV: RecievedADV 3-2 dst: \n",
> sim_time_string());
>
>     }
>     dbg("GRAPE_DBG", "%s\t ADV: Recieved 4 dst: \n", sim_time_string());
>
>     return p_msg;
>
>
> }
>
>
>
>
>
>
>  command error_t AMSend.cancel[am_id_t id](message_t* msg) {
>     return call SendPacket.cancel(msg);
>   }
>
>
>   command uint8_t AMSend.maxPayloadLength[am_id_t id]() {
>     return call Packet.maxPayloadLength();
>   }
>
>
>   command void* AMSend.getPayload[am_id_t id](message_t* m, uint8_t len) {
>     return call Packet.getPayload(m, 0);
>   }
>
>   default event void AMSend.sendDone[uint8_t id](message_t* msg, error_t
> err) {
>     return;
>   }
>
>   default event message_t* Receive.receive[am_id_t id](message_t* msg,
> void* payload, uint8_t len) {
>     return msg;
>   }
>  command error_t AMSend.send[am_id_t id](am_addr_t addr, message_t* msg,
> uint8_t len)
>   {
>
>     return SUCCESS;
>
>   }
>   event void SendPacket.sendDone(message_t* p_msg, error_t e) {
>
>     dbg("GRAPE_DBG", "%s\t ADV: SendDone\n", sim_time_string());
>
>         if( p_msg== newADV)
>          busy=FALSE;
>
>
>
>
>  }
>
>
> }
>
>
>
>
>
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to