Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: Meshlium converts from upper to lower case
PostPosted: Fri Oct 14, 2011 7:25 am 

Joined: Wed Sep 14, 2011 3:01 am
Posts: 18
***

With the following code in our DigiMesh Waspmotes
Code:
void loop(){

  RawValue = analogRead(ANALOG4);  // add analog read
  Voltage = floatmap (RawValue, 0, 1024, 0, 3.3);  // convert to voltage
  Utils.float2String (Voltage, aux2, 7);
  sprintf(aux,"Volts: %s!!!%c%c", aux2, '\r', '\n');
  XBee.println (aux);
 
  paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
  paq_sent->mode=UNICAST; // was BROADCAST
  paq_sent->MY_known=0;
  paq_sent->packetID=0x52;
  paq_sent->opt=0;
  xbeeDM.hops=0;
  xbeeDM.setOriginParams(paq_sent,MAC_TYPE);
  xbeeDM.setDestinationParams(paq_sent, direccion, aux, MAC_TYPE, DATA_ABSOLUTE);
  xbeeDM.sendXBee(paq_sent);
  free(paq_sent);
  paq_sent = NULL;
 
  delay(1000);
}


we see this output on the serial monitor

Image

Using this modified storer on Meshlium

Code:
void getFrame() {
   char c;
   int j = 0;

   //Get frame char by char untill '\n'
   while (1)
   {
      read(sd,&c,1);
      if((c=='\0') || (c=='\r'))
      {
         //Strange chars will be modified
         aux[j]='_';
      }
      else
      {
         aux[j]=c;
         j++;
      }

      if((c=='\n') || (j==(MAX-1)))
      {
         aux[j]='\0';
    fprintf (stderr, "aux is: %s\n", aux);
         break;
      }
   }
}


/*
 * parseFrame function:
 *  - take the string that returns getFrame function
 *  - separate each values from each frame into diferents variables
 *  - example frame: [HEADER] -mac:0013a20040307f9c -x:27,y:23,z:1023 -temp:28 -bat:97%
 * THIS FUNTION MAY BE CHANGED BY THE USER
 */
void parseFrame(struct xbee_frame_test *p_frame) {
   
   int error = 0;
   char *aux2;
   aux2 = strstr(aux, "Volts: "); // was strpbrk
   if (aux2 == NULL) error = 1;
   fprintf (stderr, "error is %d, aux2 is %s\n", error, aux2);

 

   //Get voltage value
   if (!error){
        strncpy(p_frame->temp, aux2, 30); 
        p_frame->temp[17] = '\0';
   }

     
   if (error){
     fprintf(stderr, "ERROR - Unable to parse received frame: %s\n",aux);
     exit(-1);
   }
}


we see this on our puTTy terminal

Image


Somewhere between the Waspmote send and the Storer read, the capital "V" is being changed to a lower case "v" and causing the Storer (parseFrame) to fail. Why?


***


Top
 Profile  
 
 Post subject: Re: Meshlium converts from upper to lower case
PostPosted: Fri Oct 14, 2011 10:09 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 12142
The quickest solution to work would be to change "volts" to "volts", however we will review our code to make sure everything works well.


Top
 Profile  
 
 Post subject: Re: Meshlium converts from upper to lower case
PostPosted: Fri Oct 14, 2011 4:14 pm 

Joined: Wed Sep 14, 2011 3:01 am
Posts: 18
Thanks.

I've already implemented the workaround. This particular case is not serious, but I'm sure neither of us wants lower level software altering packets automagically!

Please post here when it's resolved.


Top
 Profile  
 
 Post subject: Re: Meshlium converts from upper to lower case
PostPosted: Wed Nov 30, 2011 1:09 pm 

Joined: Wed Oct 05, 2011 10:31 am
Posts: 12
Location: Belgium
I'm having exactly the same problem with my Zigbee Waspmotes. All strings from the Meshlium serial port are lower case (although the data on the Waspmote is upper case). What could be causing this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use