Révision 28
Ajouté par Stephen LOPEZ il y a environ 3 ans
branch/LOPEZ_Stephen/tp_sp4_2022_LOPEZ_Stephen/sp4a12/main.c | ||
---|---|---|
|
||
{
|
||
static int cpt=0 ;
|
||
cpt++ ;
|
||
printf ("> %s\n",trame);
|
||
cpt++ ;
|
||
if(trame_cmp(trame,"GPGGA"))
|
||
{
|
||
printf ("> %s\n",trame);
|
||
}
|
||
}
|
||
int trame_cmp(char *trame,char*type)
|
||
{
|
||
int i;
|
||
int res=1;
|
||
for (i=0;i<5;i++)
|
||
{
|
||
if(trame[i+1]!=type[i])
|
||
{
|
||
res=0;
|
||
}
|
||
}
|
||
return res;
|
||
}
|
||
|
||
|
||
int decode_int(char c)
|
||
{
|
||
int val;
|
||
val = c-48;
|
||
if (val>9)
|
||
{
|
||
val=-1;
|
||
}
|
||
return val;
|
||
}
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
if (5!=5){
|
||
... | ... | |
if (trame_cmp("$APRMC...", "GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_int('0')!=0){
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_int('5')!=5){
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_int('9')!=9){
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_int('A')!=-1){
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
int trame_cmp(char *trame,char*type)
|
||
{
|
||
int i;
|
||
int res=1;
|
||
for (i=0;i<5;i++)
|
||
{
|
||
if(trame[i+1]!=type[i])
|
||
{
|
||
res=0;
|
||
}
|
||
}
|
||
return res;
|
||
}
|
||
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
Formats disponibles : Unified diff
question 5 et 6 terminées