Go Down

Topic: How Can I merge char variable (Read 2 times) previous topic - next topic

Sembazuru


Quote
Apparently we have to manager the string, but I do not know exactely how to delimeter the time

You mean that you don't know how to parse the time. You should start with printing the data as obtained from the GPS. Modify the library if needed.

If the date/time stamp in the GPS data looks like 20130617062400.345, then taking 4 characters for the year, 2 for the month, 2 for the day, 2 for the hour (GMT), 2 for the minute, and two for the second seems reasonable. The millisecond portion follows the decimal point, but may be more than you need.


And, because this is a GPS generating the time, it would be UTC not your local time (unless you happen to be in GMT and either don't use summer time, or it is winter). Because timezones are defined politically, not necessarily geographically, it would take a huge database (probably larger than an UNO could hold) to be able to accurately figure out the timezone correction based on the Lat/Lon/date for every point on the Earth...

PaulS

Quote
Apparently we have to manager the string, but I do not know exactely how to delimeter the time

You mean that you don't know how to parse the time. You should start with printing the data as obtained from the GPS. Modify the library if needed.

If the date/time stamp in the GPS data looks like 20130617062400.345, then taking 4 characters for the year, 2 for the month, 2 for the day, 2 for the hour (GMT), 2 for the minute, and two for the second seems reasonable. The millisecond portion follows the decimal point, but may be more than you need.

pierrot10

#21
Jun 17, 2013, 05:21 pm Last Edit: Jun 17, 2013, 05:52 pm by pierrot10 Reason: 1
Dear Paul, It a bit hard becaue it would be really a lot of reading.

The date is generated by a GPS library.

I declare my variabel like this:
Code: [Select]

#include "gps.h"
GPSGSM gps;

// GPS
char coords[150];
char lon[15];
char lat[15];
char alt[15];
char time[20];
char vel[15];


and here is a function to get the coords
Code: [Select]

void getGPSfix(){
       Serial.println(F(""));
      Serial.println(F("GPS FIX"));
      Serial.println(F("--------------"));
     
        delay(5000);
//Get data from GPS

gps.getPar(lon,lat,alt,time,vel);

       
Serial.print(F("Long :"));
        Serial.println(lon);
        Serial.print(F("Lat :"));
Serial.println(lat);
        Serial.print(F("Alt :"));
Serial.println(alt);
        Serial.print(F("Time :"));
Serial.println(time); // This retunr me something like 20130617062400.345
        Serial.print(F("Vel :"));
Serial.println(vel);

      Serial.println(F(""));
}


Apparently we have to manager the string, but I do not know exactely how to delimeter the time

@Paul,
Is enoguth for you?

In the gps.cpp file, there is that fonction
Code: [Select]

char GPSGSM::getPar(char *str_long, char *str_lat, char *str_alt, char *str_time, char *str_speed)
{
char ret_val=0;
char *p_char;
char *p_char1;
gsm.SimpleWriteln("AT+CGPSINF=0");
gsm.WaitResp(5000, 100, "OK");
if(gsm.IsStringReceived("OK"))
ret_val=1;

//longitude
p_char = strchr((char *)(gsm.comm_buf),',');
p_char1 = p_char+1;  //we are on the first char of longitude
p_char = strchr((char *)(p_char1), ',');
if (p_char != NULL) {
          *p_char = 0;
    }
strcpy(str_long, (char *)(p_char1));

// latitude
p_char++;
p_char1 = strchr((char *)(p_char), ',');
if (p_char1 != NULL) {
          *p_char1 = 0;
    }
strcpy(str_lat, (char *)(p_char));

// altitude
p_char1++;
p_char = strchr((char *)(p_char1), ',');
if (p_char != NULL) {
          *p_char = 0;
    }
strcpy(str_alt, (char *)(p_char1));

// UTC time
p_char++;
p_char1 = strchr((char *)(p_char), ',');
if (p_char1 != NULL) {
          *p_char1 = 0;
    }
strcpy(str_time, (char *)(p_char));

// TTFF
p_char1++;
p_char = strchr((char *)(p_char1), ',');
if (p_char != NULL) {
          *p_char = 0;
    }

// num
p_char++;
p_char1 = strchr((char *)(p_char), ',');
if (p_char1 != NULL) {
          *p_char1 = 0;
    }

// speed
p_char1++;
p_char = strchr((char *)(p_char1), ',');
if (p_char != NULL) {
          *p_char = 0;
    }
strcpy(str_speed, (char *)(p_char1));

return ret_val;
}

There is this part, as well.
Code: [Select]

// UTC time
p_char++;
p_char1 = strchr((char *)(p_char), ',');
if (p_char1 != NULL) {
          *p_char1 = 0;
    }
strcpy(str_time, (char *)(p_char));

I hope, I provided you enouhg information
Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

PaulS

Still with the snippets, eh? When you post ALL of your code, we can help.

wildbill

Quote
So to be sincerly, I do not know what it's exacetly this 062400.097. I supposed it's the time, but I do not think that at 6am, I was working....

It looks like the time as you surmised, with a decimal component to the seconds. As to it not being the time of day you expect, does it make sense if it were Zulu time (GMT) ?

Go Up