Show Posts
Pages: 1 ... 9 10 [11] 12 13 ... 25
151  Using Arduino / Programming Questions / Re: How Can I merge char variable on: June 17, 2013, 10:57:49 am
by the bay, what it's the limite of a buffer

Code:
coords[100]

I change it to 300 and nothing was working...
152  Using Arduino / Programming Questions / Re: How Can I merge char variable on: June 17, 2013, 10:21:58 am
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:
#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:
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:
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:
// 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
153  Using Arduino / Programming Questions / Re: How Can I merge char variable on: June 17, 2013, 09:49:42 am
Dear Tom Carpenter and Paul

Thank for your answer. Tom I am going to try your proposition and I count the amout of caracters but apparently it should be fine, because here are declare the char variable
Code:
char coords[100];
char lon[15];
char lat[15];
char alt[15];
char time[20];
char vel[15];
char msg1[5];
char msg2[5];

@Paul
When I publish that post, I have not niticed the here that number 20130609062400.097
there is year, month etc.
So at the final, I would like to have this in that formatz
Quote
2013-06-09 06:24:00

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....  smiley-confuse

but in order to make sure, I ma going to increate coords to 150
154  International / Français / Re: Comment convertit une date/time on: June 17, 2013, 09:31:12 am
Ben oui, c'est ce que j'avais pensé, mais 6h du mat, c'est comme tot pour bosser. Mais si l'heure est en UTC, c'est rare qu' 8h je bosse etc....
Mais c'est peut etre bien, ca je ne me souviens plus quand j'ai lancé ce code
155  International / Français / Re: Comment convertit une dat/time on: June 17, 2013, 09:20:01 am
Mais en fait, je suis bête, la date est inscrite dans ce chiffre

20130609062400.097

La question est comment ajouter des - afin formater cette chaine de caratere de la sorte 2013-06-09 062400.097

Par contre je n'ai aucune idée sur ce c'est que le : 062400.097. J'imagine bien que ca doit être l'heure, mais.... avez vous une diée?

MERCI
156  International / Français / Re: Comment convertit une dat/time on: June 16, 2013, 02:20:42 pm
Je n'arrive toujours pas lire ce formatz et le comvertir

Le Time est tiré de cette fonction
Code:
gps.getPar(lon,lat,alt,time,vel);
Code:
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;
}
157  International / Français / Re: Comment convertit une dat/time on: June 16, 2013, 05:11:00 am
Ben je ne sais pas trop quoi donner en plus

Code:
#include "gps.h"
GPSGSM gps;

 #ifdef DEBUG
          Serial.println(F(""));
          Serial.println(F("Sending GPS coords to the remote server"));
          Serial.println(F("---------------------------------------"));
          stat=gps.getStat();
          if(stat==1)
             Serial.println(F("NOT FIXED"));
          else if(stat==0)
             Serial.println(F("GPS OFF"));
          else if(stat==2)
             Serial.println(F("2D FIXED"));
          else if(stat==3)
     Serial.println(F("3D FIXED"));
        #endif
       
      delay(5000);
      //Get data from GPS
      gps.getPar(lon,lat,alt,time,vel);
     
      strcpy (coords,"lat=");
      strcat (coords,lat);
     
      strcat (coords,"&long=");
      strcat (coords,lon);
     
      strcat (coords,"&alt=");
      strcat (coords,alt);
     
      strcat (coords,"&vel=");
      strcat (coords,vel);
     
      strcat (coords,"&time=");
      strcat (coords,time);
     
     
      #ifdef DEBUG
        Serial.print(F("Coords to be sent : "));                               
        Serial.println(coords);
      #endif
     
      inet.httpPOST(host, port_post, path_post, coords , "Result", 1000);
      delay(10000);

J'aimerais modifier mon code ci-dessous pour que time ne soit plus un chiffre a 20 caracter, mais un format date et time comme fais la fonction.

Ca doit etre un format timeStamp et je ne sais pas convertir ca...
158  International / Français / Re: Comment puis compter la longeur d'une string on: June 16, 2013, 04:05:29 am
Hello

Ben en terme de code, je peux pas mettre plus en plus de ceci:
Code:
char inSerial[20];

 // MAKE A CALL
    if(!strcmp(inSerial,"call")){
       #ifdef DEBUG
          Serial.print(F("Starting Dialing "));
          Serial.println(number); 
        #endif
     
       
        if (inSerial.length()<5)  //To call variable 'number'    comand   c
         { 
          #ifdef DEBUG
            Serial.print(F("Dialing "));
            Serial.println(number); 
          #endif
           call.Call(number);
         }
         
         /*
         if (inStr.length()==5)  //To call number in phone book position   comand   cx where x is the SIM position
         {
             error=call.GetPhoneNumber(inStr[1],number);
             if (error!=0)
             {
               Serial.print("Calling ");
               Serial.println(number);
               call.Call(number);
             }
             else
             {
               Serial.print("No number in pos ");
               Serial.println(inStr[1]);
             }
         }
         */
    }
   
159  International / Français / Re: Comment convertit une dat/time on: June 16, 2013, 04:03:12 am
Heu c'est un SIM908 qui comprend un GSM/GPS

