Révision 264
Ajouté par Damien REGENT il y a environ 3 ans
main.c | ||
---|---|---|
"$GPGSA,A,3,,03,,22,14,,01,,18,,,,3.9,3.4,1.9*39",
|
||
"$GPVTG,99.4,T,,M,0.4,N,0.7,K*57",
|
||
"$GPZDA,141914.00,01,02,2006,00,00*69",
|
||
0};
|
||
0};
|
||
|
||
void ma_fonction()
|
||
typedef struct
|
||
{
|
||
float Latitude;
|
||
float Longitude;
|
||
}Position;
|
||
|
||
}
|
||
|
||
int trame_cmp(char * trame, char * type)
|
||
{
|
||
int i;
|
||
... | ... | |
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('1')!=0)
|
||
if(decode_int('1')!=1)
|
||
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('2')!=0)
|
||
if(decode_int('2')!=2)
|
||
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('3')!=0)
|
||
if(decode_int('3')!=3)
|
||
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('4')!=0)
|
||
if(decode_int('4')!=4)
|
||
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('5')!=0)
|
||
if(decode_int('5')!=5)
|
||
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('6')!=0)
|
||
if(decode_int('6')!=6)
|
||
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('7')!=0)
|
||
if(decode_int('7')!=7)
|
||
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('8')!=0)
|
||
if(decode_int('8')!=8)
|
||
{
|
||
exit(-1);
|
||
}
|
||
if(decode_int('9')!=0)
|
||
if(decode_int('9')!=9)
|
||
{
|
||
exit(-1);
|
||
}
|
||
return 1;
|
||
}
|
||
|
||
int decode_nombre(char *ch, int n)//Fonction qui permet de passer d'une chaine de caratere a un entier
|
||
int decode_nombre(char *ch, int n, int i)//Fonction qui permet de passer d'une chaine de caratere a un entier
|
||
{
|
||
int temp=0, i=0;
|
||
int temp=0;
|
||
for(i;i<n;i++)
|
||
{
|
||
temp=(temp*10)+decode_int(ch[i]);
|
||
... | ... | |
|
||
int test_decode_nombre()
|
||
{
|
||
if(decode_nombre("758961",2)!=75)
|
||
if(decode_nombre("758961",2,0)!=75)
|
||
{
|
||
printf("Erreur Test unitaire nombre. \n");
|
||
printf("Erreur Test unitaire nombre \n");
|
||
exit(-1);
|
||
}
|
||
if(decode_nombre("758961",5)!=75896)
|
||
if(decode_nombre("758961",5,0)!=75896)
|
||
{
|
||
printf("Erreur Test unitaire nombre. \n");
|
||
printf("Erreur Test unitaire nombre \n");
|
||
exit(-1);
|
||
}
|
||
return 1;
|
||
}
|
||
|
||
float decode_latitude(char *trame )
|
||
{
|
||
float degres,reste,flottant,res;
|
||
int i=17;
|
||
degres=decode_nombre(trame,i+2,i);
|
||
reste=decode_nombre(trame,i+4,i+2);
|
||
flottant=decode_nombre(trame,i+9,i+5);
|
||
|
||
res=degres+((reste/60+(flottant/10000)));
|
||
return res;
|
||
|
||
}
|
||
|
||
int test_decode_latitude()
|
||
{
|
||
if((-0.00001<=decode_latitude("3723.2475")-37.387458)&&(decode_latitude("3723.2475")-37.387458<=0.00001))
|
||
{
|
||
printf("Erreur Test unitaire latitude \n");
|
||
exit(-1);
|
||
}
|
||
return 1;
|
||
}
|
||
|
||
float decode_longitude(char *trame )
|
||
{
|
||
float degres,reste,flottant,res;
|
||
int i=30;
|
||
degres=decode_nombre(trame,i+2,i);
|
||
reste=decode_nombre(trame,i+3,i+2);
|
||
flottant=decode_nombre(trame,i+10,i+5);
|
||
|
||
res=degres+((reste+(flottant/10000))/60);
|
||
return res;
|
||
|
||
}
|
||
|
||
int test_decode_longitude()
|
||
{
|
||
if((-0.00001<=decode_latitude("00306.6036")-3.11006)&&(decode_latitude("00306.6036")-3.11006<=0.00001))
|
||
{
|
||
printf("Erreur Test unitaire latitude \n");
|
||
exit(-1);
|
||
}
|
||
return 1;
|
||
}
|
||
|
||
float decode_position(char *trame,Position Pos)
|
||
{
|
||
Pos.Latitude=decode_latitude(trame);
|
||
Pos.Longitude=decode_longitude(trame);
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
... | ... | |
}
|
||
}
|
||
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
... | ... | |
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
printf ("Erreur Test unitaire trame.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
if (test_decode_int()!=1){
|
||
printf ("Erreur Test unitaire int.\n");
|
||
exit(-1);
|
||
}
|
||
if (test_decode_nombre()!=1){
|
||
printf ("Erreur Test unitaire nombre.\n");
|
||
exit(-1);
|
||
}
|
||
if (test_decode_latitude()!=1){
|
||
printf ("Erreur Test unitaire latitude.\n");
|
||
exit(-1);
|
||
}
|
||
if (test_decode_longitude()!=1){
|
||
printf ("Erreur Test unitaire longitude.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
|
Formats disponibles : Unified diff
Implantation des décodages en flottants de latitude et de longitude avec leur test unitaire respectif