Révision 708
Ajouté par megoutteno il y a presque 4 ans
main.c | ||
---|---|---|
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include "trame.h"
|
||
|
||
typedef struct lat_long;
|
||
struct lat_long
|
||
{
|
||
float latitude;
|
||
float longitude;
|
||
};
|
||
//Trames de tests ? modifier si n?cessaire.
|
||
char * trames[]= {"$GPGSV,3,2,10,15,03,077,,18,04,041,42,19,85,271,,20,08,214,*7C",
|
||
"$GPGSV,3,3,10,22,39,053,50,28,15,320,*7E",
|
||
... | ... | |
}
|
||
// compare la trame et le type.
|
||
|
||
int trame_cmp(char* trame,char* type)
|
||
int trame_cmp(char * trame,char * type)
|
||
{
|
||
int i = 0, a = 0;
|
||
for (i=0;i<5;i++)
|
||
... | ... | |
}
|
||
|
||
}
|
||
int decode_trame(char * trame,int pos)
|
||
|
||
|
||
|
||
int decode_trame(char * trame)
|
||
{
|
||
if (trame_cmp(trame,"$GPGGA"))
|
||
int cpt=66,i=0,j=0;
|
||
float a=0, b=0;
|
||
char lat[30],longi[30];
|
||
if (trame_cmp(trame,"GPGGA"))
|
||
{
|
||
latitude_longitude(trame);
|
||
/*while(trame[cpt]!='\0')
|
||
{
|
||
cpt++;
|
||
}*/
|
||
for(i=cpt-49;i<=cpt-41;i++)
|
||
{
|
||
lat[j]=trame[i];
|
||
j++;
|
||
}
|
||
j=0;
|
||
for(i=cpt-37;i<=cpt-28;i++)
|
||
{
|
||
longi[j]=trame[i];
|
||
j++;
|
||
}
|
||
a=conver_latitude(lat);
|
||
b=conver_longitude(longi);
|
||
printf("latitude = %f",a);
|
||
printf("longitude = %f",b);
|
||
return 1;
|
||
}
|
||
return trame;
|
||
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
... | ... | |
printf ("Erreur Test unitaire conver_latitude.\n");
|
||
exit(-1);
|
||
}
|
||
if (conver_longitude("7501.20000")<0.95*750.02 || conver_longitude("7501.20000")>1.05*750.02 ){
|
||
if (conver_longitude("00306.6036")<0.95*3.11006 || conver_longitude("00306.6036")>1.05*3.11006 ){
|
||
printf ("Erreur Test unitaire conver_longitude.\n");
|
||
exit(-1);
|
||
}
|
||
... | ... | |
if (latitude_longitude("7501.20000")<0.95*750.02 || latitude_longitude("7501.20000")>1.05*750.02 ){
|
||
printf ("Erreur Test unitaire latitude_longitude.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
decode_trame("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D");
|
||
|
||
}
|
||
|
Formats disponibles : Unified diff
Avancement sur la fonction decode_trame