zzuzpb / tinyos-main

Automatically exported from code.google.com/p/tinyos-main
0 stars 0 forks source link

CC2420 bug: initial ACK transmission power not set correctly #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Set power level to lower than maximum power
2. Use SACK/HACK
3. Let one telosb node sending packets, requesting an ack and printing the rssi 
of the ack
4. Let the other node receiving without sending anything and printing the rssi 
value of the received packet as well
5. Compare the rssi values of the ack and received packet

Hello,
I think I have found a bug in the cc2420 stack concerning the  transmission 
power of the acknowledgements.
I am using the svn revision 5304 on the cc2420 folder.

In my setup a telosb node is continuously sending packets, requests an ack and 
prints the rssi value of the ack. Another node is receiving and prints out the 
rssi value of the received packet.

The problem occurs when I reduce the transmission power by setting  
CFLAGS += -DCC2420_DEF_RFPOWER=1. The rssi of the acknowledgement  
equals the transmission power of power level 31 and not the rssi of  
the received packet.
It seems that the initial transmission power for the receiving node  
was not set to DCC2420_DEF_RFPOWER. It looks like this should be done by 
CC2420Control.Init. But the m_power_level is never used as well as synchronized 
with the cc2420 chip.
For the maximum transmission power the rssi values of the ack and  
received packet equals. The behavior occurs for SACK and HACK.

I found out that I can fix the problem by the transmission of one  
packet on the receiving node. It seems like after the SoftwareInit the radio 
chip resets once more or the CC2420Config.sync() will never be called to commit 
changes to TXCTRL.

I think the problem could be fixed by setting the TXCTRL in the CC2420ConfigP 
in CC2420Power.startOscillator().

Best regards,
Tobias

Some code snippets of my test application:

   event void RadioControl.startDone(error_t err){
     if (err == SUCCESS){
       call CC2420Config.setAutoAck(1,0);   //enable auto-sw-acks
       call CC2420Config.sync();
     }
     else {
       call RadioControl.start();
     }
   }

   event void CC2420Config.syncDone(error_t error){
     if (error == SUCCESS){
       call Timer1.startPeriodic(600);
     }
     else{
       call CC2420Config.setAutoAck(1,0);   //enable auto-sw-acks
       call CC2420Config.sync();
     }
   }

   event void Timer1.fired(){
     am_addr_t dest = 1;
     test_pkt_t* pkt = call  
RadioSend.getPayload(&radio_pkt,sizeof(test_pkt_t));
     seqno++;
     pkt->seqno = seqno;
     call Acks.requestAck(&radio_pkt);
     call RadioSend.send(dest,&radio_pkt,sizeof(test_pkt_t));
   }

   event void RadioSend.sendDone(message_t* msg, error_t err){
     if (msg==&radio_pkt && err==SUCCESS){
       if (call Acks.wasAcked(msg)){
        printf("ACK received seqno:%u rssi:%02d\n \n",seqno, call  
CC2420Packet.getRssi(msg)-45);
       }
       else {
        printf("Packet LOST seqno:%u \n",seqno);
       }
     }
     printfflush();
   }

   event message_t* RadioReceive.receive(message_t* msg, void*  
payload, uint8_t len){
     test_pkt_t* pkt = payload;
     printf("RECEIVED seqno:%u rssi:%02d\n \n",pkt->seqno, call CC2420Packet.getRssi(msg)-45);
     printfflush();
     return msg;
   }

Original issue reported on code.google.com by tobiasja...@googlemail.com on 18 Mar 2011 at 12:00

GoogleCodeExporter commented 8 years ago
I have checked in the fix you suggested and tested it successfully. Can you 
please check that it works properly for you too now?

Original comment by philip.l...@gmail.com on 22 Mar 2011 at 8:50

GoogleCodeExporter commented 8 years ago

Original comment by philip.l...@gmail.com on 17 Apr 2011 at 12:34

GoogleCodeExporter commented 8 years ago
what is the interface used here
i used CC2420Packet to get Rssi value but it always generate erreur [interface 
CC2420Packet not found] i don't know why?

<<int_8 Rssi=call CC220Packet.getRssi(msg)>> 

Original comment by kamal.sa...@gmail.com on 26 Feb 2015 at 2:32