Révision 217
Ajouté par jgsoleilla il y a presque 4 ans
main.c | ||
---|---|---|
#include <strings.h>
|
||
#include <math.h>
|
||
#include "trame.h"
|
||
|
||
typedef struct{
|
||
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 trame_cmp(char* trame,char* type){
|
||
int trame_cmp(char* trame,char* type){
|
||
int i = 1;
|
||
int res = 1;
|
||
while ((res == 1) && (type[i-1] != '\0')){
|
||
... | ... | |
|
||
int decode_nombre(char * ch, int n){
|
||
int i;
|
||
int p = 1;
|
||
int res = 0;
|
||
for(i=n-1; i>=0; i--){
|
||
res += (decode_int(ch[i]))*p;
|
||
p *= 10;
|
||
for(i=0; i<n; i++){
|
||
res *= 10;
|
||
res += decode_int(ch[i]);
|
||
}
|
||
return res;
|
||
}
|
||
... | ... | |
return res;
|
||
}
|
||
|
||
/*void decode_trame(char *trame){
|
||
|
||
void decode_trame(char *trame, Position *p){
|
||
if (trame_cmp(trame,"GPGGA")==1){
|
||
char latitude[];
|
||
char longitude[];
|
||
for (i=0; i<10; i++){
|
||
char latitude[10];
|
||
char longitude[10];
|
||
|
||
int pos = 0;
|
||
|
||
int i;
|
||
int j = 0;
|
||
int k = 0;
|
||
|
||
for (i=0; i<40; i++){
|
||
if (trame[i] == ','){
|
||
pos ++;
|
||
}
|
||
if (pos == 2){
|
||
latitude[j] = trame[i];
|
||
j ++;
|
||
}
|
||
p->latitude = conversion(latitude);
|
||
|
||
if (pos == 4){
|
||
longitude[k] = trame[i];
|
||
k ++;
|
||
}
|
||
p->longitude = conversion(longitude);
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}*/
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame){
|
||
... | ... | |
|
||
if (decode_nombre("123",3)!=123){
|
||
printf ("Erreur Test unitaire decode_nombre.\n");
|
||
printf("%d",decode_nombre("123",3));
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("7541",2)!=75){
|
||
... | ... | |
if (fabs(conversion("00306.6036")-3.11006) >= pow(10,-6)){
|
||
printf ("Erreur Test unitaire conversion.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
||
// conv_lat(latitude)Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
|
Formats disponibles : Unified diff
TP2 : Modifications decode_nombre + avancement decode_trame