Meshlium converts from upper to lower case

All related to the Kernel, packages system and libraries
Post Reply
FunWithLibelium
Posts: 18
Joined: Wed Sep 14, 2011 2:01 am

Meshlium converts from upper to lower case

Post by FunWithLibelium » Fri Oct 14, 2011 6:25 am

***

With the following code in our DigiMesh Waspmotes

Code: Select all

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: Select all

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?


***

libelium-dev
Posts: 23952
Joined: Mon Sep 28, 2009 12:06 pm

Re: Meshlium converts from upper to lower case

Post by libelium-dev » Fri Oct 14, 2011 9:09 am

The quickest solution to work would be to change "volts" to "volts", however we will review our code to make sure everything works well.

FunWithLibelium
Posts: 18
Joined: Wed Sep 14, 2011 2:01 am

Re: Meshlium converts from upper to lower case

Post by FunWithLibelium » Fri Oct 14, 2011 3:14 pm

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.

dirkdepauw
Posts: 13
Joined: Wed Oct 05, 2011 9:31 am
Location: Belgium
Contact:

Re: Meshlium converts from upper to lower case

Post by dirkdepauw » Wed Nov 30, 2011 12:09 pm

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?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest