Révision 128
Ajouté par mamoisan il y a environ 4 ans
main.c | ||
---|---|---|
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include <strings.h>
|
||
#include <math.h>
|
||
#include "trame.h"
|
||
|
||
//Trames de tests ? modifier si n?cessaire.
|
||
... | ... | |
return result;
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
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);
|
||
}
|
||
}
|
||
|
||
int decode_int(char a)
|
||
{
|
||
if((a>'0') && (a<'9'))
|
||
if((a>='0') && (a<='9'))
|
||
{
|
||
return (a-48);
|
||
} else
|
||
... | ... | |
{
|
||
int i;
|
||
int res=0;
|
||
for (i=0;i<=n;i++)
|
||
for (i=0;i<n;i++)
|
||
{
|
||
res += pow(10,(n-i-1))*decode_int(ch[i]);
|
||
}
|
||
... | ... | |
exit(-1);
|
||
}
|
||
}
|
||
|
||
float latDMStoDec(char * lat_DMS)
|
||
{
|
||
float deg = decode_nombre(lat_DMS,2);
|
||
float min = decode_int(lat_DMS[2])*10+decode_int(lat_DMS[3])+(0.1*decode_int(lat_DMS[5]))+(0.01*decode_int(lat_DMS[6]))+(0.001*decode_int(lat_DMS[7]))+(0.0001*decode_int(lat_DMS[8]));
|
||
float latDec = deg+(min/60);
|
||
return latDec;
|
||
}
|
||
|
||
void test_latDMStoDec(void)
|
||
{
|
||
if (latDMStoDec("3723.2475")!= 37.387458){
|
||
printf ("Erreur Test decode_nombre.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
float lonDMStoDec(char * lon_DMS)
|
||
{
|
||
float deg = decode_nombre(lon_DMS,3);
|
||
float min = decode_int(lon_DMS[3])*10+decode_int(lon_DMS[4])+(0.1*decode_int(lon_DMS[6]))+(0.01*decode_int(lon_DMS[7]))+(0.001*decode_int(lon_DMS[8]))+(0.0001*decode_int(lon_DMS[9]));
|
||
float lonDec = deg+(min/60);
|
||
return lonDec;
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
... | ... | |
printf ("> %s\n",trame);
|
||
}
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
}
|
||
if (trame_cmp("$GPGGA suite chaine","GPGGA")!=1){
|
||
printf ("Erreur Test unitaire trame_cmp.\n");
|
||
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);
|
||
}
|
||
test_decode_nombre();
|
||
test_decode_int();
|
||
test_latDMStoDec();
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
Formats disponibles : Unified diff