Ah il me semblait bien que le pointeur était "corrompu" après usage...
J'ai réduis les espaces entre &Lati [iLigne] pour former &Lati[iLigne] , et le pire ensuite je les remet tout pareil c'est a dire &Lati [iLigne]
Et la le test d'initialisation locale ne fonctionne plus!!
Voici le code complet de ce petit prog en trois onglets :
Le Var.cpp
#include "Arduino.h"
#include "Var.h"
//http://www.mon-club-elec.fr/pmwiki_reference_arduino/pmwiki.php?n=Main.Tableaux
//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------
//Variables mem Nature Char pour Code de détection dans Com ESP8266 Mega2560
//------------------------------------------------------------------------------------------------
//float Date [60];//Datetime D -,
float Lati [60];//lAtitude A |
float Longi[60];//lOngitude O |> Valeurs du GPS compactometre ComRXTX ComRXTX
int Alti [60];//aLtitude L -' MeEGA2560
//------------------------------------------------------------------------------------------------
float lati [60];//lAtitude a -,
float longi[60];//lOngitude o |> Valeurs du GPS fixe ComWIFI
int alti [60];//aLtitude l -' DGPS
//------------------------------------------------------------------------------------------------
int Tmps [60];//Temps T -,
byte Prof [60]; //Profondeur P |
int Poids[60];//poids W |> Valeurs du compactometre ComRXTX Capteurs
int chrgp[60];//intge en % c | MeEGA2560
int ChrgP[60];//Charge en PSI C -'
//------------------------------------------------------------------------------------------------
byte R [60];//couleurRgb R -> Valeurs de la camera ComWIFI
byte G [60];//couleurRgb R -> Valeurs de la camera ComWIFI
byte B [60];//couleurRgb R -> Valeurs de la camera ComWIFI
//Pointeur de char assoccié ESP32Cam
//------------------------------------------------------------------------------------------------
char *pB = NULL;
int *pI = NULL;
float *pF = NULL;
float *pF2 = NULL;
byte Nb_Bit = 0;
byte Nb_Dgt = 0;
//------------------------------------------------------------------------------------------------
//Codes variables
const char C_GPS1[] PROGMEM = "AOL";
const char C_GPS2[] PROGMEM = "ao";
const char C_COMP[] PROGMEM = "TPWCc";
const char C_CAM[] PROGMEM = "RGB";
char Mot[6];///Attention à calibrer!!
const char *const C_GLOB[] PROGMEM = {C_GPS1,C_GPS2,C_COMP,C_CAM};
enum {OGPS1,OGPS2,OCOMPAC,OCAM};
//char CodeCol;//2= 1 seul byte stoké
byte iObjet = 0;
byte iIndex = 0;
byte iLigne = 0;
void Datas::Ini (bool Imprim){
Lati[0] = 1.001;
for (byte i = 1;i<60;i++){
Lati[i] = Lati[i-1]+1;
if(Imprim){DEBUG.println(Lati[i]);};}
}
void Datas::ExportColJson(char *Buff){
//Inspiration
//https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp
//this->NvFocus(false);
//EffaceMsg();
this->Point = '1';
*Buff++ = '{';
Buff +=sprintf_P(Buff, PSTR("\"cmd\": \"AJ_Col\", \"sht\": \"P%c\","), this->Point); // Comande&Nom
Buff +=sprintf_P(Buff, PSTR("\"col\": \"%c\","),this->CodeCol);
Buff +=sprintf_P(Buff, PSTR("\"val\": \""));
switch (Nb_Bit){
case 4:
for (byte i = 0; i < 30 ; i+=2) {
/// En cours de construction tout n'est pas nickel mais on en a plarlé
float F2 = 9.9999;
pF = &Lati[0];
int Pe = (int)*pF;
Buff +=sprintf_P(Buff, PSTR("%d"), Pe);// "Valeurs"
int Pd = (int)(*pF*100)%100;//*pF++*100)%100;
Buff +=sprintf_P(Buff, PSTR( ".%02d,"), Pd);//*pF++;
};//break;
}
*Buff++ = '}';*Buff++ = '0';
}
void Datas::En_Col(){
//*Buff = '}'
}
void Datas::SetFocus (byte Objet, byte Index){
iObjet = Objet;
iIndex = Index;
//iLigne = Ligne;
NvFocus(false);
}
void Datas::NvFocus(bool Ini){
if (Ini){iIndex =0;}
iLigne = 0;
//Met a jour le CodeCol de la variable parmis le mot du groupe (Obj)
//DEBUG.print(F("Msg: (Colexport) >BUFFER"));
//Met a jour le CodeCol de la variable parmis le mot du groupe (Obj)
strncpy_P(Mot,(char *)pgm_read_word(&(C_GLOB[iObjet])),sizeof(Mot));
//DEBUG.print(Mot);
this->CodeCol = *(Mot + iIndex);// pgm_read_byte_near(int Adress;
//Met a jour l'adresse du pointeur avec l'adresse d'une ligne dans une colonne propriété
switch (this->CodeCol){
//case 'D': pB = (char *)&Date [iLigne]; Nb_Bit = 4; break;
case 'A': pF = &Lati [iLigne]; Nb_Bit = 4; break;
case 'O': pF = &Longi [iLigne]; Nb_Bit = 4; break;
case 'L': pI = &Alti [iLigne]; Nb_Bit = 2; break;
case 'a': pF = &lati [iLigne]; Nb_Bit = 4; break;
case 'o': pF = &longi [iLigne]; Nb_Bit = 4; break;
case 'l': pI = &alti [iLigne]; Nb_Bit = 2; break;
case 'T': pI = &Tmps [iLigne]; Nb_Bit = 2; break;
case 'P': pB = &Prof [iLigne]; Nb_Bit = 1; break;
case 'W': pI = &Poids [iLigne]; Nb_Bit = 2; break;
case 'c': pI = &chrgp [iLigne]; Nb_Bit = 2; break;
case 'C': pI = &ChrgP [iLigne]; Nb_Bit = 2; break;
case 'R': pB = &R [iLigne]; Nb_Bit = 1; break;
case 'G': pB = &G [iLigne]; Nb_Bit = 1; break;
case 'B': pB = &B [iLigne]; Nb_Bit = 1; break;
}
iIndex ++;//Pour le suivant
}
Le Var.h
#ifndef ParamMoteur_h
#define ParamMoteur_h
#include "Arduino.h"
#define DEBUG Serial
class Datas{
public:
void Ini(bool Imprim); //Pour Simuler des données
void ImportLigne (char *Buff, byte Ligne); //Détecte le code et met les données dans la bonne variable
void SetFocus (byte Objet,byte Index); //Met le focus sur un Objet interne et un éventuel sous élément
void ExportColJson (char *Buff); //Exporte sous forme de colonnes un élément avec son code et les datas séparées par un virgule
byte Point = 0;
byte Ligne = 0;
private:
void En_Col();
void NvFocus(bool Ini); //Focuse sur l'élément suivant
char CodeCol = 0;
//char *Buff = NULL;
};
#endif
Et le .ino
#include <avr/pgmspace.h>
#include "Arduino.h"
#include "Var.h"
Datas D;
bool Debug =true;
byte Ligne = 0;
byte LigneMax = 10;
enum {OGPS1,OGPS2,OCOMPAC,OCAM};
const byte nInputStringSerie PROGMEM = 50; //Taille du buffer
char InputStringSerie[nInputStringSerie]; // a string to hold incoming data
const int sz_Nom PROGMEM = 8; //Taille du buffer
char Nom[sz_Nom]; // a string to hold incoming Name
const int sz_Msg PROGMEM = 600;
char Msg[sz_Msg];
void setup(){
Serial.begin(9600);
D.Ini(true);
Msg[0]='F';
D.SetFocus(OGPS1,0);
D.ExportColJson(Msg);//ou &Msg[n]
//ExportData();
Serial.print(Msg);
}
void loop(){
//LigneMax++;
}
void ExportData(){//byte Obj){Fait bug?
/*
byte index =0;
byte Obj = OGPS1;
do{
MAJ_Focus(Obj,0,index);
LigneMax++;
//if (Debug) {Serial.print(F("CodeCol: (Export) >"));Serial.print(CodeCol);Serial.println(F("<"));}
//EcrireColDataSheets();
EcrireJsonCol();
delay(100);
}while(1);
*/
}
void EffaceBuffer() {
memset (InputStringSerie, '\0', sizeof (InputStringSerie));//Efface le buffer
}
void EffaceMsg() {
memset(Msg, '\0', sizeof(Msg));
}
Si un expert peut m'expliquer tout ceci, merci d'avance.