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@0:97661408d0f9, 2021-01-15 (annotated)
- Committer:
- AndyA
- Date:
- Fri Jan 15 11:49:01 2021 +0000
- Revision:
- 0:97661408d0f9
- Child:
- 1:dd1f7e162f91
first;
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:97661408d0f9 | 14 | VIPSSerial(const PinName Rx, const PinName Tx); |
AndyA | 0:97661408d0f9 | 15 | void onSerialRx(); |
AndyA | 0:97661408d0f9 | 16 | int getStatusMessage() {int tmp=statusMessage; statusMessage=0; return tmp;} |
AndyA | 0:97661408d0f9 | 17 | void fakeRX(); |
AndyA | 0:97661408d0f9 | 18 | |
AndyA | 0:97661408d0f9 | 19 | // send all position outputs rather than just when requested. |
AndyA | 0:97661408d0f9 | 20 | void sendAllUpdated(bool enable); |
AndyA | 0:97661408d0f9 | 21 | |
AndyA | 0:97661408d0f9 | 22 | // send a position output for the requested time. Times are based on the global TimeSinceLastFrame timer. |
AndyA | 0:97661408d0f9 | 23 | position* sendPositionForTime(uint32_t timeValue); |
AndyA | 0:97661408d0f9 | 24 | position* getWaitingPostion() {position *ptr = outputPtr; outputPtr=NULL; return ptr;} |
AndyA | 0:97661408d0f9 | 25 | |
AndyA | 0:97661408d0f9 | 26 | private: |
AndyA | 0:97661408d0f9 | 27 | |
AndyA | 0:97661408d0f9 | 28 | struct posAndTime_s { |
AndyA | 0:97661408d0f9 | 29 | uint32_t time; |
AndyA | 0:97661408d0f9 | 30 | position pos; |
AndyA | 0:97661408d0f9 | 31 | }; |
AndyA | 0:97661408d0f9 | 32 | |
AndyA | 0:97661408d0f9 | 33 | void processRxMessage(); |
AndyA | 0:97661408d0f9 | 34 | void getCRC(unsigned char* data, int len, unsigned char* checksum); |
AndyA | 0:97661408d0f9 | 35 | bool checkCRC(unsigned char* data); |
AndyA | 0:97661408d0f9 | 36 | void sendResponse(unsigned char function, unsigned char* data, int dataLen); |
AndyA | 0:97661408d0f9 | 37 | void sendAck(unsigned char function); |
AndyA | 0:97661408d0f9 | 38 | void sendNack(unsigned char function); |
AndyA | 0:97661408d0f9 | 39 | void sendVBOXTime(); |
AndyA | 0:97661408d0f9 | 40 | void parsePostionInput_legacy(); |
AndyA | 0:97661408d0f9 | 41 | void parsePostionInput_mocap(); |
AndyA | 0:97661408d0f9 | 42 | bool checkNewPacketRC(unsigned char* data); |
AndyA | 0:97661408d0f9 | 43 | BufferedSerial _port; |
AndyA | 0:97661408d0f9 | 44 | unsigned char messageInBuffer[128]; |
AndyA | 0:97661408d0f9 | 45 | unsigned char messageOutBuffer[16]; |
AndyA | 0:97661408d0f9 | 46 | #define posHistoryLen 3 |
AndyA | 0:97661408d0f9 | 47 | struct posAndTime_s lastPositions[posHistoryLen]; |
AndyA | 0:97661408d0f9 | 48 | int nextPosition; |
AndyA | 0:97661408d0f9 | 49 | |
AndyA | 0:97661408d0f9 | 50 | position outputPosition; |
AndyA | 0:97661408d0f9 | 51 | position *outputPtr; |
AndyA | 0:97661408d0f9 | 52 | |
AndyA | 0:97661408d0f9 | 53 | int messagePrt; |
AndyA | 0:97661408d0f9 | 54 | int messageLength; |
AndyA | 0:97661408d0f9 | 55 | int statusMessage; |
AndyA | 0:97661408d0f9 | 56 | bool enableAllUpdates; |
AndyA | 0:97661408d0f9 | 57 | bool newFormatMsg; |
AndyA | 0:97661408d0f9 | 58 | uint32_t pointCount; |
AndyA | 0:97661408d0f9 | 59 | |
AndyA | 0:97661408d0f9 | 60 | }; |
AndyA | 0:97661408d0f9 | 61 | |
AndyA | 0:97661408d0f9 | 62 | #endif |