Révision 267
Ajouté par ahkurklu il y a presque 4 ans
main.c | ||
---|---|---|
#include <strings.h>
|
||
#include <math.h>
|
||
#include "trame.h"
|
||
|
||
typedef struct t_pos{
|
||
float latitude;
|
||
float longitude;
|
||
}Position;
|
||
|
||
|
||
//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",
|
||
... | ... | |
0};
|
||
|
||
int decode_int(char c);
|
||
int decode_trames(char * trame, Position * p);
|
||
|
||
int trame_cmp(char * trame,char * type){
|
||
/*DECLARATION VARIABLE*/
|
||
... | ... | |
}
|
||
}
|
||
|
||
void tests_unitaires_decode_tram(void){
|
||
Position p;
|
||
|
||
if(decode_trames("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D",&p)!=1){
|
||
printf("Erreur test unitaire decode trame\n");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
int decode_trames(char * trame, Position * p){
|
||
char buff[20];
|
||
int i;
|
||
int resultat = 1;
|
||
|
||
if(trame_cmp(trame,"GPGGA")){
|
||
for (i=17;i<26;i++){
|
||
buff[i-17] = trame[i];
|
||
}
|
||
p->latitude = conversion_lat_long_float(buff);
|
||
|
||
for(i=29;i<39;i++){
|
||
buff[i-29] = trame[i];
|
||
}
|
||
p->longitude = conversion_lat_long_float(buff);
|
||
|
||
if(p->latitude<0 && p->latitude>60 && p->longitude<0 && p->longitude>180){
|
||
resultat = 0;
|
||
}
|
||
}
|
||
else{
|
||
resultat = 0;
|
||
}
|
||
|
||
return resultat;
|
||
}
|
||
|
||
|
||
|
||
|
||
void test_unitaire_conversion_long_lat_float(void){
|
||
float i = conversion_lat_long_float("09013.1234");
|
||
float j = 90.21872333 ;
|
||
... | ... | |
exit(-1);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
|
||
static int cpt=0;
|
||
cpt++;
|
||
if(trame_cmp(trame,"GPGGA")){
|
||
printf ("> %s\n",trame);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
... | ... | |
test_unitaire_decode_nombre();
|
||
test_unitaire_conversion_lat_float();
|
||
test_unitaire_conversion_long_float();
|
||
test_unitaire_conversion_long_lat_float();
|
||
test_unitaire_conversion_long_lat_float();
|
||
tests_unitaires_decode_tram();
|
||
}
|
||
|
||
|
Formats disponibles : Unified diff
TP2 question 1 2 ajout fonction decode_tram() teset unitaire()