Révision 355
Ajouté par Clement ROCHE il y a presque 3 ans
branch/ROCHE/sp4a12/main.c | ||
---|---|---|
"$GPVTG,99.4,T,,M,0.4,N,0.7,K*57",
|
||
"$GPZDA,141914.00,01,02,2006,00,00*69",
|
||
0};
|
||
typedef struct {
|
||
float latitude;
|
||
float longitude;
|
||
} Position ;
|
||
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
... | ... | |
|
||
}
|
||
|
||
void decode_trame(char * trame, Position * P) {
|
||
int n=17,cpt=0; //n=17 car le codage d'une latitude commence ? l'indice 17 ds la trame
|
||
char lat[10],lon[10];
|
||
do {
|
||
lat[cpt]=trame[n];
|
||
n++;
|
||
cpt++;
|
||
} while (trame[n]!=',');
|
||
cpt=0; //cpt qui balaye le char lat/long
|
||
n=29; //codage d'une longitude commence ? l'indice 29 ds la trame
|
||
do {
|
||
lon[cpt]=trame[n];
|
||
n++;
|
||
cpt++;
|
||
} while (trame[n]!=',');
|
||
|
||
(*P).latitude = decode_lat_long(lat); //ne pas mettre de chiffre cela na aps de sens
|
||
(*P).longitude = decode_lat_long(lon);
|
||
}
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
/*void tests_unitaires_trame_cmp(void){
|
||
if (5!=5){
|
||
... | ... | |
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPRMC suite chaine","GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
printf ("Erreur Testtest_decode_trame unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPRMC... ", "GPRMC" )!=1){
|
||
... | ... | |
}
|
||
|
||
}
|
||
|
||
|
||
void test_decode_trame(void) {
|
||
float a,b;
|
||
Position P1;
|
||
|
||
decode_trame("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D",&P1);
|
||
a= 3.110061 - P1.longitude;
|
||
b= 45.75 - P1.latitude;
|
||
if ((a*a > 0.000001) && (b*b > 0.000001)) {
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
|
||
decode_trame("$GPGGA,141917.00,4545.0726,N,00306.6039,E,1,05,3.4,499.6,M,,M,,*73",&P1);
|
||
a= 3.110066 - P1.longitude;
|
||
b= 45.751209 - P1.latitude;
|
||
if ((a*a > 0.000001) && (b*b > 0.000001)) {
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
|
||
decode_trame("$GPGGA,141918.00,4545.0968,N,00306.6034,E,1,05,3.4,498.8,M,,M,,*7A",&P1);
|
||
a= 3.110057 - P1.longitude;
|
||
b= 45.751614 - P1.latitude;
|
||
if ((a*a > 0.000001) && (b*b > 0.000001)) {
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
|
||
|
||
decode_trame("$GPGGA,141919.00,4545.1210,N,00306.6040,E,1,05,3.4,500.2,M,,M,,*77",&P1);
|
||
a= 3.110067 - P1.longitude;
|
||
b= 45.752018 - P1.latitude;
|
||
if ((a*a > 0.000001) && (b*b > 0.000001)) {
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
|
||
|
||
}
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
{
|
||
|
||
//tests_unitaires();
|
||
//test_decode_int();
|
||
//test_decode_nombre();
|
||
//test_decode_latitude();
|
||
//test_decode_longitude();
|
||
test_decode_lat_long();
|
||
//test_decode_lat_long();
|
||
test_decode_trame();
|
||
|
||
// Affichage des trames definies dans la table trames.
|
||
printf ("Trames de tests tableau trames:\n");
|
Formats disponibles : Unified diff
decode trame + test unitaire : ok