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:
Thu Jan 28 15:13:05 2021 +0000
Revision:
3:14d241e29be3
Parent:
1:dd1f7e162f91
Child:
14:76083dc18b0d
Added FIZ reading code;

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 3:14d241e29be3 27 // void setOutMask(uint32_t outputMask) {_outputMask = outputMask;};
AndyA 3:14d241e29be3 28
AndyA 0:97661408d0f9 29 private:
AndyA 0:97661408d0f9 30
AndyA 0:97661408d0f9 31 struct posAndTime_s {
AndyA 0:97661408d0f9 32 uint32_t time;
AndyA 0:97661408d0f9 33 position pos;
AndyA 0:97661408d0f9 34 };
AndyA 0:97661408d0f9 35
AndyA 1:dd1f7e162f91 36 void onSerialRx(void);
AndyA 0:97661408d0f9 37 void processRxMessage();
AndyA 0:97661408d0f9 38 bool checkCRC(unsigned char* data);
AndyA 0:97661408d0f9 39 void sendResponse(unsigned char function, unsigned char* data, int dataLen);
AndyA 0:97661408d0f9 40 void sendAck(unsigned char function);
AndyA 0:97661408d0f9 41 void sendNack(unsigned char function);
AndyA 0:97661408d0f9 42 void sendVBOXTime();
AndyA 0:97661408d0f9 43 void parsePostionInput_legacy();
AndyA 0:97661408d0f9 44 void parsePostionInput_mocap();
AndyA 0:97661408d0f9 45 bool checkNewPacketRC(unsigned char* data);
AndyA 1:dd1f7e162f91 46 RawSerial _port;
AndyA 0:97661408d0f9 47 unsigned char messageInBuffer[128];
AndyA 0:97661408d0f9 48 unsigned char messageOutBuffer[16];
AndyA 0:97661408d0f9 49 #define posHistoryLen 3
AndyA 0:97661408d0f9 50 struct posAndTime_s lastPositions[posHistoryLen];
AndyA 0:97661408d0f9 51 int nextPosition;
AndyA 0:97661408d0f9 52
AndyA 0:97661408d0f9 53 position outputPosition;
AndyA 0:97661408d0f9 54 position *outputPtr;
AndyA 0:97661408d0f9 55
AndyA 0:97661408d0f9 56 int messagePrt;
AndyA 0:97661408d0f9 57 int messageLength;
AndyA 0:97661408d0f9 58 int statusMessage;
AndyA 0:97661408d0f9 59 bool enableAllUpdates;
AndyA 0:97661408d0f9 60 bool newFormatMsg;
AndyA 0:97661408d0f9 61 uint32_t pointCount;
AndyA 3:14d241e29be3 62 uint32_t _outputMask;
AndyA 0:97661408d0f9 63
AndyA 0:97661408d0f9 64 };
AndyA 0:97661408d0f9 65
AndyA 0:97661408d0f9 66 #endif