Révision 161
Ajouté par Ramazan CELIK il y a environ 3 ans
branch/CELIK/sp4a12/main.c | ||
---|---|---|
{
|
||
static int cpt=0;
|
||
cpt++;
|
||
printf ("> %s\n",trames[4]);
|
||
|
||
if (trame_cmp(trame,"GPGGA") == 1)
|
||
{
|
||
printf ("> %s\n",trame);
|
||
}
|
||
}
|
||
|
||
int trame_cmp(char*trame, char*type)
|
||
int trame_cmp(char *trame, char *type)
|
||
{
|
||
int i;
|
||
int verif=1;
|
||
for(i=0;i<5;i++)
|
||
int test=1;
|
||
|
||
for (i=0; i<5; i++)
|
||
{
|
||
if (trame[i+1]!=type[i])
|
||
if (trame[i+1] != type[i]) // verifie que le debut de la trame correspond au caractere type
|
||
{
|
||
verif=0;
|
||
test=0;
|
||
}
|
||
}
|
||
return verif;
|
||
|
||
return test;
|
||
}
|
||
|
||
int decode_int(char c)
|
||
{
|
||
int res;
|
||
|
||
if ((c>='0') && (c<='9'))
|
||
{
|
||
res = c-48;
|
||
}
|
||
else
|
||
{
|
||
res = -1;
|
||
}
|
||
return res;
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
if (5!=5){
|
||
void tests_unitaires(void)
|
||
{
|
||
if (5!=5)
|
||
{
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPGSV suite chaine","GPGSV")!=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("$GPGGA suite chaine","GPGGA") != 1)
|
||
{
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
if (trame_cmp("$GPGSV suite chaine","GPGGA") != 0)
|
||
{
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
if (trame_cmp("$GPGLL suite chaine","GPGGA") != 0)
|
||
{
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
void test_decode_int(void)
|
||
{
|
||
if (decode_int('0') != 0)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
if (trame_cmp("$GPRMC suite chaine","GPRMC")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
|
||
if (decode_int('1') != 1)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
if (trame_cmp("$GPGLL suite chaine","GPGLL")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
|
||
if (decode_int('2') != 2)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
|
||
if (decode_int('3') != 3)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
if (trame_cmp("$GPGSA suite chaine","GPGSA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
|
||
if (decode_int('4') != 4)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
if (trame_cmp("$GPVTG suite chaine","GPVTG")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
|
||
if (decode_int('5') != 5)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
if (trame_cmp("$GPZDA suite chaine","GPZDA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
if (decode_int('6') != 6)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
|
||
if (decode_int('7') != 7)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
|
||
if (decode_int('8') != 8)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
|
||
if (decode_int('9') != 9)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
|
||
if (decode_int('A') != -1)
|
||
{
|
||
printf ("erreur test unitaire decode_int\n");
|
||
}
|
||
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
|
||
tests_unitaires();
|
||
|
||
// Affichage des trames definies dans la table trames.
|
||
printf ("Trames de tests tableau trames:\n");
|
||
int i=0;
|
||
while (trames[i])
|
||
traitement(trames[i++]);
|
||
|
||
if (!trame_init())
|
||
exit(-1);
|
||
// Affichage des trames du fichier gps.log
|
||
char *trame;
|
||
printf ("Trames de tests du fichier gps.log\n");
|
||
while ((trame = trame_suivante()))
|
||
traitement(trame);
|
||
|
||
int main(int argc,char ** argv)
|
||
{
|
||
tests_unitaires();
|
||
// Affichage des trames definies dans la table trames.
|
||
printf ("Trames de tests tableau trames:\n");
|
||
int i=0;
|
||
while (trames[i])
|
||
traitement(trames[i++]);
|
||
|
||
if (!trame_init())
|
||
exit(-1);
|
||
// Affichage des trames du fichier gps.log
|
||
char *trame;
|
||
printf ("Trames de tests du fichier gps.log\n");
|
||
while ((trame = trame_suivante()))
|
||
traitement(trame);
|
||
return 0;
|
||
}
|
Formats disponibles : Unified diff
Reparation commit M. Celik (Laffont)