Révision 210
Ajouté par Awa Semou FAYE il y a environ 3 ans
branch/faye_awasemou/sp4a12/main.c | ||
---|---|---|
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include "trame.h"
|
||
#define max 5
|
||
|
||
|
||
//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",
|
||
"$GPGSV,3,3,10,22,39,053,50,28,15,320,*7E",
|
||
... | ... | |
0};
|
||
int trame_cmp(char* trame, char* type)
|
||
{
|
||
int N=max,i;
|
||
int i;
|
||
int ok;
|
||
ok=0|1;
|
||
for (i=0;i<N;i++)
|
||
for (i=0;i<5;i++)
|
||
{
|
||
if (trame[i+1]==type[i])
|
||
{
|
||
... | ... | |
|
||
int decode_int(char c)
|
||
{
|
||
int chiffre ;
|
||
int Vdecimal;
|
||
if ( c <= '9' && c >='0' )
|
||
{
|
||
chiffre =c-48;
|
||
Vdecimal =c-48;
|
||
|
||
|
||
}else
|
||
{
|
||
chiffre=-1;
|
||
Vdecimal=-1;
|
||
|
||
}
|
||
return chiffre;
|
||
return Vdecimal;
|
||
}
|
||
//decode_nombre
|
||
int decode_nombre(char* ch, int n )
|
||
{
|
||
int i,s=0;
|
||
for(i=0;i<n;i++)
|
||
{
|
||
s=s*10;
|
||
s=s+decode_int(ch[i]);
|
||
|
||
}
|
||
}
|
||
return s;
|
||
}
|
||
//declaration de la structure position contenant la latitude et la longitude
|
||
typedef struct {
|
||
float latitude;
|
||
float longitude;
|
||
} position ;
|
||
|
||
|
||
// fonction qui convertit la latitude en un nombre flottant
|
||
float conversion_latitude(char* lati)
|
||
{
|
||
float resultat;
|
||
int valDECI, valMin;
|
||
for(i=0;i++;)
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/*int seuil1; //seuil de la vitesse
|
||
int seuil2; // seuil de la distance
|
||
int j;*/
|
||
int decode_trame(char* trame, position* p)
|
||
{
|
||
if (trame_cmp(trame,"GPGGA")==1);
|
||
{
|
||
return 1;
|
||
}else
|
||
{
|
||
return 0;
|
||
|
||
}
|
||
}*/
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
|
||
static int cpt=0;
|
||
cpt++;
|
||
|
||
int ok;
|
||
if(ok==1)
|
||
{
|
||
printf("La trame commence par la chaine de caracteres type \n");
|
||
return 0;
|
||
}
|
||
|
||
}else
|
||
{
|
||
printf("La trame ne commence pas par la chaine de caracteres type \n");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
if (5!=5){
|
||
... | ... | |
}
|
||
if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPRMC suite chaine","GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
if (trame_cmp("$GPRMC... ", "GPRMC" )!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$APRMC...", "GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_int('0')!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_int('7')!=7){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_int('A')!=-1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("7541",2)!=75){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("7541",3)!=754){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
Formats disponibles : Unified diff
Implementation fonctions decode_trame,conversion_latidute, decode_nombre, tests unitaires