Révision 346
Ajouté par malameynar il y a presque 4 ans
branch/lameynardie/sp4a12/main.c | ||
---|---|---|
char lati[]="37232475S";
|
||
printf("latitude\n%f\n",lat_float(&lati));
|
||
}
|
||
|
||
decode_trame(char *chi,char *lon,char *lat,int *ok){
|
||
char ref[]="GPGGA";
|
||
int i=17;
|
||
int j=0;
|
||
int k=0;
|
||
if(trame_cmp(chi,&ref)==1){
|
||
while(i<27){
|
||
if (decode_int(chi[i])!=-1){
|
||
lon[j]=chi[i];
|
||
j++;
|
||
}
|
||
i++;
|
||
}
|
||
lon[j]=chi[i];
|
||
j++;
|
||
i++;
|
||
lon[j]='\0';
|
||
k=0;
|
||
while(i<40){
|
||
if (decode_int(chi[i])!=-1){
|
||
lat[k]=chi[i];
|
||
k++;
|
||
}
|
||
i++;
|
||
}
|
||
lat[k]=chi[i];
|
||
if(k==9 && j==9){
|
||
*ok=1;
|
||
}
|
||
else{
|
||
*ok=0;
|
||
}
|
||
}
|
||
else{
|
||
*ok=0;
|
||
}
|
||
}
|
||
|
||
|
||
test_lat_long(void){
|
||
char lati1[]="37232475N";
|
||
char longi1[]="003066036E";
|
||
... | ... | |
printf("latitude:%f\n",lat_long(&lati2));
|
||
printf("latitude:%f\n",lat_long(&longi2));
|
||
|
||
|
||
}
|
||
|
||
|
||
/*
|
||
float lon_float(char * trame)
|
||
int i=17;
|
||
float lon=0;
|
||
int deg=0;
|
||
int min=0;
|
||
while (i<19){
|
||
if(decode_int(trame[i])!=-1){
|
||
printf("%c",trame[i]);
|
||
//Fonction ? modifier !!!!!
|
||
void test_decode_trame(void){
|
||
char chlat[20];
|
||
char chlon[20];
|
||
char tramei1[]="$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D";
|
||
char tramei2[]="$GPGSV,3,2,10,15,03,077,,18,04,041,42,19,85,271,,20,08,214,*7C";
|
||
char tramei3[]="$GPRMC,141914.00,A,4545.6424,N,00306.6036,E,0.4,99.4,010206,,*0C";
|
||
char tramei4[]="$GPGLL,4545.6424,N,00306.6036,E,141914.00,A*0E";
|
||
int ok;
|
||
decode_trame(&tramei1,&chlon,&chlat,&ok);
|
||
printf("coordonnes:%s %s\ntrame valide : %d\n ",chlon,chlat,ok);
|
||
|
||
}
|
||
i+=1;
|
||
}
|
||
while (i<26){
|
||
if(decode_int(trame[i])!=-1){
|
||
printf("%c",trame[i]);
|
||
}
|
||
i+=1;
|
||
}
|
||
printf("\n");
|
||
return(1);
|
||
}
|
||
*/
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
|
||
|
||
decode_trame(&tramei2,&chlon,&chlat,&ok);
|
||
printf("coordonnes:%s %s\ntrame valide : %d\n ",chlon,chlat,ok);
|
||
|
||
|
||
|
||
decode_trame(&tramei3,&chlon,&chlat,&ok);
|
||
printf("coordonnes:%s %s\ntrame valide : %d\n ",chlon,chlat,ok);
|
||
|
||
|
||
|
||
decode_trame(&tramei4,&chlon,&chlat,&ok);
|
||
printf("coordonnes:%s %s\ntrame valide : %d\n ",chlon,chlat,ok);
|
||
}
|
||
void traitement(char * trame){
|
||
////////////////////////////
|
||
char chlat[20];
|
||
char chlon[20];
|
||
int ok;
|
||
float lat
|
||
////////////////////////////
|
||
static int cpt=0 ;
|
||
cpt++ ;
|
||
if (trame_cmp(trame,"GPGGA")==1){
|
||
printf ("> %s\n",trame);
|
||
// lon_float(trame);
|
||
///////////////////////////////
|
||
decode_trame(trame,&chlon,&chlat,&ok);
|
||
if(ok==1){
|
||
printf("longitude:%f\nlatitude:%f\n\n\n",lat_long(&chlon),lat_long(&chlat));
|
||
|
||
}
|
||
/////////////////////////////
|
||
}
|
||
}
|
||
|
||
... | ... | |
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
// test_decode_int();
|
||
// test_decode_nombre();
|
||
/* test_decode_int();
|
||
test_decode_nombre();
|
||
test_lon_float();
|
||
test_lat_float();
|
||
test_lat_long();
|
||
test_lat_long();
|
||
test_decode_trame();*/
|
||
}
|
||
|
||
void test_decode_int(void){
|
||
... | ... | |
traitement(trame);
|
||
|
||
return 0;
|
||
}
|
||
}
|
||
|
Formats disponibles : Unified diff
implémentation de decode_trame et de son test