this version has all of Jim's fixes for reading the GPS and IMU data synchronously
Dependencies: MODSERIAL SDFileSystem mbed SDShell CRC CommHandler FP LinkedList LogUtil
PCMessaging.h
- Committer:
- jekain314
- Date:
- 2014-01-09
- Revision:
- 29:dead10cce6e9
- Parent:
- 26:c2208b0ff78b
- Child:
- 30:96d133f3008e
File content as of revision 29:dead10cce6e9:
//these are defines for the messages that are sent from the PC across the USB //these messages produce reactions on the mbed const unsigned char FIRE_TRIGGER_MSG = 1; const unsigned short serBuffMax = 18; char serBuf[serBuffMax]; int serBufChars=0; //flags to control the PC command actions bool fireTrigger =false; unsigned char CR = 0x0d; //ASCII Carriage Return unsigned char LF = 0x0a; //ASCII Line Feed bool validMessage = false; void readFromPC() { // should this be a while rather than if ??? -- may have multiple bytes in buffer if (toPC.readable()) //read a PC serial byte and test it for a command { // Read in next character // why not read all available bytes unsigned char inChar = 0; inChar = toPC.getc(); //read char from the USB serial link to the PC //incoming messages will end witb a CR / LF -- disregard these chars if (inChar == CR || inChar == LF) return; //CR is a 0x0a //all incoming messages will start with "mbedMessage", "messageType", numberDataBytes, and will end with CR & LF //1) look for the mbedMessage and then get the next byte as numberDataBytes; //2) read the next numberDataBytes and then look for CR & LF //if 1) & 2) are successful, declare a valid incoming message //if message is valid, then send a response as a repeat of the original message // } //end pc.readable };