Révision 130
Ajouté par Ely SENE il y a environ 4 ans
branch/SENE/sp4a12/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",
|
||
... | ... | |
"$GPZDA,141914.00,01,02,2006,00,00*69",
|
||
0};
|
||
|
||
//fonction trame_cmp
|
||
int trame_cmp(char *a, char *b)
|
||
{
|
||
int i;
|
||
... | ... | |
return 1;
|
||
}
|
||
|
||
//fonction decode_int
|
||
int decode_int(char c)
|
||
{
|
||
int a=0;
|
||
if (c>=48 && c<=57) // caract?re compris entre '0' et '9'
|
||
{
|
||
a=c-48;
|
||
}
|
||
else
|
||
{
|
||
a=-1;
|
||
}
|
||
return a;
|
||
|
||
}
|
||
|
||
//fonction decode_nombre
|
||
int decode_nombre(char *ch,int n)
|
||
{
|
||
int tab[n],i,r=0;
|
||
for(i=0;i<n;i++)
|
||
{
|
||
tab[i]=decode_int(ch[i]);
|
||
r=r+tab[i]*pow(10,n-i-1);
|
||
}
|
||
return r;
|
||
}
|
||
|
||
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
|
||
static int cpt=0;
|
||
cpt++;
|
||
printf ("> %s\n",trame);
|
||
}
|
||
if(trame_cmp(trame,"GPGGA")==1)
|
||
{
|
||
printf ("> %s\n",trame);
|
||
}
|
||
}
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
|
||
... | ... | |
if (trame_cmp("$APRMC...", "GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
test_decode_int();
|
||
}
|
||
|
||
void test_decode_int(void)
|
||
{
|
||
char i;
|
||
for(i=0;i<10;i++)
|
||
{
|
||
if(decode_int('i')==1)
|
||
printf("Valeur d?cimal ?gale au caractere");
|
||
}
|
||
|
||
}
|
||
|
||
void test_decode_nombre(void)
|
||
{
|
||
char *c;
|
||
c="7541";
|
||
int n=2;
|
||
if (decode_nombre(c,n)==75)
|
||
{
|
||
printf("Test valid?");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
Formats disponibles : Unified diff