Ahmed_PFE_Embarq_300415
Dependencies: C12832 LM75B mbed
Fork of Ahmed_Embarq_Prog by
Revision 1:197b9fed6092, committed 2015-04-30
- Comitter:
- pfe
- Date:
- Thu Apr 30 12:24:33 2015 +0000
- Parent:
- 0:05a20e3e3179
- Commit message:
- Ahmed_PFE_Embarq_300415
Changed in this revision
diff -r 05a20e3e3179 -r 197b9fed6092 Ah_main.cpp --- a/Ah_main.cpp Tue Apr 21 10:16:20 2015 +0000 +++ b/Ah_main.cpp Thu Apr 30 12:24:33 2015 +0000 @@ -3,370 +3,503 @@ #include "MSCFileSystem.h" //----------------------- #include "Define.h" -#include "RecGPS.h" +#include "Dec_GPS.h" //----------------------- - MSCFileSystem fsLog("USB"); // Enregsetement des doonées "Flash Disque USB" - FILE *Fs_Log; - I2C _I2C(p28,p27); // I2C SCL,SDA - Serial _ComGPS(p13, p14); // TX non connecté, pin14 RX. - Serial _ComXbee(p9,p10); // Serial tx(p9),rx(10) - #define pRST_Xbee p30 // pin RST Xbee - Ticker _Ticker5ms; - Timer _Timer1; // Timer pour mesurer le temps - - DigitalIn boutonStart(p13); // Joystique Left : Boutton pour pouvoir controler le debut de l'enregistrement - DigitalIn boutonEnd(p16); // Joystique Right : Boutton pour pouvoir controler la fin de l'enregistrement +MSCFileSystem fsLog("USB"); // Enregsetement des doonées "Flash Disque USB" +FILE *Fs_Log; +I2C _I2C(p28,p27); // I2C SCL,SDA +Serial _ComGPS(NC, p14); // TX non connecté, pin14 RX. +Serial _ComXbee(p9,p10); // Serial tx(p9),rx(10) +#define pRST_Xbee p30 // pin RST Xbee +Ticker _Ticker1ms; +Timer _Timer1; // Timer pour mesurer le temps - DigitalOut RSTXbee (p30); - DigitalOut LedGPS (LED1); - DigitalOut LedLog (LED2); - DigitalOut LedXbee (LED3); - DigitalOut LedError(LED4); +DigitalIn boutonStart(p13); // Joystique Left : Boutton pour pouvoir controler le debut de l'enregistrement +DigitalIn boutonEnd(p16); // Joystique Right : Boutton pour pouvoir controler la fin de l'enregistrement + +DigitalOut RSTXbee (p30); +DigitalOut LedGPS (LED1); +DigitalOut LedLog (LED2); +DigitalOut LedXbee (LED3); +DigitalOut LedError(LED4); //----------------------- -StructGPS GPS; +StructGPS GPS,OldGPS; unsigned long TimeBtpress=0,TIMER_10ms; -unsigned long FileIndex; +unsigned long FileIndex0,FileIndex; char Txt[16],Txt_Log[100],Txt_Tx2GSC[100],DataLogFileName[32]; -unsigned long tk1; // des variables pour stocker les temps de mesure //----------------------------------- Reception des données GPS 10Hz -void AutoMat_GPS(){ -static unsigned char i=0,j=0,GPSDataType=0,ET_AutoMat_GPS=ET_01; -static char gps_mess; - while(_ComGPS.readable()){ - gps_mess=_ComGPS.getc(); - - switch(ET_AutoMat_GPS){ - case ET_01: if(gps_mess==prompt$GP[i]){ - i++; - if(i==3){ - i=0; - j=0; - ET_AutoMat_GPS=ET_02; - } - }else i=0; + +void AutoMat_GPS() +{ + static unsigned char i=0,j=0,GPSDataType=0,ET_AutoMat_GPS=ET_01; + static char gps_mess; + while(_ComGPS.readable()) { + gps_mess=_ComGPS.getc(); + + switch(ET_AutoMat_GPS) { + case ET_01: + if(gps_mess==prompt$GP[i]) { + i++; + if(i==3) { + i=0; + j=0; + ET_AutoMat_GPS=ET_02; + } + } else i=0; + break; + case ET_02: + if(gps_mess==promptGGA[i]) { + i++; + if(i==3) { + i=0; + j=0; + ET_AutoMat_GPS = ET_03; + GPSDataType = GGA; + } + break; + } else i=0; + + if(gps_mess==promptRMC[j]) { + j++; + if(j==3) { + j=0; + ET_AutoMat_GPS=ET_03; + GPSDataType=RMC; + } + break; + } else j=0; + + ET_AutoMat_GPS=ET_01; + break; + + case ET_03: + _MsgGPSRx[i]=gps_mess; + i++; + if((i<NData_GPS_Max)&&(gps_mess!=0x0D))break; + + switch(GPSDataType) { + + case GGA: + DecodageGPGGA(MsgGPSRx,i-1,&OldGPS);// l'appel de la fonction de decodage du message GPGGA + if (OldGPS.GGA_Valid == 0x01) { + OldGPS.GGA_Valid = 0x00; + LedGPS = !LedGPS; + } break; - case ET_02: if(gps_mess==promptGGA[i]){ - i++; - if(i==3){ - i=0; - j=0; - ET_AutoMat_GPS = ET_03; - GPSDataType = GGA; - } - break; - }else i=0; - - if(gps_mess==promptRMC[j]){ - j++; - if(j==3){ - j=0; - ET_AutoMat_GPS=ET_03; - GPSDataType=RMC; - } - break; - }else j=0; - - ET_AutoMat_GPS=ET_01; + case RMC: //DecodageGPRMC(i-1);// l'appel de la fonction de decodage du message GPGGA //DecodageGPRMC(i-1); + break; + default: break; - - case ET_03: _MsgGPSRx[i]=gps_mess; - i++; - if((i<NData_GPS_Max)&&(gps_mess!=0x0D))break; - - switch(GPSDataType){ - - case GGA: DecodageGPGGA(i-1);// l'appel de la fonction de decodage du message GPGGA - LedGPS=!LedGPS; - if (GpsData.GGA_Valid==0x01){ - GpsData.GGA_Valid=0x00; - GPS=GpsData; - } - break; - case RMC: //DecodageGPRMC(i-1);// l'appel de la fonction de decodage du message GPGGA //DecodageGPRMC(i-1); - break; - default: break; - } - ET_AutoMat_GPS=ET_01; - GPSDataType=0; - default : break; + } + ET_AutoMat_GPS=ET_01; + GPSDataType = NULL; + default : + break; } - } -} + } +} //----------------------------------- Transmission données au sol 10 packet/s -void AutoMat_Xbee_Tx(){ - switch (ET_AutoMat_Xbee_Tx) { - case ET_01: - LedXbee = !LedXbee; - sprintf(Txt_Tx2GSC,"$GPS;%lu;%lu;",OldTimer_10ms,GPS.Qual); - _ComXbee.printf("%s",Txt_Tx2GSC); - ET_AutoMat_Xbee_Tx = ET_02; - break; - case ET_02 : - sprintf(Txt_Tx2GSC,"%2u:%2u:%2u;",GPS.hh,GPS.mm,GPS.ss); - _ComXbee.printf("%s",Txt_Tx2GSC); - ET_AutoMat_Xbee_Tx = ET_03; - break; - case ET_03 : - sprintf(Txt_Tx2GSC,"%2u;%2u.%u;%c;",GPS.LatDeg,GPS.LatMin,GPS.Latmmmm,GPS.LatDir); - _ComXbee.printf("%s",Txt_Tx2GSC); - ET_AutoMat_Xbee_Tx = ET_04; - break; - case ET_04 : - sprintf(Txt_Tx2GSC,"%3u;%2u.%u;%c;",GPS.LongDeg,GPS.LongMin,GPS.Longmmmm,GPS.LongDir); - _ComXbee.printf("%s",Txt_Tx2GSC); - ET_AutoMat_Xbee_Tx = ET_05; - break; - case ET_05 : - sprintf(Txt_Tx2GSC,"%c%u\r\n",GPS.SignHMSL,GPS.HMSL); - _ComXbee.printf("%s",Txt_Tx2GSC); - ET_AutoMat_Xbee_Tx = ET_06; - break; - //------------ - case ET_06 : - sprintf(Txt_Tx2GSC,"$PDV;%lu;%4u;%4u;%4u;%4d\r\n",OldTimer_10ms,OldCAP,OldALT,OldTAS,OldTEMPRE); - _ComXbee.printf("%s",Txt_Tx2GSC); - ET_AutoMat_Xbee_Tx = ET_00; - break; - default: ET_AutoMat_Xbee_Tx=ET_00; break; - } +void AutoMat_Xbee_Tx() +{ + static char LIndex=0; + switch (ET_AutoMat_Xbee_Tx) { + case ET_01: + LIndex++; + ET_AutoMat_Xbee_Tx = ET_00; + if(LIndex>=5) ET_AutoMat_Xbee_Tx = ET_02; + break; + case ET_02: + LIndex = 0; + LedXbee = !LedXbee; + sprintf(Txt_Tx2GSC,"$TIME:%lu\r\n",OldTIMER_10ms); + _ComXbee.printf("%s",Txt_Tx2GSC); + ET_AutoMat_Xbee_Tx = ET_03; + break; + case ET_03 : + sprintf(Txt_Tx2GSC,"!!!UTC:%2u%2u%2u,***\r\n",GPS.hh,GPS.mm,GPS.ss); + _ComXbee.printf("%s",Txt_Tx2GSC); + ET_AutoMat_Xbee_Tx = ET_04; + break; + case ET_04 : + //delay 10ms + ET_AutoMat_Xbee_Tx = ET_05; + break; + case ET_05 : + sprintf(Txt_Tx2GSC,"!!!LAT:%ld,LON:%ld,***\r\n",GPS.LatDeg,GPS.LonDeg); + _ComXbee.printf("%s",Txt_Tx2GSC); + ET_AutoMat_Xbee_Tx = ET_06; + break; + case ET_06 : + //delay 10ms + ET_AutoMat_Xbee_Tx = ET_07; + break; + case ET_07 : + sprintf(Txt_Tx2GSC,"!!!PCH:%.2f,RLL:%.2f,CRS:%.2f,SPD:%.2f,ALT:%.2f,***\r\n",HK_PCH,HK_RLL,HK_CRS,HK_SPD,HK_ALT); + _ComXbee.printf("%s",Txt_Tx2GSC); + ET_AutoMat_Xbee_Tx = ET_08; + break; + case ET_08 : + ET_AutoMat_Xbee_Tx = ET_00; + break; + default: + ET_AutoMat_Xbee_Tx=ET_00; + break; + } } //----------------------------------- LogData 100Hz, LogGPS 10Hz -void AutoMat_DataLog(){ - switch (ET_AutoMat_DataLog){ - - case ET_01: - LedLog=!LedLog; - //-------------- - OldTimer_10ms = TIMER_10ms; - // au max 100us (0.1ms) - sprintf(Txt_Log,"PDV;%lu;%5d;%5d;%5d;%5d\r\n",TIMER_10ms,CAP,ALT,TAS,TEMPRE); - // au max 5000 us (5ms) - fprintf(Fs_Log,Txt_Log); - // 100us - sprintf(Txt_Log,"GPS;%lu;%1u;%2u:%2u:%2u;%2u;%2u.%u;%c;%3u;%2u.%u;%c;%c%u\r\n",TIMER_10ms,GPS.Qual,GPS.hh,GPS.mm,GPS.ss,GPS.LatDeg,GPS.LatMin,GPS.Latmmmm,GPS.LatDir,GPS.LongDeg,GPS.LongMin,GPS.Longmmmm,GPS.LongDir,GPS.SignHMSL,GPS.HMSL); - // au max 5 ms - fprintf(Fs_Log,Txt_Log); - //------------------ - ET_AutoMat_DataLog++; - break; - case ET_02: - case ET_03: - case ET_04: - case ET_05: - case ET_06: - case ET_07: - case ET_08: - case ET_09: - case ET_10: - // au max 100us (0.1ms) - sprintf(Txt_Log,"PDV;%lu;%5d;%5d;%5d;%5d\r\n",TIMER_10ms,CAP,ALT,TAS,TEMPRE); - // au max 5000 us (5ms) - fprintf(Fs_Log,Txt_Log); - break; - - default: break ; - } -} -//------------------------------------------ Sansors -void AutoMat_ALT_EAGLE_V4(){ - static char L_i2c_Data[2],error; - switch (ET_AutoMat_ALT) { - case ET_01 : - L_i2c_Data[0] = 0x07; // Send "register number" command to sensor - error = _I2C.write(Add_Sensor_ALT_EG4, L_i2c_Data, 1,true); // Send command string - if (error==0) ET_AutoMat_ALT = ET_02; - break; - case ET_02 : - error = _I2C.read(Add_Sensor_ALT_EG4, L_i2c_Data, 2, true); - if (error==0) { - ALT = *((unsigned short*)L_i2c_Data)&0xffff; //altitude en décimètre - ALT = ALT-3000; - } - ET_AutoMat_ALT = ET_01; - break; - default : break; +#ifdef EN_AutoMat_DataLog +void AutoMat_DataLog() +{ + static char ET_Sub_AutoMat = ET_00; + switch (ET_AutoMat_DataLog) { + + case ET_01: + LedLog=!LedLog; + //-------------- + // au max 100us (0.1ms) + sprintf(Txt_Log,"%lu;GPS;%1u;%2u:%2u:%2u;%10ld;%10ld;%ld;",TIMER_10ms,GPS.Qual,GPS.hh,GPS.mm,GPS.ss,GPS.LatDeg,GPS.LonDeg,GPS.HMSL); + // au max 5000 us (5ms) + fprintf(Fs_Log,Txt_Log); + // 100us + sprintf(Txt_Log,"P;%5d;%5d;%5d;%5d\r\n",CRS,ALT,SPD,TEM); + // au max 5 ms + fprintf(Fs_Log,Txt_Log); + //------------------ + ET_Sub_AutoMat = ET_01; + ET_AutoMat_DataLog = ET_02; + break; + case ET_02: + // au max 100us (0.1ms) + sprintf(Txt_Log,"%lu;;;;;;;",TIMER_10ms); + // au max 5000 us (5ms) + fprintf(Fs_Log,Txt_Log); + // au max 100us (0.1ms) + sprintf(Txt_Log,"P;%5d;%5d;%5d;%5d\r\n",CRS,ALT,SPD,TEM); + // au max 5000 us (5ms) + fprintf(Fs_Log,Txt_Log); + ET_Sub_AutoMat++; + if(ET_Sub_AutoMat>=ET_10) ET_AutoMat_DataLog = ET_00; + break; + + default: break ; } -} - -void AutoMat_TAS_EAGLE_V4(){ - static char L_i2c_Data[2],error; - switch (ET_AutoMat_TAS) { - case ET_01 : - L_i2c_Data[0] = 0x07; // Send "register number" command to sensor - error = _I2C.write(Add_Sensor_TAS_EG4, L_i2c_Data, 1,true); // Send command string - if (error==0) ET_AutoMat_TAS = ET_02; - break; +} +#endif +//------------------------------------------ Sansors +void AutoMat_ALT_EAGLE_V4() +{ + static char L_i2c_Data[2],LIndex,Lerror; + switch (ET_AutoMat_ALT) { + case ET_01 : + L_i2c_Data[0] = 0x07; // Send "register number" command to sensor + Lerror = _I2C.write(Add_Sensor_ALT_EG4, L_i2c_Data, 1,true); // Send command string + if (Lerror==0) ET_AutoMat_ALT = ET_02; + LIndex = 1; + break; + case ET_02 : - error = _I2C.read(Add_Sensor_TAS_EG4, L_i2c_Data, 2, true); - if (error==0) { - TAS = *((unsigned short*)L_i2c_Data)&0xffff; //altitude en décimètre - TAS = sqrt((float)(TAS-offset_TAS)*5.87755102); - } - ET_AutoMat_TAS = ET_01; - break; - default : break; + LIndex++; + if(LIndex>=Wait_Time1_ms) ET_AutoMat_ALT = ET_03; + break; + + case ET_03 : + Lerror = _I2C.read(Add_Sensor_ALT_EG4, L_i2c_Data, 2, true); + if (Lerror==0) { + ALT = *((unsigned short*)L_i2c_Data)&0xffff; //altitude en décimètre + ALT = ALT-3000; + } + ET_AutoMat_ALT = ET_01; + break; + default : break; } -} -void AutoMat_CAP_HMC(){ - static char L_i2c_Data[2],error; +} + +void AutoMat_TAS_EAGLE_V4() +{ + static char L_i2c_Data[2],LIndex,Lerror; + unsigned short SPD_short; + float SPD_float; + switch (ET_AutoMat_TAS) { + case ET_01 : + L_i2c_Data[0] = 0x07; // Send "register number" command to sensor + Lerror = _I2C.write(Add_Sensor_TAS_EG4, L_i2c_Data, 1,true); // Send command string + if (Lerror==0) ET_AutoMat_TAS = ET_02; + LIndex = 1; + break; + + case ET_02 : + LIndex++; + if(LIndex>=Wait_Time1_ms) ET_AutoMat_TAS = ET_03; + break; + + case ET_03 : + Lerror = _I2C.read(Add_Sensor_TAS_EG4, L_i2c_Data, 2, true); + if (Lerror==0) { + SPD_short = *((unsigned short*)L_i2c_Data)&0xffff; + SPD_float = 10*sqrt((float)(SPD_short-Offset_SPD)*5.87755102); + SPD = 10*SPD_float; // mph*10 + } + ET_AutoMat_TAS = ET_01; + break; + default : + break; + } +} +void AutoMat_CAP_HMC() +{ + static char L_i2c_Data[2],LIndex,Lerror; switch (ET_AutoMat_CAP) { - case ET_01 : - L_i2c_Data[0] = 0x07; // Send "register number" command to sensor - error = _I2C.write(Add_Sensor_CAP_HMC, L_i2c_Data, 1,true); // Send command string - if (error==0) ET_AutoMat_CAP = ET_02; - break; + case ET_01 : + L_i2c_Data[0] = 0x07; // Send "register number" command to sensor + Lerror = _I2C.write(Add_Sensor_CAP_HMC, L_i2c_Data, 1,true); // Send command string + if (Lerror==0) ET_AutoMat_CAP = ET_02; + LIndex = 1; + break; + case ET_02 : - error = _I2C.read(Add_Sensor_CAP_HMC , L_i2c_Data, 2, true); - if (error==0) { - CAP = *((unsigned short*)L_i2c_Data)&0xffff; //altitude en décimètre - } - ET_AutoMat_CAP = ET_01; - break; - default : break; + LIndex++; + if(LIndex>=Wait_Time1_ms) ET_AutoMat_CAP = ET_03; + break; + + case ET_03 : + Lerror = _I2C.read(Add_Sensor_CAP_HMC , L_i2c_Data, 2, true); + if (Lerror==0) { + CRS = *((unsigned short*)L_i2c_Data)&0xffff; //Cap en deg*10 + } + ET_AutoMat_CAP = ET_01; + break; + default : + break; } -} -//------------------- -void Sansors_Init(){ - char L_i2c_Data[3]; - //------------ init Compass HMC //Continuous mode, periodic set/reset, 20Hz measurement rate. - L_i2c_Data[0] = HMC6352_CONTINUOUS; - L_i2c_Data[1] = 0x01; - L_i2c_Data[2] = 20; - _I2C.write(Add_Sensor_CAP_HMC,L_i2c_Data,3); // Send command - //---------------------------- - wait_ms(1); //attendre 1mS - //------------- Get Offset TAS - L_i2c_Data[0] = 0x01; // Send "read data" command to sensor - _I2C.write(Add_Sensor_TAS_EG4,L_i2c_Data,1); // Send command string - wait_ms(1); //attendre 400µS avant de relancer - _I2C.read(Add_Sensor_TAS_EG4,L_i2c_Data, 2); - offset_TAS = *((unsigned short*)L_i2c_Data)&0xffff; // Altitude en décimètre } -void Irq05ms(){ -static unsigned char L_Flag_Timer=0, LTIMER005ms=0,LTIMER010ms=0; - LTIMER005ms++; - L_Flag_Timer = 1; - //----------------------------- - if(LTIMER005ms >= 2){ - //----------------- - TIMER_10ms = TIMER_10ms+1; - LTIMER005ms = 0; - LTIMER010ms++; - L_Flag_Timer = 2; - //----------------- - if(LTIMER010ms >= 10){ - LTIMER010ms = 0; - L_Flag_Timer = 3; - } - //----------------- - } - - AutoMat_ALT_EAGLE_V4(); - AutoMat_TAS_EAGLE_V4(); - AutoMat_CAP_HMC(); - - if (Flag_Timer != 0xFF) Flag_Timer = L_Flag_Timer; - //----------------------------- - } - -int main() { +void AutoMat_TEM_LM75B() +{ + static char L_i2c_Data[2],LIndex,Lerror; + switch (ET_AutoMat_TEM) { + case ET_01 : + L_i2c_Data[0] = 0x07; // Send "register number" command to sensor + Lerror = _I2C.write(Add_Sensor_TEM_LM75B, L_i2c_Data, 1,true); // Send command string + if (Lerror==0) ET_AutoMat_TEM = ET_02; + LIndex = 1; + break; + + case ET_02 : + LIndex++; + if(LIndex>=Wait_Time1_ms) ET_AutoMat_TEM = ET_03; + break; + + case ET_03 : + Lerror = _I2C.read(Add_Sensor_TEM_LM75B, L_i2c_Data, 2, true); + if (Lerror==0) { + // CRS = *((unsigned short*)L_i2c_Data)&0xffff; //Cap en deg*10 + } + ET_AutoMat_TEM = ET_01; + break; + default : + break; + } +} +//----------------- LCD ------------ +void AutoMat_LCD_Ext() +{ + static char Lerror; + switch (ET_AutoMat_LCD) { + case ET_01 : + Lerror = _I2C.write(Add_LCD_Ext, NULL, 0,true); + if (Lerror==0) ET_AutoMat_LCD = ET_02; + break; + case ET_02 : + // Code ici + ET_AutoMat_LCD = ET_01; + break; + default : + break; + } +} +//--------------------------------- + +void Sansors_Init() +{ + char L_i2c_Data[3]; + //------------ init Compass HMC //Continuous mode, periodic set/reset, 20Hz measurement rate. + L_i2c_Data[0] = HMC6352_CONTINUOUS; + L_i2c_Data[1] = 0x01; + L_i2c_Data[2] = 20; + _I2C.write(Add_Sensor_CAP_HMC,L_i2c_Data,3); // Send command + //---------------------------- + wait_ms(1); //attendre 1mS + //------------- Get Offset TAS + L_i2c_Data[0] = 0x01; // Send "read data" command to sensor + _I2C.write(Add_Sensor_TAS_EG4,L_i2c_Data,1); // Send command string + wait_ms(1); //attendre 400µS avant de relancer + _I2C.read(Add_Sensor_TAS_EG4,L_i2c_Data, 2); + Offset_SPD = *((unsigned short*)L_i2c_Data)&0xffff; // Altitude en décimètre +} + +void Irq01ms() +{ + static unsigned char LFlag_Timer=0, LTIMER001ms=0,LTIMER010ms=0; + LTIMER001ms++; + LFlag_Timer = 1; + //----------------------------- + if(LTIMER001ms >= 10) { + //----------------- + LTIMER001ms = 0; + LFlag_Timer = 3; + LTIMER010ms = LTIMER010ms+1; + //----------------- + if(LTIMER010ms >= 10) { + LTIMER010ms = 0; + LFlag_Timer = 7; + } + //----------------- + TIMER_10ms = TIMER_10ms+1; + } + AutoMat_ALT_EAGLE_V4(); + AutoMat_TAS_EAGLE_V4(); + AutoMat_CAP_HMC(); + AutoMat_TEM_LM75B();// temperateur LM75B - CAP = 0; - TAS = 0; - ALT = 0; - LedError = 0; - //-------------------- - _I2C.frequency(100000); - _ComGPS.baud(38400); //GPS V4 EAGLE - _ComGPS.attach(&AutoMat_GPS,Serial::RxIrq); // defini une interruption chaque foix que le recepteur GPS envoi un charactere - _ComXbee.baud(38400); - RSTXbee=0; - wait(0.5); - RSTXbee=1; - Sansors_Init(); - //-------------------- - //-------------- File Creat RGPSLogX.csv and DataLogX.csv X=FileIndex - FileIndex = 5; - //-------------------- - sprintf(DataLogFileName,"/USB/DataLog%lu.csv",FileIndex); - Fs_Log = fopen(DataLogFileName, "w");//ajouter un nouveau fichier et écraser l'ancien - //-------------------- Verification de la creations des fichers - if(Fs_Log==NULL) goto LabError; - fprintf(Fs_Log,"LogData\r\n"); - fprintf(Fs_Log,"GPS;TIMER1;Qual;Heur;LatD;LatMin;LatDir;LongD;LongMin;LongDir;HMSL\r\n"); - fprintf(Fs_Log,"PDV;TIMER1;CAP;ALT;TAS;Tem\r\n"); - //-------------------- - // Active les Automat - ET_AutoMat_ALT = ET_01; - ET_AutoMat_TAS = ET_01; - ET_AutoMat_CAP = ET_01; - _Ticker5ms.attach_us(&Irq05ms,5000); - // la variable un nom de 1ms mais on fait ca sur 5ms ce n'est pas cohérent !!!!!!! - // Samir - //-------------------- - CAP = 9991; - ALT = 9992; - TAS = 9993; - TEMPRE = 9994; - TimeBtpress=0; - while(TimeBtpress<100){ + if (Flag_Timer != 0xFF) Flag_Timer = LFlag_Timer; + //----------------------------- +} + +int main() +{ + + CRS = 0; + SPD = 0; + ALT = 0; + LedError = 0; + //-------------------- + _I2C.frequency(100000); + _ComGPS.baud(38400); //GPS V4 EAGLE + _ComGPS.attach(&AutoMat_GPS,Serial::RxIrq); // defini une interruption chaque foix que le recepteur GPS envoi un charactere + _ComXbee.baud(38400); + RSTXbee=0; + wait(0.5); + RSTXbee=1; + Sansors_Init(); + //-------------------- + //-------------- File Creat RGPSLogX.csv and DataLogX.csv X=FileIndex +#ifdef EN_AutoMat_DataLog + FileIndex = 0; +Started: + FileIndex++; + + //-------------------- + sprintf(DataLogFileName,"/USB/DataLog%4lu.csv",FileIndex); + Fs_Log = fopen(DataLogFileName, "r");//ajouter un nouveau fichier et écraser l'ancien + if (Fs_Log!=NULL) goto Started; + + Fs_Log = fopen(DataLogFileName, "w");//ajouter un nouveau fichier et écraser l'ancien + //-------------------- Verification de la creations des fichers + if(Fs_Log==NULL) goto LabError; + fprintf(Fs_Log,"LogData\r\n"); + fprintf(Fs_Log,"TIMER;GPS;Qual;Heur;LatD;LongD;HMSL;"); + fprintf(Fs_Log,"PDV;CRS;ALT;SPD;TEM\r\n"); +#endif + //-------------------- + // Active les Automat + ET_AutoMat_ALT = ET_01; + ET_AutoMat_TAS = ET_01; + ET_AutoMat_CAP = ET_01; + ET_AutoMat_TEM = ET_01; + ET_AutoMat_LCD = ET_01; + _Ticker1ms.attach_us(&Irq01ms,Irq_Time_us); + // la variable un nom de 1ms mais on fait ca sur 5ms ce n'est pas cohérent !!!!!!! + // Samir + //-------------------- + CRS = 9991;// initialisation + ALT = 9992;// initialisation + SPD = 9993;// initialisation + TEM = 9994;// initialisation + Flag_Timer = 0; + //------------------- + TimeBtpress=0; + while(TimeBtpress<100) { // Boutton pour pouvoir controler le debut de l'enregistrement if(boutonStart == 1)TimeBtpress++; - if(boutonStart == 0)TimeBtpress=0; - wait(0.005); - } - //while(boutonStart==0); // Boutton pour pouvoir controler le debut de l'enregistrement - Flag_Timer = 0; - TimeBtpress=0; - while(boutonEnd==0){ // Boutton pour pouvoir controler la fin de l'enregistrement - - switch (Flag_Timer) { + else TimeBtpress=0; + wait_ms(10); + } + //------------------- + TimeBtpress=0; + while(TimeBtpress<0xFFFF) { + + switch (Flag_Timer) { - case 0x01: + case 0x01:// 05 ms + Flag_Timer = 0; + // Boutton pour pouvoir controler la fin de l'enregistrement + if(boutonEnd == 1)TimeBtpress++; + else TimeBtpress=0; + //------------------ + break; + case 0x03:// 10 ms + Flag_Timer = 0xFF; + #ifdef EN_AutoMat_DataLog + AutoMat_DataLog(); + #endif + AutoMat_Xbee_Tx(); Flag_Timer = 0; break; - case 0x02: - Flag_Timer = 0xFF; - AutoMat_DataLog(); - AutoMat_Xbee_Tx(); + case 0x07:// 100 ms + Flag_Timer = 0xFF; + + GPS = OldGPS; + OldTIMER_10ms = TIMER_10ms; + OldALT = ALT; + OldSPD = SPD; + OldCRS = CRS; + OldTEM = TEM; + + HK_ALT = OldALT/10.0; + HK_SPD = OldSPD/10.0; + HK_CRS = OldCRS/10.0; - Flag_Timer = 0; - break; - case 0x03: - Flag_Timer = 0xFF; - - GPS = GpsData; - OldALT = ALT; - OldTAS = TAS; - OldCAP = CAP; - OldTEMPRE = TEMPRE; + ET_AutoMat_Xbee_Tx = ET_01; + ET_AutoMat_DataLog = ET_01; - ET_AutoMat_Xbee_Tx = ET_01; - ET_AutoMat_DataLog = ET_01; + //------------------ vérification si le Bt de fin est press pendent un Dt=100 ms + if(TimeBtpress>100) { + TimeBtpress = 0xFFFF; + ET_AutoMat_Xbee_Tx = ET_00; + ET_AutoMat_DataLog = ET_00; + } + //------------------ + #ifdef EN_AutoMat_DataLog AutoMat_DataLog(); - AutoMat_Xbee_Tx(); - + #endif + AutoMat_Xbee_Tx(); + Flag_Timer = 0x00; break; - - default: break; - }// fin switch - } - _Ticker5ms.detach(); - _ComGPS.attach(NULL,Serial::RxIrq); - LedXbee = 0; - LedGPS = 0; - LedLog = 1; - fclose(Fs_Log); - wait(1); - LedLog = 0; - while(1){ + + default: + break; + }// fin switch + }// fin while + _Ticker1ms.detach(); // ticker detach + _ComGPS.attach(NULL,Serial::RxIrq); // detach Com GPS + LedXbee = 0; + LedGPS = 0; +#ifdef EN_AutoMat_DataLog + LedLog = 1; + fprintf(Fs_Log,"END\r\n"); + fclose(Fs_Log); + wait(1); + LedLog = 0; +#endif + while(1) { LedError=!LedError; wait(0.5); - } + } //---------------- -LabError: +#ifdef EN_AutoMat_DataLog +LabError: LedError=1; +#endif //---------------- }
diff -r 05a20e3e3179 -r 197b9fed6092 Define.h --- a/Define.h Tue Apr 21 10:16:20 2015 +0000 +++ b/Define.h Thu Apr 30 12:24:33 2015 +0000 @@ -1,6 +1,13 @@ -#define Add_Sensor_CAP_HMC 0x0042 -#define Add_Sensor_TAS_EG4 0x00EA -#define Add_Sensor_ALT_EG4 0x00EC +#define EN_AutoMat_DataLog +#define EN_AutoMat_GPS +#define EN_AutoMat_Xbee +#define EN_AutoMat_Hid_PC +//----------------------------- +#define Add_Sensor_CAP_HMC 0x42 +#define Add_Sensor_TAS_EG4 0xEA +#define Add_Sensor_ALT_EG4 0xEC +#define Add_Sensor_TEM_LM75B 0x01 +#define Add_LCD_Ext 0x02 #define Cmd_Sensor_CAP 0x41 #define Cmd_Sensor_TAS 0x07 @@ -27,15 +34,25 @@ #define RMC 2 #define NData_GPS_Max 100 //----------------------------- +#define Irq_Time_us 1000 +#define Wait_Time1_ms 5 +unsigned char MsgGPSRx[100]; + unsigned char ET_AutoMat_GPS = ET_00; unsigned char ET_AutoMat_Xbee_Tx = ET_00; unsigned char ET_AutoMat_DataLog = ET_00; unsigned char ET_AutoMat_ALT = ET_00; unsigned char ET_AutoMat_TAS = ET_00; unsigned char ET_AutoMat_CAP = ET_00; +unsigned char ET_AutoMat_TEM = ET_00; +unsigned char ET_AutoMat_LCD = ET_00; -unsigned int offset_TAS,OldTimer_10ms; -unsigned int CAP,TAS,ALT,TEMPRE; -unsigned int OldCAP,OldTAS,OldALT,OldTEMPRE; +char HK_MSG_Tx[100]; +float HK_RLL,HK_PCH,HK_CRS,HK_SPD,HK_ALT; -unsigned char Flag_Timer = 0; \ No newline at end of file +unsigned int Offset_SPD,OldTIMER_10ms; +unsigned int CRS,SPD,ALT,TEM; +unsigned int OldCRS,OldSPD,OldALT,OldTEM; + +unsigned char Flag_Timer = 0; +
diff -r 05a20e3e3179 -r 197b9fed6092 _GPS/DecMsgGPGGA.h --- a/_GPS/DecMsgGPGGA.h Tue Apr 21 10:16:20 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -void DecodageGPGGA(unsigned char Ldata) //------------------------------------------------------- -{ - static unsigned short CommaNbr; - static unsigned short ii,jj; - GpsData.GGA_Valid = 0; - CommaNbr = 0; - for(ii=0;ii<Ldata;ii++) - { - if(_MsgGPSRx[ii]==',') - { - _PosV[CommaNbr] = ii; - CommaNbr++; - } - } - if(CommaNbr<11)goto LabFin; //Vérification de la longueur du message GPGGA - //par le nombre des vergules -//UTC of position - //extraction du temps UTC - jj=0;//Identification de la position de la première virgule dans le MsgGPS - _DL=Get_Length(jj); - if((_DL<9)||(_DL>10)) goto LabFin;//Vérification de la longueur du message de temps - Set_Data(jj); - Validation_StrToFloat(_DL); - if(_Npt !=1) goto LabFin; - if(_Pospt!=6) goto LabFin; - //Vérification de Time "hhmmss" - _hh=10*(_Data[0]-48)+(_Data[1]-48);//Extraction de l'heur - _mm=10*(_Data[2]-48)+(_Data[3]-48);//Extraction des minutes - _ss=10*(_Data[4]-48)+(_Data[5]-48);//Extraction des secondes - if((_hh>24)||(_mm>59)||(_ss>59))goto LabFin; -//Latitude of position - //extraction du Lattitude - jj=1;//Identification de la position de la deuxième virgule dans le MsgGPS - _DL=Get_Length(jj); - if((_DL<9)||(_DL>10)) goto LabFin;//Vérification de la longueur du message de lattitude - Set_Data(jj); - Validation_StrToFloat(_DL); - if(_Npt !=1) goto LabFin; - if(_Pospt!=4) goto LabFin; - - //Vérification du Lattitude "LatDegLatMin,LatMin1LatMin2" - _LatDeg =10*(_Data[0]-48)+(_Data[1]-48);//Extraction des degrés du lattitude - _LatMin =10*(_Data[2]-48)+(_Data[3]-48);//Extraction des minutes du lattitude - _LatMin1=10*(_Data[5]-48)+(_Data[6]-48);//Extraction des deux chiffres minutes après la virgule du lattitude - _LatMin2=10*(_Data[7]-48)+(_Data[8]-48);//Extraction des deux chiffres minutes après la virgule du lattitude - if((_LatDeg>90)||(_LatMin>59)||(_LatMin1>99)||(_LatMin2>99))goto LabFin; - //Vérification de la direction du Lattitude LatDir(N ou S) - jj=2;//Identification de la position de la troisième virgule dans le MsgGPS - _DL=Get_Length(jj); - if(_DL!=1) goto LabFin;//Vérification de la longueur du message de direction de latittude - Set_Data(jj); - _LatDir=_Data[0];//Extraction de le direction du latitude - if((_LatDir!='N')&&(_LatDir!='S'))goto LabFin; - // 01 byte - //Longitude of position - //extraction de la Longitude - jj=3;//Identification de la position de la quatrième virgule dans le MsgGPS - _DL=Get_Length(jj); - if((_DL<10)||(_DL>11)) goto LabFin;//Vérification de la longueur du message de la longitude - Set_Data(jj); - Validation_StrToFloat(_DL); - if(_Npt !=1) goto LabFin; - if(_Pospt!=5) goto LabFin; - //Vérification du La Longitude "LongDegLongMin,LongMin1LongMin2" - _LongDeg =100*(_Data[0]-48)+10*(_Data[1]-48)+(_Data[2]-48);//Extraction des degrés de la longitude - _LongMin =10*(_Data[3]-48)+(_Data[4]-48);//Extraction des minutes de la longitude - _LongMin1=10*(_Data[6]-48)+(_Data[7]-48);//Extraction des deux chiffres minutes après la virgule de la longitude - _LongMin2=10*(_Data[8]-48)+(_Data[9]-48);//Extraction des deux chiffres minutes après la virgule de la longitude - if((_LongDeg>180)||(_LongMin>59)||(_LongMin1>99)||(_LongMin2>99))goto LabFin; - //Vérification de la direction du Longitude LonDir(E ou W) - jj=4;//Identification de la position de la cinquième virgule dans le MsgGPS - _DL=Get_Length(jj); - if(_DL!=1) goto LabFin;//Vérification de la longueur du message de direction de la longitude - Set_Data(jj); - _LongDir=_Data[0];//Extraction de le direction de la longitude - if((_LongDir!='E')&&(_LongDir!='W'))goto LabFin; -//GPS Quality indicator - jj=5;//Identification de la position de la sixième virgule dans le MsgGPS - _DL=Get_Length(jj); - if(_DL!=1) goto LabFin;//Vérification de la longueur du message de l'ndicateur de qualité GPS - Set_Data(jj); - Validation_StrToFloat(_DL); - if(_Npt !=0) goto LabFin; - if(_Pospt!=0) goto LabFin; - _Qual=_Data[0]-48;//Extraction de l'information de la qualité du MsgGPs - if((_Qual<1)||(_Qual>2))goto LabFin; -//Antenna altitude above mean-sea-level "SignHMSLHMSL_HHMSL_L,HMSL_1HMSL_2" . - jj=8;//Identification de la position de la neuvième virgule dans le MsgGPS - _DL=Get_Length(jj); - if(_DL<3) goto LabFin;//Vérification de la longueur du message de l'altitude - Set_Data(jj); - _SignHMSL='+'; - if(_Data[0]=='-') - { - _DL=_DL-1; - _SignHMSL='-'; - for(ii=0;ii<_DL;ii++) _Data[ii]=_Data[ii+1]; - } - Validation_StrToFloat(_DL); - if(_Npt !=1) goto LabFin; - if(_Pospt ==0) goto LabFin; - switch (_Pospt) - { - case 1: {_HMSL_L = (_Data[0]-48) ; _HMSL_H = 0; break;} - case 2: {_HMSL_L = (_Data[1]-48)+10*(_Data[0]-48); _HMSL_H = 0; break;} - case 3: {_HMSL_L = (_Data[2]-48)+10*(_Data[1]-48); _HMSL_H = (_Data[0]-48); break;} - case 4: {_HMSL_L = (_Data[3]-48)+10*(_Data[2]-48); _HMSL_H = (_Data[1]-48)+10*(_Data[0]-48); break;} - default : break; - } - _DL=_DL-_Pospt-1; //La longure de chiffre après la virgule - switch (_DL) - { - case 1: {_HMSL_1 = (_Data[_Pospt+1]-48) ; _HMSL_2 = 0; break;} - case 2: {_HMSL_1 = (_Data[_Pospt+2]-48)+10*(_Data[_Pospt+1]-48); _HMSL_2 = 0; break;} - case 3: {_HMSL_1 = (_Data[_Pospt+2]-48)+10*(_Data[_Pospt+1]-48); _HMSL_2 = _Data[_Pospt+3]-48; break;} - case 4: {_HMSL_1 = (_Data[_Pospt+2]-48)+10*(_Data[_Pospt+1]-48); _HMSL_2 = 10*(_Data[_Pospt+3]-48)+_Data[_Pospt+4]-48; break;} - default : break; - } - //Antenna height unit - jj=9;//Identification de la position de la dixième virgule dans le MsgGPS - _DL=Get_Length(jj); - if(_DL!=1) goto LabFin;//Vérification de la longueur du message de l'unité de la hauteur - Set_Data(jj); - _HUnite=_Data[0];//Extraction de l'unité de la hauteur - if((_HMSL_H>35)||(_HUnite!='M'))goto LabFin; - - GpsData.GGA_Valid = 1; - GpsData.hh = _hh; - GpsData.mm = _mm; - GpsData.ss = _ss; - //---------------------------------------------------------------------------- - GpsData.LatDeg = _LatDeg; - GpsData.LatMin = _LatMin; - GpsData.Latmmmm = _LatMin1*100+_LatMin2; - GpsData.LatDir = _LatDir; - //----------------------------------------------------------------------------- - GpsData.LongDeg = _LongDeg; - GpsData.LongMin = _LongMin; - GpsData.Longmmmm = _LongMin1*100+_LongMin2; - GpsData.LongDir = _LongDir; - //----------------------------------------------------------------------------- - GpsData.Qual = _Qual; - //----------------------------------------------------------------------------- - GpsData.HMSL = _HMSL_H*100+_HMSL_L; - GpsData.SignHMSL = _SignHMSL; - GpsData.HUnite = _HUnite; -LabFin: -asm{NOP} -} \ No newline at end of file
diff -r 05a20e3e3179 -r 197b9fed6092 _GPS/Dec_GPS.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_GPS/Dec_GPS.cpp Thu Apr 30 12:24:33 2015 +0000 @@ -0,0 +1,195 @@ +#include "Dec_GPS.h" + + unsigned char _DL,_Npt,_Pospt; + unsigned char _Data[16],_PosV[16]; + unsigned char _MsgGPSRx[100]; + +//------------------------------------------------------------------------------ +//Calcul de la longueur des sous message +unsigned char Get_Length(unsigned short index) + { + static unsigned char LongData; + LongData=_PosV[index+1]-_PosV[index]-1; + return LongData; + } +//Décomposition du message en Sub message +void Set_Data(unsigned char index){ + static unsigned char ii,jj; + static unsigned char Start,End; + ii=0; + Start = _PosV[index]+1; + End = _PosV[index+1]; + + for(jj=Start;jj<End;jj++){ + _Data[ii] = _MsgGPSRx[jj]; + ii++; + } + } +//Vérification des sub message +void Validation_StrToFloat(unsigned char LongData) + { + unsigned char ii; + _Npt = 0; + _Pospt = 0; + for(ii=0;ii<LongData;ii++){ + if(_Data[ii]=='.') + { + _Npt++; + _Pospt=ii; + } + else if((_Data[ii]<48)||(_Data[ii]>57)) _Npt=_Npt+2; + } + } + +void DecodageGPGGA(unsigned char *_MsgGPS_Rx,unsigned char Ldata, StructGPS *GpsData) +{ + static unsigned char CommaNbr; + static unsigned char ii,jj; + StructGPS L_GpsData; + + unsigned char _hh,_mm,_ss; + unsigned char _LatDeg,_LatMin,_LatMin1,_LatMin2,_LatDir; + unsigned char _LonDeg,_LonMin,_LonMin1,_LonMin2,_LonDir; + unsigned char _Qual; + unsigned char _HMSL_L,_HMSL_H; + char _SignHMSL,_HUnite; + float _fLatGpsDD,_fLonGpsDD; + + ii=0; + while(ii<=Ldata){ + _MsgGPSRx[ii]=*_MsgGPS_Rx; + _MsgGPS_Rx++; + ii++; + } + L_GpsData.GGA_Valid = 0; + CommaNbr = 0; + for(ii=0;ii<Ldata;ii++) { + if(_MsgGPSRx[ii]==',') { + _PosV[CommaNbr] = ii; + CommaNbr++; + } + } + if(CommaNbr<11)goto LabFin; //Vérification de la longueur du message GPGGA + //par le nombre des vergules +//UTC of position + //extraction du temps UTC + jj=0;//Identification de la position de la première virgule dans le MsgGPS + _DL=Get_Length(jj); + if((_DL<9)||(_DL>10)) goto LabFin;//Vérification de la longueur du message de temps + Set_Data(jj); + Validation_StrToFloat(_DL); + if(_Npt !=1) goto LabFin; + if(_Pospt!=6) goto LabFin; + //Vérification de Time "hhmmss" + _hh=10*(_Data[0]-48)+(_Data[1]-48);//Extraction de l'heur + _mm=10*(_Data[2]-48)+(_Data[3]-48);//Extraction des minutes + _ss=10*(_Data[4]-48)+(_Data[5]-48);//Extraction des secondes + if((_hh>24)||(_mm>59)||(_ss>59))goto LabFin; +//Latitude of position + //extraction du Lattitude + jj=1;//Identification de la position de la deuxième virgule dans le MsgGPS + _DL=Get_Length(jj); + if((_DL<9)||(_DL>10)) goto LabFin;//Vérification de la longueur du message de lattitude + Set_Data(jj); + Validation_StrToFloat(_DL); + if(_Npt !=1) goto LabFin; + if(_Pospt!=4) goto LabFin; + + //Vérification du Lattitude "LatDegLatMin,LatMin1LatMin2" + _LatDeg =10*(_Data[0]-48)+(_Data[1]-48);//Extraction des degrés du lattitude + _LatMin =10*(_Data[2]-48)+(_Data[3]-48);//Extraction des minutes du lattitude + _LatMin1=10*(_Data[5]-48)+(_Data[6]-48);//Extraction des deux chiffres minutes après la virgule du lattitude + _LatMin2=10*(_Data[7]-48)+(_Data[8]-48);//Extraction des deux chiffres minutes après la virgule du lattitude + if((_LatDeg>90)||(_LatMin>59)||(_LatMin1>99)||(_LatMin2>99))goto LabFin; + //Vérification de la direction du Lattitude LatDir(N ou S) + jj=2;//Identification de la position de la troisième virgule dans le MsgGPS + _DL=Get_Length(jj); + if(_DL!=1) goto LabFin;//Vérification de la longueur du message de direction de latittude + Set_Data(jj); + _LatDir=_Data[0];//Extraction de le direction du latitude + if((_LatDir!='N')&&(_LatDir!='S'))goto LabFin; + // 01 byte + //Longitude of position + //extraction de la Longitude + jj=3;//Identification de la position de la quatrième virgule dans le MsgGPS + _DL=Get_Length(jj); + if((_DL<10)||(_DL>11)) goto LabFin;//Vérification de la longueur du message de la longitude + Set_Data(jj); + Validation_StrToFloat(_DL); + if(_Npt !=1) goto LabFin; + if(_Pospt!=5) goto LabFin; + //Vérification du La Longitude "LongDegLongMin,LongMin1LongMin2" + _LonDeg =100*(_Data[0]-48)+10*(_Data[1]-48)+(_Data[2]-48);//Extraction des degrés de la longitude + _LonMin =10*(_Data[3]-48)+(_Data[4]-48);//Extraction des minutes de la longitude + _LonMin1=10*(_Data[6]-48)+(_Data[7]-48);//Extraction des deux chiffres minutes après la virgule de la longitude + _LonMin2=10*(_Data[8]-48)+(_Data[9]-48);//Extraction des deux chiffres minutes après la virgule de la longitude + if((_LonDeg>180)||(_LonMin>59)||(_LonMin1>99)||(_LonMin2>99))goto LabFin; + //Vérification de la direction du Longitude LonDir(E ou W) + jj=4;//Identification de la position de la cinquième virgule dans le MsgGPS + _DL=Get_Length(jj); + if(_DL!=1) goto LabFin;//Vérification de la longueur du message de direction de la longitude + Set_Data(jj); + _LonDir=_Data[0];//Extraction de le direction de la longitude + if((_LonDir!='E')&&(_LonDir!='W'))goto LabFin; +//GPS Quality indicator + jj=5;//Identification de la position de la sixième virgule dans le MsgGPS + _DL=Get_Length(jj); + if(_DL!=1) goto LabFin;//Vérification de la longueur du message de l'ndicateur de qualité GPS + Set_Data(jj); + Validation_StrToFloat(_DL); + if(_Npt !=0) goto LabFin; + if(_Pospt!=0) goto LabFin; + _Qual=_Data[0]-48;//Extraction de l'information de la qualité du MsgGPs + if((_Qual<1)||(_Qual>2))goto LabFin; +//Antenna altitude above mean-sea-level "SignHMSLHMSL_HHMSL_L,HMSL_1HMSL_2" . + jj=8;//Identification de la position de la neuvième virgule dans le MsgGPS + _DL=Get_Length(jj); + if(_DL<3) goto LabFin;//Vérification de la longueur du message de l'altitude + Set_Data(jj); + _SignHMSL='+'; + + if(_Data[0]=='-'){ + _DL=_DL-1; + _SignHMSL='-'; + for(ii=0;ii<_DL;ii++) _Data[ii]=_Data[ii+1]; + } + Validation_StrToFloat(_DL); + if(_Npt !=1) goto LabFin; + if(_Pospt ==0) goto LabFin; + + switch (_Pospt) { + case 1: {_HMSL_L = (_Data[0]-48) ; _HMSL_H = 0; break;} + case 2: {_HMSL_L = (_Data[1]-48)+10*(_Data[0]-48); _HMSL_H = 0; break;} + case 3: {_HMSL_L = (_Data[2]-48)+10*(_Data[1]-48); _HMSL_H = (_Data[0]-48); break;} + case 4: {_HMSL_L = (_Data[3]-48)+10*(_Data[2]-48); _HMSL_H = (_Data[1]-48)+10*(_Data[0]-48); break;} + default : break; + } + //Antenna height unit + jj=9; // Identification de la position de la dixième virgule dans le MsgGPS + _DL=Get_Length(jj); + if(_DL!=1) goto LabFin;//Vérification de la longueur du message de l'unité de la hauteur + Set_Data(jj); + _HUnite=_Data[0];//Extraction de l'unité de la hauteur + if((_HMSL_H>35)||(_HUnite!='M'))goto LabFin; + + L_GpsData.hh = _hh; + L_GpsData.mm = _mm; + L_GpsData.ss = _ss; + //---------------------------------------------------------------------------- + L_GpsData.LatDeg = _LatDeg; + //----------------------------------------------------------------------------- + _fLatGpsDD = 1000000.0*_LatDeg+100000.0*_LatMin/6.0+10.0*(_LatMin1*100+_LatMin2)/6.0; + _fLonGpsDD = 1000000.0*_LonDeg+100000.0*_LonMin/6.0+10.0*(_LonMin1*100+_LonMin2)/6.0; + + L_GpsData.LatDeg = (_fLatGpsDD);//*0.99998537); + L_GpsData.LonDeg = (_fLonGpsDD);//*0.99981997); + //----------------------------------------------------------------------------- + L_GpsData.Qual = _Qual; + //----------------------------------------------------------------------------- + L_GpsData.HMSL = _HMSL_H*100+_HMSL_L; + if (_SignHMSL=='-') L_GpsData.HMSL = -L_GpsData.HMSL; + L_GpsData.GGA_Valid = 1; + *GpsData=L_GpsData; +LabFin: +asm{NOP} +} \ No newline at end of file
diff -r 05a20e3e3179 -r 197b9fed6092 _GPS/Dec_GPS.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_GPS/Dec_GPS.h Thu Apr 30 12:24:33 2015 +0000 @@ -0,0 +1,26 @@ +#ifndef Dec_GPS_H + +#define Dec_GPS_H + +typedef struct { + unsigned char GGA_Valid; + unsigned char Qual; + unsigned char hh; + unsigned char mm; + unsigned char ss; + signed long LatDeg; + signed long LonDeg; + signed long HMSL; + +}StructGPS; + +unsigned char Get_Length(unsigned short index); +void Set_Data(unsigned char index); +void Validation_StrToFloat(unsigned char LongData); +void DecodageGPGGA(unsigned char *_MsgGPSRx,unsigned char Ldata,StructGPS *GpsData); + +#endif + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------
diff -r 05a20e3e3179 -r 197b9fed6092 _GPS/RecGPS.h --- a/_GPS/RecGPS.h Tue Apr 21 10:16:20 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -unsigned char _DL,_Npt,_Pospt; -unsigned char _hh,_mm,_ss; -unsigned char _LatDeg,_LatMin,_LatMin1,_LatMin2,_LatDir; -unsigned char _LongDeg,_LongMin,_LongMin1,_LongMin2,_LongDir; -unsigned char _Qual; -unsigned char _SignHMSL,_HMSL_L,_HMSL_H,_HMSL_1,_HMSL_2,_HUnite; -unsigned char _dd,_yy,_mn,_val; - -unsigned char _Data[16],_PosV[16],_MsgGPSRx[100]; - -// defini un structure -typedef struct { - unsigned char GGA_Valid; - unsigned char hh; - unsigned char mm; - unsigned char ss; - - unsigned char LatDeg; - unsigned char LatMin; - unsigned char LatMin1; - unsigned char LatMin2; - unsigned int Latmmmm; - unsigned char LatDir; - - unsigned char LongDeg; - unsigned char LongMin; - unsigned char LongMin1; - unsigned char LongMin2; - unsigned int Longmmmm; - unsigned char LongDir; - - unsigned char Qual; - - unsigned int HMSL; - unsigned char SignHMSL; - unsigned char HUnite; -}StructGPS; - -StructGPS GpsData; -//------------------------------------------------------------------------------ -//Calcul de la longueur des sous message -unsigned char Get_Length(unsigned short index) - { - static unsigned char LongData; - LongData=_PosV[index+1]-_PosV[index]-1; - return LongData; - } -//Décomposition du message en Sub message -void Set_Data(unsigned char index){ - static unsigned char ii,jj; - static unsigned char Start,End; - ii=0; - Start = _PosV[index]+1; - End = _PosV[index+1]; - - for(jj=Start;jj<End;jj++){ - _Data[ii] = _MsgGPSRx[jj]; - ii++; - } - } -//Vérification des sub message -void Validation_StrToFloat(unsigned char LongData) - { - unsigned char ii; - _Npt = 0; - _Pospt = 0; - for(ii=0;ii<LongData;ii++){ - if(_Data[ii]=='.') - { - _Npt++; - _Pospt=ii; - } - else if((_Data[ii]<48)||(_Data[ii]>57)) _Npt=_Npt+2; - } - } - -void DecodageGPGGA(unsigned char Ldata); - -//------------------------------------------------------------------------------ -#include "DecMsgGPGGA.h" // GPGGA -//------------------------------------------------------------------------------