essential classes for arianna station protocol
SnHeaderFrame.h@7:4dcfa12d4fe9, 2015-10-30 (annotated)
- Committer:
- uci1
- Date:
- Fri Oct 30 04:21:18 2015 +0000
- Revision:
- 7:4dcfa12d4fe9
- Parent:
- 6:3ee695731d92
- Child:
- 8:5c7ce687524f
Add StatusDataPack, StatusUpdateDone and StatusDataPackDone header codes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 0:df529a435193 | 1 | #ifndef SNS_SnHeaderFrame |
uci1 | 0:df529a435193 | 2 | #define SNS_SnHeaderFrame |
uci1 | 0:df529a435193 | 3 | |
uci1 | 0:df529a435193 | 4 | #include <stdint.h> |
uci1 | 0:df529a435193 | 5 | |
uci1 | 0:df529a435193 | 6 | #include "SnBitUtils.h" |
uci1 | 0:df529a435193 | 7 | |
uci1 | 0:df529a435193 | 8 | class SnHeaderFrame { |
uci1 | 0:df529a435193 | 9 | public: |
uci1 | 0:df529a435193 | 10 | // |
uci1 | 0:df529a435193 | 11 | // A simple class to function like namespace. |
uci1 | 0:df529a435193 | 12 | // The header for each i/o message is read/sent from here, in order to |
uci1 | 0:df529a435193 | 13 | // ensure consistency across the communication methods. |
uci1 | 0:df529a435193 | 14 | // |
uci1 | 0:df529a435193 | 15 | |
uci1 | 0:df529a435193 | 16 | static const uint32_t kMaxSizeOf = sizeof(uint8_t) + sizeof(uint32_t); |
uci1 | 0:df529a435193 | 17 | |
uci1 | 0:df529a435193 | 18 | // these are not in an enum so that we can control their size in bytes (1 byte) |
uci1 | 6:3ee695731d92 | 19 | // the values should NEVER change |
uci1 | 0:df529a435193 | 20 | static const uint8_t kStatusCode = 0x10; |
uci1 | 7:4dcfa12d4fe9 | 21 | static const uint8_t kStatusDataPack = 0x12; // signal that some data (config, event, etc) is being sent in a status update |
uci1 | 7:4dcfa12d4fe9 | 22 | static const uint8_t kStatusUpdDone = 0x13; // signal the end of the status update (status i/o V9+) |
uci1 | 7:4dcfa12d4fe9 | 23 | static const uint8_t kStatusDatPakDone= 0x14; // signal the end of the status data packs (status i/o version 9+) |
uci1 | 0:df529a435193 | 24 | static const uint8_t kFileCode = 0x20; |
uci1 | 0:df529a435193 | 25 | static const uint8_t kFilenameCode = 0x23; |
uci1 | 4:9f7e3fb5394d | 26 | static const uint8_t kFileTrgStrtCode = 0x24; |
uci1 | 4:9f7e3fb5394d | 27 | static const uint8_t kFileTrgStopCode = 0x25; |
uci1 | 0:df529a435193 | 28 | static const uint8_t kFileNevtsCode = 0x26; |
uci1 | 0:df529a435193 | 29 | static const uint8_t kFileNpwrsCode = 0x28; |
uci1 | 0:df529a435193 | 30 | static const uint8_t kFileHeadrCode = 0x2A; |
uci1 | 0:df529a435193 | 31 | static const uint8_t kFileReadFailCode= 0x2C; |
uci1 | 0:df529a435193 | 32 | static const uint8_t kMbedFileCode = 0x30; |
uci1 | 0:df529a435193 | 33 | static const uint8_t kMbedFilenameCode= 0x33; |
uci1 | 0:df529a435193 | 34 | static const uint8_t kMbedFileChksCode= 0x35; |
uci1 | 0:df529a435193 | 35 | static const uint8_t kConfigCode = 0x40; |
uci1 | 0:df529a435193 | 36 | static const uint8_t kEventCode = 0x50; |
uci1 | 0:df529a435193 | 37 | static const uint8_t kHndShkBits = 0x60; // all handshakes have these bits set |
uci1 | 0:df529a435193 | 38 | static const uint8_t kHnShOkComplCode = 0x61; |
uci1 | 6:3ee695731d92 | 39 | static const uint8_t kHnShOkRqPtRnCode= 0x62; // partial run req |
uci1 | 6:3ee695731d92 | 40 | static const uint8_t kHnShOkRqPtSqCode= 0x63; // [minseq,maxseq] of partial run req |
uci1 | 0:df529a435193 | 41 | static const uint8_t kHnShOkPartlCode = 0x64; |
uci1 | 3:fc27e024ad2d | 42 | static const uint8_t kHnShOkReqRnCode = 0x65; |
uci1 | 0:df529a435193 | 43 | static const uint8_t kHnShOkStopCode = 0x66; |
uci1 | 0:df529a435193 | 44 | static const uint8_t kHnShOkDelRnCode = 0x67; |
uci1 | 0:df529a435193 | 45 | static const uint8_t kHnShOkDelAlCode = 0x68; |
uci1 | 6:3ee695731d92 | 46 | static const uint8_t kHnShOkClRSLCode = 0x69; // clear run/seq list since last comm win file |
uci1 | 0:df529a435193 | 47 | static const uint8_t kHnShFailPrtCode = 0x6A; |
uci1 | 0:df529a435193 | 48 | static const uint8_t kHnShFailNonCode = 0x6C; |
uci1 | 4:9f7e3fb5394d | 49 | static const uint8_t kHnShDemandCode = 0x6E; |
uci1 | 4:9f7e3fb5394d | 50 | static const uint8_t kHnShNoReplyCode = 0x6F; |
uci1 | 0:df529a435193 | 51 | static const uint8_t kPowerCode = 0x70; |
uci1 | 6:3ee695731d92 | 52 | static const uint8_t kTemperatureCode = 0x74; |
uci1 | 0:df529a435193 | 53 | static const uint8_t kHeartbeatCode = 0x78; |
uci1 | 0:df529a435193 | 54 | static const uint8_t kNoConfigCode = 0x80; |
uci1 | 0:df529a435193 | 55 | static const uint8_t kSbdMsgCode = 0x90; |
uci1 | 0:df529a435193 | 56 | static const uint8_t kStringCode = 0xA0; // a debug string |
uci1 | 5:ef4c7dfbf8cf | 57 | static const uint8_t kSignalStrCode = 0xB0; |
uci1 | 0:df529a435193 | 58 | |
uci1 | 0:df529a435193 | 59 | private: |
uci1 | 0:df529a435193 | 60 | static char fgHdBuf[kMaxSizeOf]; |
uci1 | 0:df529a435193 | 61 | |
uci1 | 0:df529a435193 | 62 | public: |
uci1 | 0:df529a435193 | 63 | |
uci1 | 0:df529a435193 | 64 | static |
uci1 | 0:df529a435193 | 65 | char* GetHdBuf(const uint8_t mcode, const uint32_t mlen) { |
uci1 | 0:df529a435193 | 66 | char* b = fgHdBuf; |
uci1 | 0:df529a435193 | 67 | WriteTo(b, mcode, mlen); |
uci1 | 0:df529a435193 | 68 | return fgHdBuf; |
uci1 | 0:df529a435193 | 69 | } |
uci1 | 0:df529a435193 | 70 | |
uci1 | 0:df529a435193 | 71 | template<class T> |
uci1 | 0:df529a435193 | 72 | static |
uci1 | 1:28f2a824223d | 73 | bool WriteTo(T& x, |
uci1 | 1:28f2a824223d | 74 | const uint8_t msgCode, |
uci1 | 1:28f2a824223d | 75 | const uint32_t msgLen) { |
uci1 | 4:9f7e3fb5394d | 76 | // expect 'x' to be a MODSERIAL or a char const* or a FILE* |
uci1 | 0:df529a435193 | 77 | x = SnBitUtils::WriteTo(x, msgCode); |
uci1 | 0:df529a435193 | 78 | x = SnBitUtils::WriteTo(x, msgLen); |
uci1 | 1:28f2a824223d | 79 | return true; |
uci1 | 0:df529a435193 | 80 | } |
uci1 | 0:df529a435193 | 81 | |
uci1 | 0:df529a435193 | 82 | template<class T> |
uci1 | 0:df529a435193 | 83 | static |
uci1 | 1:28f2a824223d | 84 | bool ReadFrom(T& b, |
uci1 | 1:28f2a824223d | 85 | uint8_t& msgCode, |
uci1 | 1:28f2a824223d | 86 | uint32_t& msgLen) { |
uci1 | 1:28f2a824223d | 87 | b = SnBitUtils::ReadFrom(b, msgCode); |
uci1 | 1:28f2a824223d | 88 | b = SnBitUtils::ReadFrom(b, msgLen); |
uci1 | 1:28f2a824223d | 89 | return true; |
uci1 | 0:df529a435193 | 90 | } |
uci1 | 0:df529a435193 | 91 | |
uci1 | 0:df529a435193 | 92 | static |
uci1 | 0:df529a435193 | 93 | uint32_t SizeOf() { |
uci1 | 0:df529a435193 | 94 | return kMaxSizeOf; |
uci1 | 0:df529a435193 | 95 | } |
uci1 | 0:df529a435193 | 96 | |
uci1 | 0:df529a435193 | 97 | }; |
uci1 | 0:df529a435193 | 98 | |
uci1 | 0:df529a435193 | 99 | #endif // SNS_SnHeaderFrame |