Révision 890
Ajouté par mukis il y a presque 4 ans
main.c | ||
---|---|---|
#include <math.h>
|
||
#include "trame.h"
|
||
|
||
//Enregistrement latitude et longitude
|
||
typedef struct {
|
||
float longitude;
|
||
float latitude;
|
||
... | ... | |
"$GPZDA,141914.00,01,02,2006,00,00*69",
|
||
0};
|
||
|
||
int trame_cmp(char* trame,char* type)
|
||
int trame_cmp(char* trame,char* type)//Verifie que la trame est un GPGGA
|
||
{
|
||
int i = 0, a = 0;
|
||
for (i=0;i<5;i++)
|
||
... | ... | |
|
||
else if ((trame[i+1] == '\0') || (type[i] == '\0') || (trame[i+1] == ','))
|
||
{
|
||
a = trame[i] - type[i];
|
||
a = trame[i] - type[i];
|
||
}
|
||
|
||
else
|
||
... | ... | |
}
|
||
}
|
||
|
||
int decode_int(char ch)
|
||
int decode_int(char ch)//Conversion d'un caractere en entier
|
||
{
|
||
int dec;
|
||
|
||
... | ... | |
}
|
||
}
|
||
|
||
int decode_nombre(char *ch, int n)
|
||
int decode_nombre(char *ch, int n)//Decode les premiers chiffres de la latitude ou longitude
|
||
{
|
||
int i=0, res=0;
|
||
|
||
... | ... | |
return res;
|
||
}
|
||
|
||
float conversion_latitude (char *lat_c)
|
||
float conversion_latitude (char *lat_c)//Conversion de la latitude - Passage sous forme de flottant
|
||
{
|
||
int i=0, k=2;
|
||
float lat_f=0;
|
||
... | ... | |
return lat_f;
|
||
}
|
||
|
||
float conversion_longitude (char *long_c)
|
||
float conversion_longitude (char *long_c)//Conversion de la longitude - Passage sous forme de flottant
|
||
{
|
||
int i, k=3;
|
||
float long_f=0;
|
||
... | ... | |
return long_f;
|
||
}
|
||
|
||
float conversion_lat_long (char *c)
|
||
float conversion_lat_long (char *c)//Appelle la bonne fonction de conversion
|
||
{
|
||
int i=0;
|
||
|
||
... | ... | |
}
|
||
}
|
||
|
||
int decode_trame(char *trame, Position p)
|
||
int decode_trame(char *trame, Position p)//Permet d'identifier et enregistrer la latitude et longitude
|
||
{
|
||
int i=0, j=0, k=0;
|
||
int i=0, j=0, k=0, a=0;
|
||
char lat_c[10]={NULL}, long_c[11]={NULL};
|
||
|
||
if(trame_cmp(trame,"GPGGA"))
|
||
{
|
||
printf("Trame commencant par GPGGA :\n");
|
||
printf("%s\n",trame);
|
||
|
||
for (i=0; i<66; i++)
|
||
{
|
||
if (i>=17 && i<=25)
|
||
if (a == 2 && trame[i]!=',')
|
||
{
|
||
lat_c[j] = trame[i];
|
||
j++;
|
||
//printf("lat : %s\n",lat_c);
|
||
}
|
||
|
||
if (i>=29 )// 29<= i <=38
|
||
if (a == 4 && trame[i]!=',')
|
||
{
|
||
if(i==39)
|
||
{
|
||
break;
|
||
}
|
||
long_c[k] = trame[i];
|
||
k++;
|
||
//printf("long : %s\n",long_c);
|
||
}
|
||
|
||
if (trame[i] == ',')
|
||
{
|
||
a++;
|
||
}
|
||
}
|
||
|
||
printf("lat_c : %s,long_c %s\n",lat_c,long_c);
|
||
p.latitude = conversion_lat_long(lat_c);
|
||
p.longitude = conversion_lat_long(long_c);
|
||
... | ... | |
return trame_cmp(trame,"GPGGA");
|
||
}
|
||
|
||
float calcule_distance(Position p_1, Position p_2)
|
||
float calcule_distance(Position p_1, Position p_2)//Calcul de distance entre 2 points
|
||
{
|
||
float d=0, a1, a2, b1, b2;
|
||
|
||
... | ... | |
return d;
|
||
}
|
||
|
||
float calcule_vitesse(Position p_1, Position p_2)
|
||
float calcule_vitesse(Position p_1, Position p_2)//Calcul de la vitesse entre 2 points
|
||
{
|
||
float v = 0;
|
||
|
||
... | ... | |
return v;
|
||
}
|
||
|
||
float distance_a_la_plus_proche_zone(Position p,Zone r[],int nb_zones,float *d)
|
||
{
|
||
float k=0, i=0, j=9999999;
|
||
|
||
for (i=0; i<nb_zones; i++)
|
||
{
|
||
k=calcule_distance(p, r[i].rpos);
|
||
|
||
if (k<j)
|
||
{
|
||
j=k;
|
||
}
|
||
}
|
||
|
||
printf("distance entre le vehicule et la zone dangereuse la plus proche : ");
|
||
printf("%f",k);
|
||
return j; //retourne la plus petite distance
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
Formats disponibles : Unified diff
Modification de la fonction decode_tram (identification par rapport aux virgules)