Use the fact that a  message is sent if the sendone is executed that is in
the sendone you launch the send of second message

Another method  is to,use a buffer where you memorize message to be sent and
in the send down you remove msg from buffer as it is sent.

 

Please send directly to the mailing list

 

De : zainab noorbhaiwala [mailto:[email protected]] 
Envoyé : vendredi 30 juillet 2010 13:08
À : chikh omar
Objet : Problem in sending packets one after the other over serial port

 

Hi Omar,

I had mailed earlier regarding how to send over mote and PC simultaneously.
I am using what you had suggested and the program was running fine. I am a
newbie in tinyos and am stuck in this problem :(

 In my apllication a timer is fired evry 2 seconds and i call solarcell read
and when that is done i send the info to the PC as in the following code.

 I am sending a mote_to_PC_packet to the PC with different fields one after
the other like in the following code. So the first one 'battery_pkt' is sent
successfully but for the next one it prints locked... I assume that the
serial port is busy..


If i wait after sending the first one(using while and a counter).. it still
says locked... and if i put a condition that till it is locked send it it
goes in infinite loop...

And im using the same AMsend.senddone.

I hope i could explain my problem correctly to you...

Could you tell me what im doing wrong or what is the correct way of doing
this??

Looking forward to your reply.
Thanks so much!
Zainab

 


event void SolarCell.readDone( error_t result, uint16_t val ) {
    if (result == SUCCESS) {

    /*sending to PC*/
    if (locked) {
    }
    else {

      mote_to_PC_packet_t* rcm = (mote_to_PC_packet_t*)call
PacketSerial.getPayload(&packet, sizeof(mote_to_PC_packet_t ));
     
      locked = FALSE;
      rcm->from = TOS_NODE_ID;
      rcm->time = call Timer0.getNow();
      rcm->report_type = 1;
-------------------------------- this is battery pkt
      rcm->mote_status = 200;
      rcm->maximum_possible_level = 100; 
      rcm->current_level = battery_val;
   

         if (call AMSendSerial.send(0, &packet, sizeof(mote_to_PC_packet_t
)) == SUCCESS) {
         locked = TRUE;
         printf("sent battery pkt");
         }
         else {
       
          }
     }

     if (locked) { printf("locked");}
        else{
            
            mote_to_PC_packet_t* harvesting = (mote_to_PC_packet_t*)call
PacketSerial.getPayload(&

packet, sizeof(mote_to_PC_packet_t ));


            locked = FALSE;
            harvesting->from = TOS_NODE_ID;
            harvesting->time = call Timer0.getNow();
            harvesting->report_type =
2;----------------------------------------------------htis is harvesting pkt
            harvesting->mote_status = 200;
            harvesting->current_level=solar_val;
  
            if (call AMSendSerial.send(0, &packet,
sizeof(mote_to_PC_packet_t )) == SUCCESS) {
            locked = TRUE;
            printf("sent harvest pkt");
            }
            else {
            }
        }
}


/*sending done over serial port*/
event void AMSendSerial.sendDone(message_t* bufPtr, error_t error) { 
locked = FALSE;
  }




 

 

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to