I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later

Dependencies:   BufferedSerial FatFileSystemCpp mbed

Committer:
AndyA
Date:
Fri Jan 15 15:44:39 2021 +0000
Revision:
1:dd1f7e162f91
Parent:
0:97661408d0f9
Child:
3:14d241e29be3
2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AndyA 0:97661408d0f9 1 #ifndef __VIPSSERIALPROTOCOL_H__
AndyA 0:97661408d0f9 2 #define __VIPSSERIALPROTOCOL_H__
AndyA 0:97661408d0f9 3
AndyA 0:97661408d0f9 4 #include "mbed.h"
AndyA 0:97661408d0f9 5 #include "position.h"
AndyA 0:97661408d0f9 6 #include "BufferedSerial.h"
AndyA 0:97661408d0f9 7
AndyA 0:97661408d0f9 8 extern const char* VIPSStatusMessages[];
AndyA 0:97661408d0f9 9
AndyA 0:97661408d0f9 10 class VIPSSerial {
AndyA 0:97661408d0f9 11
AndyA 0:97661408d0f9 12 public:
AndyA 0:97661408d0f9 13
AndyA 1:dd1f7e162f91 14 VIPSSerial(const PinName Tx, const PinName Rx);
AndyA 0:97661408d0f9 15 int getStatusMessage() {int tmp=statusMessage; statusMessage=0; return tmp;}
AndyA 1:dd1f7e162f91 16 void run(void);
AndyA 0:97661408d0f9 17
AndyA 0:97661408d0f9 18 // send all position outputs rather than just when requested.
AndyA 0:97661408d0f9 19 void sendAllUpdated(bool enable);
AndyA 0:97661408d0f9 20
AndyA 0:97661408d0f9 21 // send a position output for the requested time. Times are based on the global TimeSinceLastFrame timer.
AndyA 0:97661408d0f9 22 position* sendPositionForTime(uint32_t timeValue);
AndyA 0:97661408d0f9 23 position* getWaitingPostion() {position *ptr = outputPtr; outputPtr=NULL; return ptr;}
AndyA 0:97661408d0f9 24
AndyA 1:dd1f7e162f91 25 static void getCRC(void *data, int len, void *checksum);
AndyA 1:dd1f7e162f91 26
AndyA 0:97661408d0f9 27 private:
AndyA 0:97661408d0f9 28
AndyA 0:97661408d0f9 29 struct posAndTime_s {
AndyA 0:97661408d0f9 30 uint32_t time;
AndyA 0:97661408d0f9 31 position pos;
AndyA 0:97661408d0f9 32 };
AndyA 0:97661408d0f9 33
AndyA 1:dd1f7e162f91 34 void onSerialRx(void);
AndyA 0:97661408d0f9 35 void processRxMessage();
AndyA 0:97661408d0f9 36 bool checkCRC(unsigned char* data);
AndyA 0:97661408d0f9 37 void sendResponse(unsigned char function, unsigned char* data, int dataLen);
AndyA 0:97661408d0f9 38 void sendAck(unsigned char function);
AndyA 0:97661408d0f9 39 void sendNack(unsigned char function);
AndyA 0:97661408d0f9 40 void sendVBOXTime();
AndyA 0:97661408d0f9 41 void parsePostionInput_legacy();
AndyA 0:97661408d0f9 42 void parsePostionInput_mocap();
AndyA 0:97661408d0f9 43 bool checkNewPacketRC(unsigned char* data);
AndyA 1:dd1f7e162f91 44 RawSerial _port;
AndyA 0:97661408d0f9 45 unsigned char messageInBuffer[128];
AndyA 0:97661408d0f9 46 unsigned char messageOutBuffer[16];
AndyA 0:97661408d0f9 47 #define posHistoryLen 3
AndyA 0:97661408d0f9 48 struct posAndTime_s lastPositions[posHistoryLen];
AndyA 0:97661408d0f9 49 int nextPosition;
AndyA 0:97661408d0f9 50
AndyA 0:97661408d0f9 51 position outputPosition;
AndyA 0:97661408d0f9 52 position *outputPtr;
AndyA 0:97661408d0f9 53
AndyA 0:97661408d0f9 54 int messagePrt;
AndyA 0:97661408d0f9 55 int messageLength;
AndyA 0:97661408d0f9 56 int statusMessage;
AndyA 0:97661408d0f9 57 bool enableAllUpdates;
AndyA 0:97661408d0f9 58 bool newFormatMsg;
AndyA 0:97661408d0f9 59 uint32_t pointCount;
AndyA 0:97661408d0f9 60
AndyA 0:97661408d0f9 61 };
AndyA 0:97661408d0f9 62
AndyA 0:97661408d0f9 63 #endif