Révision 374
Ajouté par rademagalh il y a presque 4 ans
main.c | ||
---|---|---|
return res * fact;
|
||
}
|
||
|
||
typedef struct{
|
||
float latitude;
|
||
float longitude;
|
||
}Position;
|
||
|
||
Position decode_trame(char * ch)
|
||
{
|
||
Position pos;
|
||
int i,indice=0;
|
||
char longitude[10]="";
|
||
char latitude[10]="";
|
||
int compteur_de_virgule = 0;
|
||
if (trame_cmp(ch,"GPGGA")==0)
|
||
{
|
||
exit(-1);
|
||
}
|
||
else
|
||
{
|
||
|
||
do
|
||
{
|
||
if (ch[indice]==',')
|
||
{
|
||
compteur_de_virgule++;
|
||
}
|
||
|
||
if (compteur_de_virgule==2)
|
||
{
|
||
for (int i = 0; i < 9; i++)
|
||
{
|
||
latitude[i]=ch[indice+1];
|
||
indice++;
|
||
}
|
||
}
|
||
|
||
if (compteur_de_virgule==4)
|
||
{
|
||
for (int i = 0; i < 9; i++)
|
||
{
|
||
longitude[i]=ch[indice+1];
|
||
indice++;
|
||
}
|
||
break;
|
||
}
|
||
indice++;
|
||
} while (ch[indice]!='\0');
|
||
pos.latitude = conversionChaineFlottante(latitude);
|
||
pos.longitude = conversionChaineFlottante(longitude);
|
||
}
|
||
return pos;
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
... | ... | |
printf("Pas d'erreur fonction potentiellement valide ! \n");
|
||
}
|
||
}
|
||
// Ne pas modifier cette fonction
|
||
|
||
|
||
void test_decode_trame(){
|
||
printf("Test de la fonction test_decode_trame \n");
|
||
if (5!=5){
|
||
printf ("Erreur Test decode_trame basique. n?1\n");
|
||
exit(-1);
|
||
}
|
||
Position pos=(decode_trame(("$GPGGA,141925.00,4545.2410,N,00306.6046,E,1,05,3.4,501.4,M,,M,,*7D")));
|
||
printf("latitude en flottant = %.4f \n ",pos.latitude);
|
||
printf("longitude en flottant = %.4f \n ",pos.longitude);
|
||
if ((4545.2410/pos.latitude)>1.0)
|
||
{
|
||
printf ("Erreur Test decode_trame. n?2\n");
|
||
exit(-1);
|
||
}
|
||
if ((00306.6046/pos.longitude)<1.0)
|
||
{
|
||
printf ("Erreur Test decode_trame. n?3\n");
|
||
exit(-1);
|
||
}
|
||
else
|
||
{
|
||
printf("Pas d'erreur fonction potentiellement valide ! \n");
|
||
}
|
||
|
||
}
|
||
|
||
//Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
|
||
tests_unitaires();
|
||
test_decode_int();
|
||
test_decode_nombre();
|
||
test_conversionChaineFlottante();
|
||
test_conversionChaineFlottante();
|
||
test_decode_trame();
|
||
|
||
// Affichage des trames definies dans la table trames.
|
||
printf ("Trames de tests tableau trames:\n");
|
Formats disponibles : Unified diff
Ajout de la fonction decode_trame et test_decode_trame.
En utilisant la structure Position.