Mdot control and communication for the exosonde

Dependencies:   libmDot-mbed5 mbed

Committer:
brettsawyers
Date:
Mon Aug 28 03:47:42 2017 +0000
Revision:
0:d8d49519a14a
Child:
1:3bb9d88c2646
Currently implemented functinality to request data and recieve the data string from exosonde

Who changed what in which revision?

UserRevisionLine numberNew contents of line
brettsawyers 0:d8d49519a14a 1 #include "mbed.h"
brettsawyers 0:d8d49519a14a 2 #include "mDot.h"
brettsawyers 0:d8d49519a14a 3 #include "MTSLog.h"
brettsawyers 0:d8d49519a14a 4 #include <string>
brettsawyers 0:d8d49519a14a 5 #include <vector>
brettsawyers 0:d8d49519a14a 6 #include <algorithm>
brettsawyers 0:d8d49519a14a 7
brettsawyers 0:d8d49519a14a 8 Serial device(USBTX, USBRX); //will need to change thistoi the appropriate pins once connected ot the exosonde
brettsawyers 0:d8d49519a14a 9 DigitalOut led1(LED1);
brettsawyers 0:d8d49519a14a 10 int main() {
brettsawyers 0:d8d49519a14a 11 char datachar;
brettsawyers 0:d8d49519a14a 12 char* recieved = (char *) malloc(sizeof(char) * 50);;
brettsawyers 0:d8d49519a14a 13 int malloced = 50, charcount = 0;
brettsawyers 0:d8d49519a14a 14 bool commaflag = false;
brettsawyers 0:d8d49519a14a 15 while(datachar = device.getc(),datachar != '\r'){
brettsawyers 0:d8d49519a14a 16 if(!((charcount+1)%malloced)){
brettsawyers 0:d8d49519a14a 17 malloced = malloced*2;
brettsawyers 0:d8d49519a14a 18 recieved = realloc(recieved, malloced);
brettsawyers 0:d8d49519a14a 19 }
brettsawyers 0:d8d49519a14a 20 recieved[charcount] = datachar;
brettsawyers 0:d8d49519a14a 21 charcount++;
brettsawyers 0:d8d49519a14a 22 }
brettsawyers 0:d8d49519a14a 23 }