test

main.cpp

Committer:
valentinbruchet
Date:
2020-12-09
Revision:
0:9985114fbde9

File content as of revision 0:9985114fbde9:

#include "mbed.h"

Serial xbee(PB_6,PB_7); //Initalise xbee_lib
Serial pc(USBTX, USBRX); //Initalise PC serial comms

int valeur1;
int valeur2;
int valeur3;
int valeur4;
int valeur5;
int valeur6;
int i;

char recu[20];
char data1[3];
char data2[3];
char data3[3];
char data4[3];
char data5[3];
char data6[3];

int main()
{
    while(1) 
         {
               while(xbee.getc()!=('$'));
               while(xbee.getc()!=('C')); 
               while(xbee.getc()!=('H')); 
               while(xbee.getc()!=('R')); 
               while(xbee.getc()!=('O')); 
               while(xbee.getc()!=('N')); 
               while(xbee.getc()!=('O'));
               
               while(i<7)
               {
                   recu[i]=xbee.getc();
                   i=i+1;
                }
                i=0;
                
                data1[0]=recu[0];
                data1[1]=recu[1];
                data2[0]=recu[3];
                data2[1]=recu[4];
                data3[0]=recu[6];
                data3[1]=recu[7];
                data4[0]=recu[9];
                data4[1]=recu[10];
                data5[0]=recu[12];
                data5[1]=recu[13];
                data6[0]=recu[15];
                data6[1]=recu[16];
                
                valeur1=atoi(data1); 
                valeur2=atoi(data2);
                valeur3=atoi(data3);
                valeur4=atoi(data4);
                valeur5=atoi(data5);
                valeur6=atoi(data6);
                
                pc.printf("Chronometre candidat 1 : %i:%i:%i\n\r", valeur1, valeur2, valeur3);   
                pc.printf("Chronometre candidat 2 : %i:%i:%i\n\r", valeur4, valeur5, valeur6);   
          }
}