![](/media/cache/group/Racelogic_Blue_Logo.jpg.50x50_q85.jpg)
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
Diff: VIPSSerialProtocol.h
- Revision:
- 0:97661408d0f9
- Child:
- 1:dd1f7e162f91
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VIPSSerialProtocol.h Fri Jan 15 11:49:01 2021 +0000 @@ -0,0 +1,62 @@ +#ifndef __VIPSSERIALPROTOCOL_H__ +#define __VIPSSERIALPROTOCOL_H__ + +#include "mbed.h" +#include "position.h" +#include "BufferedSerial.h" + +extern const char* VIPSStatusMessages[]; + +class VIPSSerial { + +public: + + VIPSSerial(const PinName Rx, const PinName Tx); + void onSerialRx(); + int getStatusMessage() {int tmp=statusMessage; statusMessage=0; return tmp;} + void fakeRX(); + + // send all position outputs rather than just when requested. + void sendAllUpdated(bool enable); + + // send a position output for the requested time. Times are based on the global TimeSinceLastFrame timer. + position* sendPositionForTime(uint32_t timeValue); + position* getWaitingPostion() {position *ptr = outputPtr; outputPtr=NULL; return ptr;} + +private: + + struct posAndTime_s { + uint32_t time; + position pos; + }; + + void processRxMessage(); + void getCRC(unsigned char* data, int len, unsigned char* checksum); + bool checkCRC(unsigned char* data); + void sendResponse(unsigned char function, unsigned char* data, int dataLen); + void sendAck(unsigned char function); + void sendNack(unsigned char function); + void sendVBOXTime(); + void parsePostionInput_legacy(); + void parsePostionInput_mocap(); + bool checkNewPacketRC(unsigned char* data); + BufferedSerial _port; + unsigned char messageInBuffer[128]; + unsigned char messageOutBuffer[16]; + #define posHistoryLen 3 + struct posAndTime_s lastPositions[posHistoryLen]; + int nextPosition; + + position outputPosition; + position *outputPtr; + + int messagePrt; + int messageLength; + int statusMessage; + bool enableAllUpdates; + bool newFormatMsg; + uint32_t pointCount; + +}; + +#endif