Révision 119
Ajouté par annoyau il y a presque 4 ans
branch/NOYAU/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",
|
||
... | ... | |
"$GPGSA,A,3,,03,,22,14,,01,,18,,,,3.9,3.4,1.9*39",
|
||
"$GPVTG,99.4,T,,M,0.4,N,0.7,K*57",
|
||
"$GPZDA,141914.00,01,02,2006,00,00*69",
|
||
0};
|
||
0};
|
||
// Fonction trame_cmp
|
||
int trame_cmp (char * trame, char * type) {
|
||
|
||
int i=0;
|
||
... | ... | |
}
|
||
return verif;
|
||
}
|
||
|
||
// Fonction decode_int
|
||
int decode_int(char c)
|
||
{
|
||
int res;
|
||
if (c >= 48 && c<=57) {
|
||
res = c-48;
|
||
}
|
||
else {
|
||
res = -1;
|
||
}
|
||
return res;
|
||
}
|
||
// Fonction decode_nombre
|
||
/*int decode_nombre(char *ch,int n)
|
||
{
|
||
int tab[n],i=0;
|
||
int res2=0;
|
||
|
||
for(i=0;i<n;i++)
|
||
{
|
||
tab[i]=decode_int(ch[i]);
|
||
res2=res2+(tab[i]*pow(10,n-i-1));
|
||
}
|
||
return res2;
|
||
} */
|
||
int decode_nombre(char *ch,int n)
|
||
{
|
||
int tab[n],i,retour=0;
|
||
|
||
for(i=0;i<n;i++)
|
||
{
|
||
tab[i]=decode_int(ch[i]);
|
||
retour=retour+tab[i]*pow(10,n-i-1);
|
||
}
|
||
return retour;
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
... | ... | |
cpt++ ;
|
||
|
||
if (trame_cmp(trame,"GPGGA")==1) {
|
||
printf ("> %s\n",trame);
|
||
// printf ("> %s\n",trame);
|
||
}
|
||
|
||
}
|
||
... | ... | |
if (trame_cmp("$APRMC...", "GPGGA")!=0){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
test_decode_int();
|
||
test_decode_nombre();
|
||
}
|
||
void test_decode_int(void) {
|
||
/* char i;
|
||
for (i=0;i>127;i++)
|
||
{
|
||
if (decode_int(i)==(-1))
|
||
{
|
||
printf("La conversion est pas bonne \n");
|
||
exit (-1);
|
||
}
|
||
}
|
||
if (decode_int('A')!=(-1)) {
|
||
printf("La conversion c'est mal pass? \n");
|
||
exit (-1);
|
||
}
|
||
if (decode_int('0')==(-1)) {
|
||
printf("La conversion c'est mal pass? \n");
|
||
exit (-1);
|
||
}
|
||
*/
|
||
}
|
||
void test_decode_nombre (void) {
|
||
char *c;
|
||
c = "3165";
|
||
int n = 3;
|
||
if (decode_nombre(c,n)==316){
|
||
printf("Le test est bonne\n");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
||
|
||
tests_unitaires();
|
||
tests_unitaires();
|
||
|
||
|
||
// Affichage des trames definies dans la table trames.
|
||
printf ("Trames de tests tableau trames:\n");
|
||
int i=0;
|
Formats disponibles : Unified diff
Ajout fonction decode_nombre