Révision 127
Ajouté par yoguer il y a environ 4 ans
branch/Guer/sp4a12/main.c | ||
---|---|---|
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include "trame.h"
|
||
#include <math.h>
|
||
|
||
//Trames de tests ? modifier si n?cessaire.
|
||
char * trames[]= {"$GPGSV,3,2,10,15,03,077,,18,04,041,42,19,85,271,,20,08,214,*7C",
|
||
"$GPGSV,3,3,10,22,39,053,50,28,15,320,*7E",
|
||
"$GPRMC,141914.00,A,4545.6424,N,00306.6036,E,0.4,99.4,010206,,*0C",
|
||
"$GPGLL,4545.6424,N,00306.6036,E,141914.00,A*0E",
|
||
"$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D",
|
||
"$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};
|
||
|
||
|
||
int decode_int(char c)
|
||
{
|
||
int a=0;
|
||
... | ... | |
return a;
|
||
}
|
||
|
||
|
||
//Trames de tests ? modifier si n?cessaire.
|
||
char * trames[]= {"$GPGSV,3,2,10,15,03,077,,18,04,041,42,19,85,271,,20,08,214,*7C",
|
||
"$GPGSV,3,3,10,22,39,053,50,28,15,320,*7E",
|
||
"$GPRMC,141914.00,A,4545.6424,N,00306.6036,E,0.4,99.4,010206,,*0C",
|
||
"$GPGLL,4545.6424,N,00306.6036,E,141914.00,A*0E",
|
||
"$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D",
|
||
"$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};
|
||
|
||
int decode_nombre(char *ch,int n)
|
||
{
|
||
int tab[n],i,retour=0;
|
||
|
||
for(i=0;i<n;i++)
|
||
{
|
||
tab[i]=decode_int(ch[i]);
|
||
retour=retour*10+tab[i];
|
||
}
|
||
return retour;
|
||
}
|
||
|
||
|
||
float conversion_char_latitude(char latitude)
|
||
{
|
||
int tab[n],i,degres;
|
||
|
||
|
||
for(i=0;i<n;i++)
|
||
{
|
||
tab[i]=decode_int(ch[i]);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
int trame_cmp(char * trame, char * type)
|
||
{
|
||
int i=0, validation=0, j=0;
|
||
... | ... | |
//printf ("> %s\n",trame);
|
||
}
|
||
}
|
||
|
||
|
||
//**************************************************************************************************************************************************************************
|
||
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
... | ... | |
}
|
||
|
||
test_decode_int(); //test la fonction decode_int
|
||
test_decode_nombre(); //test la fonction decode_nombre
|
||
}
|
||
|
||
|
||
... | ... | |
|
||
for(i=0;i<10;i++)
|
||
{
|
||
if (decode_int('i')==i);
|
||
if (decode_int('0'+i)==i);
|
||
{
|
||
printf("GOOD pour le caractere: %hd\n",i); //test si la fonction renvoie bien la bonne valeur d?cimal
|
||
}
|
||
... | ... | |
|
||
if(decode_int('A')==-1)
|
||
{
|
||
printf("GOOD pour le caractere A\n"); //test si la fonction renvoie -1 pour le caract?re A
|
||
printf("GOOD pour le caractere A\n\n"); //test si la fonction renvoie -1 pour le caract?re A
|
||
}
|
||
}
|
||
|
||
|
||
void test_decode_nombre(void)
|
||
{
|
||
char *ch;
|
||
int n;
|
||
|
||
ch="246500";
|
||
n=3;
|
||
if(decode_nombre(ch,n)==246);
|
||
{
|
||
printf("decode nombre=%hd pour ch=%s et n=%d\n",decode_nombre(ch,n),ch,n);
|
||
}
|
||
|
||
ch="28600";
|
||
n=4;
|
||
if(decode_nombre(ch,n)==246);
|
||
{
|
||
printf("decode nombre=%hd pour ch=%s et n=%d\n\n",decode_nombre(ch,n),ch,n);
|
||
}
|
||
}
|
||
|
||
|
||
|
Formats disponibles : Unified diff
Fonction conversion latitude en cour