Révision 149
Ajouté par Victor SOUDY il y a environ 3 ans
branch/SOUDY/main.c | ||
---|---|---|
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include "trame.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",
|
||
... | ... | |
|
||
float lat_to_float (char*trame)
|
||
{
|
||
int lat;
|
||
lat=decode_nombre(&trame[17],4);
|
||
return lat;
|
||
float latd,latm,lats,latdeg;
|
||
latd=decode_nombre(&trame[17],2);
|
||
latm=decode_nombre(&trame[19],2);
|
||
lats=decode_nombre(&trame[21],4);
|
||
latdeg=latd+((latm+(lats/10000))/60.0);
|
||
return latdeg;
|
||
}
|
||
|
||
|
||
|
||
float long_to_float (char*trame)
|
||
{
|
||
float longd,longm,longs,longdeg;
|
||
longd=decode_nombre(&trame[29],3);
|
||
longm=decode_nombre(&trame[32],2);
|
||
longs=decode_nombre(&trame[35],4);
|
||
longdeg=longd+((longm+(longs/10000))/60.0);
|
||
return longdeg;
|
||
}
|
||
|
||
|
||
|
||
|
||
//Fonction ? modifier !!!!!754198
|
||
void traitement(char*trame)
|
||
... | ... | |
if (trame_cmp(trame,"GPGGA")==1)
|
||
{
|
||
printf("%f\n",lat_to_float(trame));
|
||
|
||
printf("%f\n",long_to_float(trame));
|
||
printf ("> %s\n",trame);
|
||
}
|
||
|
||
... | ... | |
printf("Erreur test unitaire decode_nombre\n");
|
||
exit(-1);
|
||
}
|
||
//-----------------------------------------------------------//
|
||
//test unitaire lattitude
|
||
|
||
|
||
if ((fabs(lat_to_float("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D")-45.748))>=pow(1,-6))
|
||
{
|
||
printf("Erreur test unitaire lattitude\n");
|
||
exit(-1);
|
||
}
|
||
//-----------------------------------------------------------//
|
||
//test unitaire longitude
|
||
|
||
if ((fabs(long_to_float("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D")-3.1100))>=pow(1,-6))
|
||
{
|
||
printf("Erreur test unitaire longitude\n");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
|
||
|
Formats disponibles : Unified diff
question 8 et 9. Ajouts fct lat_to_float et long_to_float avec leurs tests unitaires.