Révision 148
Ajouté par Erwan DESFRICHES DORIA il y a environ 3 ans
branch/DESFRICHES-DORIA/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};
|
||
|
||
|
||
int exposant(int n)
|
||
{
|
||
int i;
|
||
int expo = 1;
|
||
for(i=1; i<=n; i++)
|
||
expo = expo*10;
|
||
return(expo);
|
||
}
|
||
|
||
int decode_int(char c)
|
||
{
|
||
int valeur;
|
||
if((c>47)&&(c<=58))
|
||
valeur = c-48;
|
||
else
|
||
valeur = -1;
|
||
return(valeur);
|
||
}
|
||
int trame_cmp(char * trame, char * type)
|
||
{
|
||
int i = 0;
|
||
int ok;
|
||
do
|
||
{
|
||
if(trame[i]==type[i])
|
||
i++;
|
||
}
|
||
while((trame[i]==type[i])&&(trame[i]!='\0'));
|
||
if(trame[i]=='\0')
|
||
ok = 1;
|
||
else
|
||
ok = 0;
|
||
return(ok);
|
||
}
|
||
|
||
int decode_nombre(char * ch, int n)
|
||
{
|
||
int val = 0;
|
||
int incr=0;
|
||
int expo = 0;
|
||
int i;
|
||
for(i=0; i<n; i++)
|
||
{
|
||
incr = n-i;
|
||
expo = exposant(incr);
|
||
val = val + (decode_int(ch[i])*expo);
|
||
}
|
||
}
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
... | ... | |
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
/*if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
|
||
if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}*/
|
||
}
|
||
if (trame_cmp("$GPRMC suite chaine","GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPRMC...","GPGGA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$APRMC...","GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
||
... | ... | |
char *trame;
|
||
printf ("Trames de tests du fichier gps.log\n");
|
||
while ((trame = trame_suivante()))
|
||
traitement(trame);
|
||
traitement(trame);
|
||
int ch[3] = {1,2,3};
|
||
int n = 2;
|
||
decode_nombre(ch, n);
|
||
|
||
return 0;
|
||
}
|
Formats disponibles : Unified diff
J'ai écris les fonctions decode_int(); trame_cmp() et decode_nombre(). Je vais m'occuper de la fonction traitement()