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
VIPSSerialProtocol.h
- Committer:
- AndyA
- Date:
- 2021-02-25
- Revision:
- 14:76083dc18b0d
- Parent:
- 3:14d241e29be3
- Child:
- 16:a8d3a0dbe4bf
File content as of revision 14:76083dc18b0d:
#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 Tx, const PinName Rx); void run(void); // 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;} static void getCRC(void *data, int len, void *checksum); // void setOutMask(uint32_t outputMask) {_outputMask = outputMask;}; private: struct posAndTime_s { uint32_t time; position pos; }; void onSerialRx(void); void processRxMessage(); 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); RawSerial _port; unsigned char messageInBuffer[128]; unsigned char messageOutBuffer[16]; #define posHistoryLen 3 struct posAndTime_s lastPositions[posHistoryLen]; int nextPosition; struct posAndTime_s lastPos; // the most recent position received struct posAndTime_s prevPos; // the most last but one position received position outputPosition; position *outputPtr; int messagePrt; int messageLength; int statusMessage; bool enableAllUpdates; bool newFormatMsg; uint32_t pointCount; uint32_t _outputMask; }; #endif