Try reducing the scope of the atomic section. It's way huge now.
atomic shuts off interrupts so you may be missing important things.
It should be used very sparingly.
MS



Jordi Pérez wrote:
> Hi,
> 
> I've one mote which send packets in broadcast. On the other side I've 
> three motes that receive the packets from first mote. One mote of them 
> is connected whit the PC (mote B). I've made a programm that show the 
> data content of the received packets  in mote B.
> Maybe mote B receives packets whit errors in data content, then I send a 
> message to the others receiver motes and they send mote B the received 
> packet again. (I guess that packets of this motes can have others errors 
> in data content).
> Now I've three packets in mote B. I can show the data content of the 
> three packets in my application. I want to compare the data content of 
> this three received packets to create a good data content and I only 
> show that in my application.
> 
> I don't know if this code is OK, because it doesn't work very well. The 
> base station (mote B) shows packets illogical. Maybe, it's a problem of 
> atomic, but I am not sure. I think that when I do post sendserial() some 
> variables change the data content before.
> 
> event message_t *Receive.receive(message_t *msg, void *payload, uint8_t 
> len)
>     {
>         rssi = call CC2420Packet.getRssi(msg);
>         sourcer=call AMPacket.source(msg);
>         call Leds.led0Toggle();
>    
>         if (len==sizeof(PacketLinkMsg))
>         {
>             atomic {
>                     strcpy(datapc, LinkMsg->datatx);
>                 if(sourcer==1){                   
>                     strcpy(pktOut, datapc); // Paquete 1 es el paquete 
> que recibe el receptor
>                     LinkMsg = (PacketLinkMsg*) payload;
>                     //call Leds.led0Toggle();
>                     source = call AMPacket.source(msg);
>                     Transmitted[source] = LinkMsg->count;   
>                     Received[source]++;
>                     recibido=FALSE;
>                     post sendSerialMsg();
>                     // if you lost = on
>                     ((PacketSynchroMsg*) call radioSend.getPayload(&myMsg))-
>  >retries=41;
>                     ((PacketSynchroMsg*) call 
> radioSend.getPayload(&myMsg))->flag=Transmitted[source];
>                     radioDest=AM_BROADCAST_ADDR;
>                     post sendToRadio();
>                   
>                    
>                 }
>            
>            
>                    
>                     if (x==N_MOTAS){               
>                     x=0;
>                     }                   
>                     for(y=0;y<14;y++){
>                     matriz[x][y]=datapc[y];
>                     }
>                     if(sourcer!=1){                   
>                     LinkMsg = (PacketLinkMsg*) payload;
>                     source = call AMPacket.source(msg);
>                     Transmitted[source] = LinkMsg->count;   
>                     Received[source]++;
>                     }
>                     matriz[x][y]=LinkMsg->count;
>                     y++;
>                     matriz[x][y]=source;
>                     motas2=N_MOTAS;
>                     x++;
>                     if (x==motas2){
>      
>                         for (z=0;z<=motas;z++){
>                             sonia=matriz[z][15];
>                             resultado= resultado * sonia;
>                          }        
>                         while (motas2>0){                           
>                             resultado2 = resultado2 * motas2;
>                             motas2--;
>                         }   
>                            
>                         if (resultado2 == resultado){
>                         call Leds.led1Toggle();
>                    
>                             for(j=0;j<14;j++){
>                                 for(i=0;i<=motas;i++){
>                                     do{
>                                     if(matriz[i][j]==matriz[cont][j]){
>                                         similar++;
>                                     }
>                                     cont++;   
>                                     }while(cont<=motas);
>                                     coincidencias[i]=similar;
>                                     cont=0;
>                                     similar=0;
>                                 }                           
>                    
>                                 mayor=coincidencias[0];   
>                                 pos=0;       
>                                 for(i=1;i<=motas;i++){
>                                     if(coincidencias[i]>mayor){
>                                     mayor=coincidencias[i];
>                                     pos=i;
>                                     }
>                                 pktOut[j]=matriz[pos][j];
>                                
>                                 }
>                             }
>                        
>                    
>                         recibido=TRUE;                       
>                         call Leds.led2Toggle();
>                         post sendSerialMsg();
>                        
>                        
>                         }
>                        
> 
>    
>                         }
>             }//atomic
>         }
>        
> 
> Can anyone help me please?
> 
> Thanks in advanced,
> 
> Jordi
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

-- 
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew

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

Reply via email to