Hello everybody

Thank Philip for your answer.

I have problems yet.

I removed the atomic sections. I method to debug de program: The program has 
three variables (call, function, sendDone). When the programm call the function 
it pluses one to call variable. The same for function and sendDone in the 
function and sendDone event. Before to start the new iteration with the sensors 
the node sends a debub message with the three variables. The two motes works 
with a sample rate of two minutes and with a delay of one minute between them 
(minute 1: debug message node 1, data sensor0 and data sensor1; minute 2: debug 
message nodo 2, data sensor0 and data sensor1 ...).

I know that the protocol with the sensor runs ok because the read of data from 
sensor1 starts five seconds after sendDone event message data of sensor0 and 
sometimes I receive the data from sensor1 and not from sensor0.

Ten hours after to start the program the values of three variables are the same 
from the two motes, then it appears that the send of messages runs perfect. 
Maybe I have the problem with the Java programm because when the programm gets 
an message it writes something in a file to can know  a lot hours later if all 
is ok. I put the code below.

Thanks in advance.

A greeting, Juan Antonio.

  public void messageReceived(int to, Message message) 
  {
    Date hoy = new Date();

    if (message.amType() == 12)    // Message with data
    {
       System.out.println("\n");
       MensajeDatos msg = (MensajeDatos)message;
       System.out.println( hoy );
       System.out.println("El nodo " + msg.get_nodeid() + " sensor " + 
msg.get_sensor() + " " + " longitud " + msg.get_longitud() + " ");
       for (int i = 0;i < 36;i++)
       {
           System.out.print((char)msg.getElement_datos(i));
       }
       try
       { 
          FileWriter fichero = new FileWriter("prueba.txt",true);
          PrintWriter pw = new PrintWriter(fichero);
          pw.println("\n");
          pw.println(hoy.toString() + " nodo " + msg.get_nodeid() + " sensor " 
+ msg.get_sensor()); 
          pw.close(); 
       } 
       catch (Exception e)
       { 
          e.printStackTrace();
       } 
    }
    
    if (message.amType() == 13)    // Debug messages
    {
          MensajeDato msg = (MensajeDato)message;
          System.out.println("\n");
          System.out.println( hoy );
          System.out.println("El nodo " + msg.get_nodeid() + " llamadas " + 
msg.get_llamadas() + " entradas " + msg.get_entradas() + " enviados " +         
msg.get_enviados());
          try
          { 
              FileWriter fichero = new FileWriter("prueba.txt",true);
              PrintWriter pw = new PrintWriter(fichero);
              pw.println("\n");
              pw.print("El nodo " + msg.get_nodeid() + " llamadas " + 
msg.get_llamadas() + " entradas " + msg.get_entradas() + " enviados " +         
                msg.get_enviados()); 
              pw.close(); 
          } 
          catch (Exception e)
          { 
              e.printStackTrace();
          } 
    }
  ...




----- Original Message ----- 
From: "Philip Levis" <[EMAIL PROTECTED]>
To: "Juan Antonio López Riquelme" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Wednesday, April 02, 2008 12:34 AM
Subject: Re: [Tinyos-help] Problem sending messages with 39 bytes of payload.


> 
> On Apr 1, 2008, at 2:37 PM, Juan Antonio López Riquelme wrote:
>> Hello
>>
>> I am working with 2.0.2 release of Tinyos. I have two remote nodes  
>> and one with BaseStation application. By all programs I have  
>> configured the payload to 39 bytes with the line "#define  
>> TOSH_DATA_LENGTH 39". To send messages I have a function and one  
>> task. When I have all data from one sensor I call the function  
>> FunctionSendData, later a delay of 5 seconds before to get the data  
>> from the other sensor and finally the program calls the function  
>> again.
>>
>> The computer uses the program TestSerial with some modications from  
>> the tutorials.
>>
>> The nodes sends two messages every minute. Sometimes I have observed  
>> that in Cygwin does not appear the message from one sensor (not  
>> always the same).
>>
>> I would like to know if I can have problems with 39 bytes of payload  
>> because the default value is 28 or another idea about what is the  
>> problem.
>>
>> Thanks, Juan Antonio.
>>
>> task void FunctionSendDataTask(){FunctionSendData();}
>>
>> void FunctionSendData()
>>
>> {
>>
>>   uint8_t j;
>>
>>   uint8_t len;
>>
>>   atomic if (!enviarDatosBusy)
>>
>>   {
>>
>>           MensajeDatos* btrpkt = (MensajeDatos*)(call  
>> Packet.getPayload(&PaqueteDatos, NULL));
>>
>>
>>           len = recibidos - 5;
>>
>>           btrpkt->nodeid = TOS_NODE_ID;
>>
>>
>>           if (sensor0) btrpkt->sensor = 0;
>>
>>           else btrpkt->sensor = 1;
>>
>>
>>           btrpkt->longitud = len;
>>
>>           for (j = 0; j < 36; j++)
>>
>>           {
>>
>>                   if (!leerDatos) btrpkt->datos[j] = debug[j];
>>
>>                   else btrpkt->datos[j] = debug[j+5];
>>
>>           }
>>
>>           if (call EnviarDatos.send(0, &PaqueteDatos,  
>> sizeof(MensajeDatos)) == SUCCESS)
>>
>>           {
>>
>>                   enviarDatosBusy = TRUE;
>>
>>           }
>>
>>           else post FunctionSendDataTask();
>>
>>   }
>>
>>   else post FunctionSendDataTask();
>>
>> }
> 
> I'm not sure if this is the problem, but you should most definitely  
> not be calling send from within an atomic section. Please take a look  
> at the TinyOS programming manual.
> 
> Phil
> 
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to