Révision 304
Ajouté par Florentin GAMEL il y a presque 3 ans
branch/gamel/sp4a12/main.c | ||
---|---|---|
"$GPZDA,141914.00,01,02,2006,00,00*69",
|
||
0};
|
||
|
||
typedef struct{
|
||
float Lat;
|
||
float Long;
|
||
}position;
|
||
|
||
int trame_cmp(char*trame, char*type)
|
||
{
|
||
... | ... | |
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
void traitement(char * trame){
|
||
static int cpt=0;
|
||
cpt++;
|
||
|
||
... | ... | |
}
|
||
|
||
|
||
int decode_int(char c)
|
||
{
|
||
int decode_int(char c){
|
||
int valeur;
|
||
if((c>47)&&(c<58))
|
||
{
|
||
... | ... | |
}
|
||
|
||
|
||
int main1(){
|
||
int retour;
|
||
char c;
|
||
retour=decode_int(c);
|
||
printf("Le code ascii de %c est %d",c,retour);
|
||
return(0);
|
||
}
|
||
|
||
|
||
|
||
/*
|
||
int main2(){
|
||
int result;
|
||
float position;
|
||
result=decode_trame(p);
|
||
|
||
return(0);
|
||
}
|
||
|
||
|
||
float decode_trame(char*trame,position p)
|
||
{
|
||
int i;
|
||
if (trame_cmp(trame[i],"GPGGA")==1)
|
||
{
|
||
decode_position(trame[i],p)
|
||
}
|
||
}
|
||
*/
|
||
|
||
|
||
|
||
|
||
int decode_nombre(char *ch,int n){
|
||
int r=0;
|
||
int i;
|
||
... | ... | |
}
|
||
|
||
|
||
position decode_position(char *trame){
|
||
position p;
|
||
p.Lat=decode_latitude(trame);
|
||
p.Long=decode_longitude(trame);
|
||
|
||
return p;
|
||
}
|
||
|
||
/*
|
||
float decode_trame(char*trame,position p)
|
||
{
|
||
int i;
|
||
if (trame_cmp(trame[i],"GPGGA")==1)
|
||
{
|
||
decode_position(trame[i],p)
|
||
}
|
||
}
|
||
*/
|
||
|
||
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
if (5!=5){
|
||
... | ... | |
printf("Erreur test unitaire trame_cmp\n");
|
||
exit(-1);
|
||
}
|
||
test_decode_int();
|
||
|
||
test_decode_nombre();
|
||
|
||
test_decode_latitude();
|
||
|
||
test_decode_longitude();
|
||
|
||
test_decode_position();
|
||
|
||
}
|
||
|
||
|
||
|
||
void test_decode_nombre(void){
|
||
char t[5];
|
||
t[0]='1';t[1]='2';t[2]='3';t[3]='4';
|
||
... | ... | |
}
|
||
}
|
||
|
||
void tests_decode_int(void){
|
||
void test_decode_int(void){
|
||
if (decode_int('0')!=0){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
... | ... | |
}
|
||
|
||
|
||
void test_decode_position(void){
|
||
if(decode_position("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D").Long!=3.1100599765777588){
|
||
printf("Erreur test unitaire decode_position1\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_position("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D").Lat!=45.75){
|
||
printf("Erreur test unitaire decode_position2\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_position("$GPGGA,141914.00,4545.0000,N,23000.0000,E,1,05,3.4,499.3,M,,M,,*7D").Long!=230){
|
||
printf("Erreur test unitaire decode_position3\n");
|
||
exit(-1);
|
||
}
|
||
if(decode_position("$GPGGA,141914.00,1800.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D").Lat!=18){
|
||
printf("Erreur test unitaire decode_position4\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
Formats disponibles : Unified diff
Fin tp1 avec la fonction qui lie la latitude et longitude avec les tests.