Code:
gps.getPar(lon,lat,alt,time,vel);
Serial.print(time) // => 20130609062400.097
160  International / Français / Comment puis compter la longeur d'une string on: June 16, 2013, 02:40:16 am
Bonjour,
quand je tape "call" dans le terminal ce code rentre en action

Code:
// MAKE A CALL
    if(!strcmp(inSerial,"call")){
       #ifdef DEBUG
          Serial.print(F("Starting Dialing "));
          Serial.println(number); 
        #endif
     
       
        if (inSerial.length()<5)  //To call variable 'number'    comand   c
         { 
          #ifdef DEBUG
            Serial.print(F("Dialing "));
            Serial.println(number); 
          #endif
           call.Call(number);
         }else{
}
Le truc c'est que j'aimerais pouvoir compter la longeur du text "call".
S'il est c'est bien call, execute un code, si c'est call1, ou call2 ou call3 etc, fait une autre partie du code

Simplement, là, ca ne marche pas j'ai un message d'erruer:
Quote
rquest from member 'length' in 'inSerial', which is of non-class type 'char[20]'
161  International / Français / Comment convertit une date/time on: June 16, 2013, 02:12:19 am
Bonjour à tous,

J'utilise un GPS et ce code me retourne les positios et date

Code:
gps.getPar(lon,lat,alt,time,vel);
La variable time me retourne ceci : 20130609062400.097

Comment puis-je convertir ceci de maniere à etre comrpis par l'oeil humain, du genre

16-06-2013 10:10:00

Merciiii
162  Using Arduino / Programming Questions / Re: How Can I merge char variable on: June 16, 2013, 01:30:22 am
Ok, I solved my problem this way
Code:
  gps.getPar(lon,lat,alt,time,vel);
     
      strcpy (coords,"lat=");
      strcat (coords,lat);
     
      strcat (coords,"&long=");
      strcat (coords,lon);
     
      strcat (coords,"&alt=");
      strcat (coords,alt);
     
      strcat (coords,"&vel=");
      strcat (coords,vel);
     
      strcat (coords,"&time=");
      strcat (coords,time);

Now I have a last question.

time diaply this : 20130609062400.097

how can I have it in a readable format?

many thank
163  Using Arduino / Programming Questions / Re: How Can I merge char variable on: June 16, 2013, 12:55:17 am
Hello All
thank for your answers and help, but I am afraid it did not solve my issue.

I am sorry if I have been not clear enough.

Here is a resume

Code:
// GPS
char coords[100];
char lon[15];
char lat[15];
char alt[15];
char time[20];
char vel[15];
char msg1[5];
char msg2[5];

This collect the GPS coords
Code:
gps.getPar(lon,lat,alt,time,vel);
Then from now, I have the longitude (lon) the latitude (lat) etc. No worries for sppeed and course, I will see it later.

I have to send the cords to a remote server and for this I use this function
Code:
inet.httpPOST(host, port_post, path_post, coords , "Result", 1000);
      delay(10000);
Coords is the char variable which must contain the value.

If I code
Code:
coords = "lat="+lat+"&long="+lon+"&alt="+alt+"&vel="+val+"&time="+time;
inet.httpPOST(host, port_post, path_post, coords , "Result", 1000);

This works fine, but now I have to replace the "10.000", "20.000" etc by the value provided by the GSP.
So I tryied this

Code:
coords = "lat="+lat+"&long=20.0000&alt=30.000&speed=&vel=40.000&time=20130609062400.097;
but this does not work.
I have this error message
Quote
Invalid operands of types 'const char[5]' and 'char[15]' to binary 'operator' +

That's it
 smiley
164  Using Arduino / Programming Questions / Re: How Can I merge char variable on: June 15, 2013, 06:28:24 pm
To resume,
I have this
Code:
gps.getPar(lon,lat,alt,time,vel);
and it should be in the coords variable of this
Code:
inet.httpPOST(host, port_post, path_post, coords , "Result", 1000);
But I hav to add URL varaiable like this
Code:
coords = "lat="+lat+"&long="+lon+"&alt="+alt+"&speed=&course="+val+"&date=2013-04-25&time="+time+";

 smiley-slim smiley
165  Using Arduino / Programming Questions / Re: How Can I merge char variable on: June 15, 2013, 06:21:40 pm
This is when is commented
Code:
----------------------
Starting SIM908.
----------------------
Please wait...
DB:ELSE
DB:ELSE
DB:ELSE
DB:CORRECT BR
Turn on

status=READY

Attaching GSM
--------------
DB:ALREADY HAVE AN IP
status=ATTACHED
GSM RAEDY TO GO!

Attaching GPS
--------------
status=GPS READY TO GO!
sms => Send SMS
data => Send data to the server
get => Get data from server
gps => Get GPS coords
test => Test system


This is when it uncommented (not good)
Code:
----------------------
Starting SIM908.
----------------------
Please wait...
DB:ELSE
DB:ELSE
DB:ELSE
DB:CORRECT BR
Pages: 1 ... 9 10 [11] 12 13 ... 25