Révision 143
Ajouté par Romain CHAMBELLON il y a environ 3 ans
branch/CHAMBELLON/sp4a12/main.c | ||
---|---|---|
int trame_cmp(char * trame, char * type)
|
||
{
|
||
int i = 0, j = 0, res = 1;
|
||
while(type[i] != '\0')
|
||
while(type[i] != '\0') // La boucle while s'execute tant que le char type n'a pas ?t? enti?rement lu
|
||
{
|
||
i++;
|
||
}
|
||
|
||
while(j<i)
|
||
{
|
||
if (trame[j+1] != type[j])
|
||
if (trame[j+1] != type[j]) // Le resultat devient faux
|
||
{
|
||
res = 0;
|
||
}
|
||
... | ... | |
void traitement(char * trame)
|
||
{
|
||
static int cpt=0;
|
||
cpt++;
|
||
printf ("> %s\n",trame);
|
||
cpt++;
|
||
if (trame_cmp(trame,"GPGGA"))
|
||
printf ("> %s\n",trame);
|
||
|
||
}
|
||
|
||
... | ... | |
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
printf ("Erreur Test unitaire trame_cmp 1.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPRMC suite chaine","GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
printf ("Erreur Test unitaire trame_cmp 2.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPRMC... ", "GPRMC" )!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
if (trame_cmp("$GPRMC...", "GPRMC" )!=1){
|
||
printf ("Erreur Test unitaire trame_cmp 3.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$APRMC...", "GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp4.\n");
|
||
printf ("Erreur Test unitaire trame_cmp 4.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
Formats disponibles : Unified diff
Q5 : Le programme affiche bien les trames "GPGGA" seulement