Show Posts
Pages: 1 ... 9 10 [11] 12 13 ... 26
151  International / Français / Re: Comment puis-je envoyer un array en post on: July 15, 2013, 12:33:34 am
Aussi, ca ca ne marche pas non plus

Code:
String message = "test1"+"test2";
Le message d'erreur : "Invalid  operands of types 'const char [5]' and 'const char [5]' to binary 'operateu' +"

J'essaye de concatener des String, maintenant.
152  International / Français / Re: Comment puis-je envoyer un array en post on: July 14, 2013, 03:41:18 pm
Merci pour ta réponse.
Je deviens un peu fou  smiley

je fais ceci:
Code:
String fix = "long=" + String(lon) + "&lat=" + String(lat) + "&alti=" + String(alt) + "&vel=" + String(vel) + "&time=" + String(time);


 Serial.println(fix);
 Serial.println(fix.length());
fix.toCharArray(coords, 109);
//(j'aimerais remplacé 109 par fix.length()+1
//char coords[fix.length()+1];
//fix.toCharArray(coords, fix.length()+1);
// Le +1 pour laisser une place au terminateur, comme tu me l a expliqué

pourquoi fix n'affiche rien? Il affiche vide.
(lon, lat, alt, vel, time, sont des char.
153  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 14, 2013, 03:14:33 pm
Hello acboother,

Yes, I debug a bit as you explain.
Yesterday evening, I discivered that it work until this
Code:
/*
  strncat(coords,alt,COORDSSIZ);  //61
 
  strcat(coords,"&t=");        //64
  strncat(coords,time,20);      //84
 
  strcat(coords,"&vel=");        //89
  strncat(coords,vel,COORDSSIZ);  //114
  */

Code:
void getGPSCoords(){
  #ifdef DEBUG
    stat=gps.getStat();
    if(stat==1){
      Serial.println("NOT FIXED");
    }else if(stat==0){
      Serial.println("GPS OFF");
    }else if(stat==2){
      Serial.println("2D FIXED");
    }else if(stat==3){
      Serial.println("3D FIXED");
    }
    delay(5000);
  #endif   
 
  //Get data from GPS
 
    gps.getPar(lon,lat,alt,time,vel);
 
  Serial.println(lon);
  Serial.println(lat);
  Serial.println(alt);
  Serial.println(vel);
  Serial.println(time);
  Serial.println("-----");
 

 
  strcpy(coords,"long=");
  strncat(coords,lon,COORDSSIZ); //21
 
  strcat(coords,"&lat=");        //25
  strncat(coords,lat,COORDSSIZ);//40

  strcat(coords,"&alti=");        //46
/*
  strncat(coords,alt,COORDSSIZ);  //61
 
  strcat(coords,"&t=");        //64
  strncat(coords,time,20);      //84
 
  strcat(coords,"&vel=");        //89
  strncat(coords,vel,COORDSSIZ);  //114
  */
 
  // I am also trying this, but coords display nothing
  //snprintf(coords, sizeof coords,"lon=%s,lat=%s,alti=%s,vel=%s,time=%s",lon,lat,alt,vel,time);
 
  #ifdef DEBUG
    Serial.print(F("Coords : "));                               
    Serial.println(coords);
  #endif

I am also traing with this
Code:
char coords[]="";
snprintf(coords, sizeof coords,"lon=%s,lat=%s,alti=%s,vel=%s,time=%s",lon,lat,alt,vel,time);
Serial.println(coords);
With this, the code work and do not crash or restart. But coords display nothing
154  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 14, 2013, 02:57:10 pm
Really really thank for your help.

What do you mean ba the header?

The function is in another file. I past all of this function. I hope I answered to your question
(I have not wrote this function. It's a library I found.)
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;
}
155  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 14, 2013, 02:35:53 pm
Here is my full full code

the function
void getGPSCoords(){} and
gps.getPar(lon,lat,alt,time,vel);
is at the bottom

and also look below
// GET GPS COORDS,
I call the function getGPSCoords, here, while I type "gps" in my terminal

Code:
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
#include "sms.h"
//#include "call.h"
#include "gps.h"

InetGSM inet;
//CallGSM call;
SMSGSM sms;
GPSGSM gps;

#define DEBUG

char number[]="0041000000000";  //Destination number

// INET
char apn[] = "internet"; // access-point name for GPRS
char username[] = "";
char password[] = "";
//char ip = "92.104.xx.xxx"; // IP address of server we're connecting to
int port_get = 80; // Port to use
int port_post = 80; // Port to use
char host[] = "xxx.dyndns.org"; // required in HTTP 1.1 - what's the name of the host at this IP address?
char path_post[] = "/opt/updatesql.php";
/*
const int buttonPin = 10;     // the number of the pushbutton pin
int buttonState = 0;
buttonState = digitalRead(buttonPin);
*/

// GPS

char coords[127];
#define COORDSSIZ 15
char lon[COORDSSIZ];
char lat[COORDSSIZ];
char alt[COORDSSIZ];
char time[20];
char vel[COORDSSIZ];
char msg1[5];
char msg2[5];

char stat;
char inSerial[20];
int i=0;
boolean started=false;

void setup()
{
  //Serial connection.
  Serial.begin(9600);
  #ifdef DEBUG
    Serial.println(F(""));
    Serial.println(F("\n--------------------------------"));
    Serial.println(F("Starting SIM908."));
    Serial.println(F("--------------------------------"));
    Serial.println(F("Please wait..."));
  #endif
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
 
  if (gsm.begin(2400)){
   
    #ifdef DEBUG
      Serial.println("\nstatus=READY\n");
    #endif
   
    gsm.forceON(); //To ensure that SIM908 is not only in charge mode
    started=true; 
   
  }else{
    #ifdef DEBUG
      Serial.println("\nstatus=IDLE");
    #endif
  }
  if(started){
    #ifdef DEBUG
      Serial.println(F("GPS"));
      Serial.println(F("--------------------------------"));
    #endif
    //GPS attach
    if (gps.attachGPS()){
      Serial.println("status=GPS_READY");
    }else{
      Serial.println("status=GPS_ERROR_NOT_ATTACHED");
    }
   
    #ifdef DEBUG
      Serial.println(F("\nGSM"));
      Serial.println(F("--------------------------------"));
    #endif
   
    #ifdef DEBUG
      Serial.println("Waiting for 20sec before trying to attach GSM");
    #endif
    delay(20000); //Time for fixing
   
   
   
    // GSM ATTACH
    if (inet.attachGPRS("internet", "", "")){
      #ifdef DEBUG
        Serial.println(F("status=GSM_ATTACHED"));
      #endif
      //Read IP address.
      gsm.SimpleWriteln("AT+CIFSR");
      delay(5000);
      //Read until serial buffer is empty.
      gsm.WhileSimpleRead();
    }else{
      Serial.println(F("status=GSM_ERROR_NOT_ATTACHED"));
    }
    #ifdef DEBUG
      Serial.println("\nWaiting for 1sec");
    #endif
    delay(1000);
   
   
   
    #ifdef DEBUG
      enterCommand();
    #endif
   
  }else{
    #ifdef DEBUG
      Serial.println(F("Not started"));
     #endif
  }
};

void loop()
{
  /*
  buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    digitalWrite(GSM_ON, HIGH);
    delay(2000);
    digitalWrite(GSM_ON, LOW);
    delay(5000); 
  }
  else {
  }
  */
  //Read for new byte on serial hardware,
  //and write them on NewSoftSerial.
  serialhwread();
  //Read for new byte on NewSoftSerial.
  serialswread();
};

void serialhwread(){
  i=0;
  if (Serial.available() > 0){           
    while (Serial.available() > 0) {
      inSerial[i]=(Serial.read());
      delay(10);
      i++;     
    }
   
    inSerial[i]='\0';
    if(!strcmp(inSerial,"/END")){
      Serial.println("_");
      inSerial[0]=0x1a;
      inSerial[1]='\0';
      gsm.SimpleWriteln(inSerial);
    }
    //Send a saved AT command using serial port.
    if(!strcmp(inSerial,"test")){
      Serial.println(F("BATTERY TEST 1"));
      Serial.println(F("--------------------------------"));
      gps.getBattInf(msg1,msg2);
      Serial.println(msg1);
      Serial.println(msg2);
      Serial.println(F("BATTERY TEST 2"));
      Serial.println(F("--------------------------------"));
      gps.getBattTVol(msg1);
      Serial.println(msg1);
      Serial.println(F("GPS TEST"));
      Serial.println(F("--------------------------------"));
      getGPSCoords();
      Serial.println(F(""));
     
      #ifdef DEBUG
          enterCommand();
      #endif
    }
   
     // SEND SMS
    if(!strcmp(inSerial,"sms")){
      #ifdef DEBUG
        Serial.println(F("SENDING SMS"));
        Serial.println(F("--------------------------------"));
        Serial.println(F("In progress, wait..."));
      #endif
      if (sms.SendSMS(number, "Did you get that SMS?")){
        #ifdef DEBUG
          Serial.println("SMS sent OK\n");
        #endif
       }
       
       #ifdef DEBUG
          enterCommand();
        #endif
    }
   
    // GET GPS COORDS
    if(!strcmp(inSerial,"gps")){
      #ifdef DEBUG
        Serial.println(F("GETTING GPS COORDS"));
        Serial.println(F("--------------------------------"));
        Serial.println(F("In progress, wait..."));
      #endif
      getGPSCoords();
     
      #ifdef DEBUG
          enterCommand();
      #endif
    }
   
    // GET DATA FROM SERVER
    if(!strcmp(inSerial,"get")){
     
      #ifdef DEBUG
        Serial.println(F(""));
        Serial.println(F("The collection of data from the server, is not ready yet"));
       #endif
     /*
      #ifdef DEBUG
        Serial.print(F("Getting data from (Host/Port) "));
        Serial.print(host);
        Serial.print(F(" /  "));
        Serial.println(port_get);
      #endif
      */
     
      /*
      //TCP Client GET, send a GET request to the server and
      //save the reply.
      numdata=inet.httpGET(host, port_get, "/", msg, 50);
      //Print the results.
      Serial.println(F("\nNumber of data received:"));
      Serial.println(numdata); 
      Serial.println(F("\nData received:"));
      Serial.println(msg);
      */
     
       enterCommand();
    }
   
    // SEND DATA
    if(!strcmp(inSerial,"data")){
        #ifdef DEBUG
          Serial.println(F(""));
          Serial.println(F("Sending GPS coords to the remote server"));
          Serial.println(F("---------------------------------------"));
          Serial.println(F("Script not ready"));
         #endif
      /*
        inet.httpPOST(host, port_post, path_post, coords , "Result", 1000);
        delay(10000);
       */
        enterCommand();
    }
   
   
    //Read last message saved.
    if(!strcmp(inSerial,"msg")){
      Serial.println(msg1);
    }
    else{
      Serial.println(inSerial);
      gsm.SimpleWriteln(inSerial);
    }   
    inSerial[0]='\0';
  }
}

void serialswread(){
  gsm.SimpleRead();
}

void getGPSCoords(){
  #ifdef DEBUG
    stat=gps.getStat();
    if(stat==1){
      Serial.println("NOT FIXED");
    }else if(stat==0){
      Serial.println("GPS OFF");
    }else if(stat==2){
      Serial.println("2D FIXED");
    }else if(stat==3){
      Serial.println("3D FIXED");
    }
    delay(5000);
  #endif   
 
  //Get data from GPS
 
  gps.getPar(lon,lat,alt,time,vel);
 
  Serial.println(lon);
  Serial.println(lat);
  Serial.println(alt);
  Serial.println(time);
  Serial.println(vel);
  /*
  String fix = "long=" + String(lon) + "&lat=" + String(lat) + "&alti=" + String(alt) + "&vel=" + String(vel) + "&time=" + String(time) + "\0";
//  char *fix[144] = {"long=" + String(lon) + "&lat=" + String(lat) + "&alti=" + String(alt) + "&vel=" + String(vel) + "&time=" + String(time) + "\0"};

  char *coord;
  coord = (char*)fix;
  */

 
  strcpy(coords,"long=");
  strncat(coords,lon,COORDSSIZ); //21
 
  strcat(coords,"&lat=");        //25
  strncat(coords,lat,COORDSSIZ);//40

  strcat(coords,"&alti=");        //46

  strncat(coords,alt,COORDSSIZ);  //61
 
  strcat(coords,"&t=");        //64
  strncat(coords,time,20);      //84
 
  strcat(coords,"&vel=");        //89
  strncat(coords,vel,COORDSSIZ);  //114
 
 
  #ifdef DEBUG
    Serial.print(F("Coords : "));                               
    Serial.println(coords);
  #endif
 
}

void enterCommand(){
    Serial.println("\nEnter a command :");
    Serial.println(F("--------------------------------"));
    Serial.println(F("sms  => Send SMS"));
    Serial.println(F("data => Send GPS coords to the server"));
    Serial.println(F("get  => Get data from server"));
    Serial.println(F("gps  => Display GPS coords"));
    Serial.println(F("test => Test system"));
    Serial.println(F("--------------------------------\n"));
   
}
156  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 14, 2013, 02:19:48 pm
Dear UKHeliBob

Thank for your proposition.

I am just confused with this, as you showed
Code:
char lon[15] = {"712.585044"};
  char lat[15] = {"4705.587531"};
  char alt[15] = {"505.911530"};
  char time[20] = {"20130713210510.000"};
  char vel[15] = {"0.000000"};

I can not hardly code this {"712.585044"};

The value are provided to lon, lat, alt, time, vel by a function
Code:
gps.getPar(lon,lat,alt,time,vel);
and all lon, lat, alt.. etc are char variable

I just declare
Code:
char coords[200]; //I gave this time a very large value, but it should be around 114
#define COORDSSIZ 15
char lon[COORDSSIZ];
char lat[COORDSSIZ];
char alt[COORDSSIZ];
char time[20];
char vel[COORDSSIZ];
and then the function give the value to the variable.

Code:
void getGPSCoords(){
  #ifdef DEBUG
    stat=gps.getStat();
    if(stat==1){
      Serial.println("NOT FIXED");
    }else if(stat==0){
      Serial.println("GPS OFF");
    }else if(stat==2){
      Serial.println("2D FIXED");
    }else if(stat==3){
      Serial.println("3D FIXED");
    }
    delay(5000);
  #endif   
 
  //Get data from GPS
 
  gps.getPar(lon,lat,alt,time,vel);
 
// Those Serial.println, print correctly the value of the variables
  Serial.println(lon);
  Serial.println(lat);
  Serial.println(alt);
  Serial.println(time);
  Serial.println(vel);
  /*
  String fix = "long=" + String(lon) + "&lat=" + String(lat) + "&alti=" + String(alt) + "&vel=" + String(vel) + "&time=" + String(time) + "\0";
//  char *fix[144] = {"long=" + String(lon) + "&lat=" + String(lat) + "&alti=" + String(alt) + "&vel=" + String(vel) + "&time=" + String(time) + "\0"};

  char *coord;
  coord = (char*)fix;
  */

  strcpy(coords,"long=");
  strncat(coords,lon,COORDSSIZ); //21 => This fonction is to limit the size of lon to 15. It uses the first 15 caracters, if there are more...
 
  strcat(coords,"&lat=");        //25
  strncat(coords,lat,COORDSSIZ);//40

  strcat(coords,"&alti=");        //46
  strncat(coords,alt,COORDSSIZ);  //61
 
  strcat(coords,"&t=");        //64
  strncat(coords,time,20);      //84
 
 
  strcat(coords,"&vel=");        //89
  strncat(coords,vel,COORDSSIZ);  //114
 
 
 
 
  #ifdef DEBUG
    Serial.print(F("Coords : "));                               
    Serial.println(coords);
  #endif
 
}
157  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 14, 2013, 01:14:39 pm
Thank again all for helping
@PeterH
Those value are the excat value,  provided by
gps.getPar(lon,lat,alt,time,vel);
@acboother
Those value (lon, lat, alt, time, vel) are char
@Gammon
x is an value that I am not sure, but it should be aroud 114
I wrote this:
Quote
(x=a value that I may ignore..., may be it's the reason of my issue)
I posted the major code here
http://forum.arduino.cc/index.php?topic=177206.msg1315045#msg1315045

My code works fine excepted for my need to concatenate char variable, as I wrote before.


I also tried something like this
Keep in mind, lon, lat, alt, etc have 15 caraceter maximum
Code:
  char fix[144] = {"long=" + String(lon) + "&lat=" + String(lat) + "&alti=" + String(alt) + "&vel=" + String(vel) + "&time=" + String(time) + "\0"};
But I got this error message, because I miss the step to convert String to char. Can we do it simply?
Quote
Can not covert 'StringSumHelper' to 'char' in initlization
158  International / Français / Re: Comment puis-je envoyer un array en post on: July 14, 2013, 12:45:50 pm
Je ne suis pas trop favorable à ceci, mais ne serait pas possible de trouver une alternative comme ceci:
Code:
String fix = "long=" + String(lon) + "&lat=" + String(lat) + "&alti=" + String(alt) + "&vel=" + String(vel) + "&time=" + String(time);
  char coord[]="";
  strcpy(coord,fix);
Dans lée cas ci-dessous, ca ne marche pas, car il n'accepte pas un String dans un char.

Mais, dans ce cas, es-ce possible de convertir un String en un char?

J'ai aussi pensé à ca, si non:
Code:
  char fix[144] = {"long=" + String(lon) + "&lat=" + String(lat) + "&alti=" + String(alt) + "&vel=" + String(vel) + "&time=" + String(time) + "\0"};
Mais j'ai ce message d'erreur:
Quote
Can not covert 'StringSumHelper' to 'char' in initlization

Merci pour votre aide precieuse
159  International / Français / Re: Comment puis-je envoyer un array en post on: July 14, 2013, 12:35:02 pm
Hello
merci pour ta réponse. J'ai du mal a te suivre.

Oui en effet, il y a 26 caractere entre les "&xxx="

Pour les lat lon, ..., il y a un maximum de 15 caracteres, mais dans mon cas il y en a 10

J'ai change le code ainsi

Code:
// A savoir que:
char coords[46];
#define COORDSSIZ 15
char lon[COORDSSIZ];
char lat[COORDSSIZ];
char alt[COORDSSIZ];
char time[20];
char vel[COORDSSIZ];
void getGPSCoords(){
  #ifdef DEBUG
    stat=gps.getStat();
    if(stat==1){
      Serial.println("NOT FIXED");
    }else if(stat==0){
      Serial.println("GPS OFF");
    }else if(stat==2){
      Serial.println("2D FIXED");
    }else if(stat==3){
      Serial.println("3D FIXED");
    }
    delay(5000);
  #endif   
 
  //Get data from GPS
 
  gps.getPar(lon,lat,alt,time,vel);
 
  Serial.println(lon);
  Serial.println(lat);
  Serial.println(alt);
  Serial.println(time);
  Serial.println(vel);
 
  strcpy(coords,"long=");
  strncat(coords,lon,COORDSSIZ); //21
 
  strcat(coords,"&lat=");        //25
  strncat(coords,lat,COORDSSIZ);//40

  strcat(coords,"&alti=");        //46
/*
  strncat(coords,alt,COORDSSIZ);  //61
 
  strcat(coords,"&t=");        //64
  strncat(coords,time,20);      //84
 
 
  strcat(coords,"&vel=");  //89
  strncat(coords,vel,COORDSSIZ);  //114
  */
 
 
 
  #ifdef DEBUG
    Serial.print(F("Coords : "));                               
    Serial.println(coords);
  #endif
 
}

A savoir que la fonction  gps.getPar(lon,lat,alt,time,vel);
fourni les valeurs pour :
Quote
lon : 608.487270
lat : 4613.154144
alt : 449.156219
time : 20130714172921.000
vel : 0.000000


Mais que veux tu dire par
Quote
A chaque concaténation on gagne le terminateur de chaîne
Es-ce que le terminateur de chaine est le "\0"

Parce que la en effet, j'ai pas pensé à ca, et pour être franc je ne sais pas comment modifier mes variable/script.
Je pensais que de donner une valeur à une variable char, le \0 est automatique.

Pourrais-tu m'éclairecir, la dessus?

Il y a une autre chose intéressante que j'ai constaté hier soir.
Dans le code que j'ai collé, ci-dessus, il y a un commentaire qui rend une partie de strcat non fonctionnel.

Ma variable coords affiche ce que je veux
Quote
Coords : long=608.487270&lat=4613.154144&alti=
Mais du moment quze je décommente cette partie, il plante.
Donc ca plante à partir de
Code:
strcat(coords,"&alti=");        //46

Bien entendu, quand je décommente cette partie, j'augmente la valeur de
Code:
char coords[46];
comme par exemple
Code:
char coords[114];
160  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 13, 2013, 04:37:47 pm
Thank for all for your help,
but I do not undertand why it's so complicate to concatenate char variable. (I am a beginner as well :o)).

In resume , I have :
(x=a value that I may ignore..., may be it's the reason of my issue)
Code:
char coords[x];
char lat[15];
char lon[15]
char alt[15];
char vel[15];
char time[20];

my function
void getGPSCoords()
collect the coords and provide the value to teh corresponding char variable.
The values are numbers with dots, for exemple:

lon: 712.585044
lat: 4705.587531
alti: 505.911530
time: 20130713210510.000
vel: 0.000000

I wish to concatenate lat,lon,alti,vel and time into coords and adding the string (or har) between some of them
lon=, &lat=, &alti, &vel=, &time=

As we can do in PHP:

$coords="lon=".$lon."&lat=".$lat."&alti=".$alt."&vel=".$vel."&time=".$time;

 smiley




161  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 13, 2013, 04:22:35 pm
oups sorry,

har is char. the c was not copied but it is correct in my script

Same for i.

It's well declared on the top of my script
Code:
int i=0;
162  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 13, 2013, 04:05:26 pm
here are the exact value :

lon: 712.585044
lat: 4705.587531
alti: 505.911530
time: 20130713210510.000
vel: 0.000000


Coords : long=712.585044&lat=4705.587531&alti=
163  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 13, 2013, 03:58:31 pm
Ha sorry!

the value are something like this (number with .)

for exemple:
lon: 12.344566
lat: 3457.3456
alt: 34.6788

etc
164  Using Arduino / Programming Questions / Re: Do I need a special library for strcpy and strcat on: July 13, 2013, 02:54:34 pm
I discover an intersting think,

I tryed step by step by commenting all strcat command. Then I uncomment he two first strcat for lat, the the next for lon and it was working until I uncomment the strcat for the variable cat:

Be aware, I change the variable
char coords[100]; to char coord[]="";
and I added a define COORDSSIZ 15.

Here is a exemple/part of my above code.
Code:
char coord[]="";$
define COORDSSIZ 15; //in order to make sure to not have more than 15 caracter.

void getGPSCoords(){
  #ifdef DEBUG
    stat=gps.getStat();
    if(stat==1){
      Serial.println("NOT FIXED");
    }else if(stat==0){
      Serial.println("GPS OFF");
    }else if(stat==2){
      Serial.println("2D FIXED");
    }else if(stat==3){
      Serial.println("3D FIXED");
    }
    delay(5000);
  #endif   
 
  //Get data from GPS
 
  gps.getPar(lon,lat,alt,time,vel);
 
 
  strcat (coords,"lat=");
  strncat (coords,lat,COORDSSIZ); //In my case lat has 11 caracter but can have  15 in max
  Serial.print(lat);
  Serial.println(",");
  strcat (coords,"&long=");
  strncat (coords,lon,COORDSSIZ); //In my case lon has 10 caracter but can have  15 in max
  Serial.print(lon);
  Serial.println(",");

  strcat (coords,"&alt=");
 
  // Until now coords has 35 caracters.
 // IT CRASH/RESET SINCE I UNCOMMENT THNE BELOW LIGN

  strncat (coords,alt,COORDSSIZ); //In my case alt has 10 caracter but can have 15 in max
 
  Serial.print(alt);
  Serial.println(",");   
  /*
  strcat (coords,"&vel=");
  strncat (coords,vel,COORDSSIZ);
   
  strcat (coords,"&time=");
  strncat (coords,time,20);
  */
  #ifdef DEBUG
    Serial.print(F("Coords : "));                               
    Serial.println(coords);
  #endif
 
}
Does coords become out of "space"?
165  International / Français / Re: Comment puis-je envoyer un array en post on: July 13, 2013, 02:03:24 pm
Ben mon probleme il est la.

Je le faisait ainsi
Code:
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 : "));                               
    Serial.println(coords);
  #endif

Mais pour une raison que j'ignore, mon programe crache 4 seconde apres avoir commencé. un peu comme si on faisait un reset. Par contre si je commente, le strcat et strcpy, ca ne crache plus.....

Alors je cherche a comprendre ou une alternative..., et c est pourquoi j'ai pensé a une array.

En fait, le besoin est donc de concatener 5 variable en une seul, comme par exemple en php:

Code:
$coords = 'coords='.$lon.','.$lat.','.$alt.','.$time.','.$vel;
Pages: 1 ... 9 10 [11] 12 13 ... 26