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@14:76083dc18b0d, 2021-02-25 (annotated)
- Committer:
- AndyA
- Date:
- Thu Feb 25 17:54:04 2021 +0000
- Revision:
- 14:76083dc18b0d
- Parent:
- 3:14d241e29be3
- Child:
- 16:a8d3a0dbe4bf
Disabled USB
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 | 1:dd1f7e162f91 | 14 | VIPSSerial(const PinName Tx, const PinName Rx); |
AndyA | 1:dd1f7e162f91 | 15 | void run(void); |
AndyA | 0:97661408d0f9 | 16 | |
AndyA | 0:97661408d0f9 | 17 | // send all position outputs rather than just when requested. |
AndyA | 0:97661408d0f9 | 18 | void sendAllUpdated(bool enable); |
AndyA | 0:97661408d0f9 | 19 | |
AndyA | 0:97661408d0f9 | 20 | // send a position output for the requested time. Times are based on the global TimeSinceLastFrame timer. |
AndyA | 0:97661408d0f9 | 21 | position* sendPositionForTime(uint32_t timeValue); |
AndyA | 0:97661408d0f9 | 22 | position* getWaitingPostion() {position *ptr = outputPtr; outputPtr=NULL; return ptr;} |
AndyA | 0:97661408d0f9 | 23 | |
AndyA | 1:dd1f7e162f91 | 24 | static void getCRC(void *data, int len, void *checksum); |
AndyA | 1:dd1f7e162f91 | 25 | |
AndyA | 3:14d241e29be3 | 26 | // void setOutMask(uint32_t outputMask) {_outputMask = outputMask;}; |
AndyA | 3:14d241e29be3 | 27 | |
AndyA | 0:97661408d0f9 | 28 | private: |
AndyA | 0:97661408d0f9 | 29 | |
AndyA | 0:97661408d0f9 | 30 | struct posAndTime_s { |
AndyA | 0:97661408d0f9 | 31 | uint32_t time; |
AndyA | 0:97661408d0f9 | 32 | position pos; |
AndyA | 0:97661408d0f9 | 33 | }; |
AndyA | 0:97661408d0f9 | 34 | |
AndyA | 1:dd1f7e162f91 | 35 | void onSerialRx(void); |
AndyA | 0:97661408d0f9 | 36 | void processRxMessage(); |
AndyA | 0:97661408d0f9 | 37 | bool checkCRC(unsigned char* data); |
AndyA | 0:97661408d0f9 | 38 | void sendResponse(unsigned char function, unsigned char* data, int dataLen); |
AndyA | 0:97661408d0f9 | 39 | void sendAck(unsigned char function); |
AndyA | 0:97661408d0f9 | 40 | void sendNack(unsigned char function); |
AndyA | 0:97661408d0f9 | 41 | void sendVBOXTime(); |
AndyA | 0:97661408d0f9 | 42 | void parsePostionInput_legacy(); |
AndyA | 0:97661408d0f9 | 43 | void parsePostionInput_mocap(); |
AndyA | 0:97661408d0f9 | 44 | bool checkNewPacketRC(unsigned char* data); |
AndyA | 1:dd1f7e162f91 | 45 | RawSerial _port; |
AndyA | 0:97661408d0f9 | 46 | unsigned char messageInBuffer[128]; |
AndyA | 0:97661408d0f9 | 47 | unsigned char messageOutBuffer[16]; |
AndyA | 0:97661408d0f9 | 48 | #define posHistoryLen 3 |
AndyA | 0:97661408d0f9 | 49 | struct posAndTime_s lastPositions[posHistoryLen]; |
AndyA | 0:97661408d0f9 | 50 | int nextPosition; |
AndyA | 14:76083dc18b0d | 51 | struct posAndTime_s lastPos; // the most recent position received |
AndyA | 14:76083dc18b0d | 52 | struct posAndTime_s prevPos; // the most last but one position received |
AndyA | 0:97661408d0f9 | 53 | |
AndyA | 0:97661408d0f9 | 54 | position outputPosition; |
AndyA | 0:97661408d0f9 | 55 | position *outputPtr; |
AndyA | 0:97661408d0f9 | 56 | |
AndyA | 0:97661408d0f9 | 57 | int messagePrt; |
AndyA | 0:97661408d0f9 | 58 | int messageLength; |
AndyA | 0:97661408d0f9 | 59 | int statusMessage; |
AndyA | 0:97661408d0f9 | 60 | bool enableAllUpdates; |
AndyA | 0:97661408d0f9 | 61 | bool newFormatMsg; |
AndyA | 0:97661408d0f9 | 62 | uint32_t pointCount; |
AndyA | 3:14d241e29be3 | 63 | uint32_t _outputMask; |
AndyA | 0:97661408d0f9 | 64 | |
AndyA | 0:97661408d0f9 | 65 | }; |
AndyA | 0:97661408d0f9 | 66 | |
AndyA | 0:97661408d0f9 | 67 | #endif |