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);
}

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);
}
}

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?
***