Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnCommWin.h@12:d472f9811262, 2012-08-18 (annotated)
- Committer:
- uci1
- Date:
- Sat Aug 18 05:00:32 2012 +0000
- Revision:
- 12:d472f9811262
- Parent:
- 10:3c93db1cfb12
- Child:
- 15:f2569d8e4176
Fixed bug in throttling timers. Now evt stores dt of triggers but throttle works on dt of events. AfarTCP communication possibly done. Debug output put behind precompiler macros.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 1:e392595b4b76 | 1 | #ifndef SN_SnCommWin |
uci1 | 1:e392595b4b76 | 2 | #define SN_SnCommWin |
uci1 | 1:e392595b4b76 | 3 | |
uci1 | 1:e392595b4b76 | 4 | #include "mbed.h" |
uci1 | 1:e392595b4b76 | 5 | #include <stdint.h> |
uci1 | 1:e392595b4b76 | 6 | |
uci1 | 8:95a325df1f6b | 7 | #include "SnConfigFrame.h" |
uci1 | 1:e392595b4b76 | 8 | class SnEventFrame; |
uci1 | 8:95a325df1f6b | 9 | class SnPowerFrame; |
uci1 | 1:e392595b4b76 | 10 | |
uci1 | 1:e392595b4b76 | 11 | // ABC for communication types |
uci1 | 1:e392595b4b76 | 12 | |
uci1 | 1:e392595b4b76 | 13 | class SnCommWin { |
uci1 | 1:e392595b4b76 | 14 | public: |
uci1 | 1:e392595b4b76 | 15 | enum ECommWinResult { |
uci1 | 1:e392595b4b76 | 16 | kUndefFail, // undefined fail type |
uci1 | 1:e392595b4b76 | 17 | kCanNotConnect, // unable to connect to port |
uci1 | 1:e392595b4b76 | 18 | kFailTimeout, // timed out but message required |
uci1 | 2:e67f7c158087 | 19 | kFailNoneSent, // none of the message sent |
uci1 | 1:e392595b4b76 | 20 | kFailPartSent, // only part of the message sent |
uci1 | 3:24c5f0f50bf1 | 21 | kUnexpectedRec, // unexpected / unhandled message received |
uci1 | 1:e392595b4b76 | 22 | kAllFails, // to be used for "if (ret > kAllFails) ==> success" |
uci1 | 1:e392595b4b76 | 23 | // only successes should go below |
uci1 | 1:e392595b4b76 | 24 | kConnected, // connection established, no messaging attempted |
uci1 | 1:e392595b4b76 | 25 | kOkMsgSent, // message sent without waiting for "received" handshake |
uci1 | 1:e392595b4b76 | 26 | kOkNoMsg, // timed out with no message, but that is ok |
uci1 | 12:d472f9811262 | 27 | kOkWithMsg, // successfully received message |
uci1 | 12:d472f9811262 | 28 | kOkWthMsgNoConf // successfully received message and it says to stick with the same config |
uci1 | 1:e392595b4b76 | 29 | }; |
uci1 | 2:e67f7c158087 | 30 | |
uci1 | 1:e392595b4b76 | 31 | |
uci1 | 3:24c5f0f50bf1 | 32 | protected: |
uci1 | 12:d472f9811262 | 33 | virtual int SendFileBlock(FILE* inf, |
uci1 | 12:d472f9811262 | 34 | const uint8_t blockHeaderCode, |
uci1 | 12:d472f9811262 | 35 | const uint32_t blockSize, |
uci1 | 12:d472f9811262 | 36 | char* const genBuf, |
uci1 | 12:d472f9811262 | 37 | const uint32_t timeout); |
uci1 | 12:d472f9811262 | 38 | |
uci1 | 8:95a325df1f6b | 39 | virtual ECommWinResult SendFileContents(FILE* inf, |
uci1 | 8:95a325df1f6b | 40 | const SnConfigFrame& curConf, |
uci1 | 8:95a325df1f6b | 41 | SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 42 | SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 43 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 44 | uint32_t nevts, |
uci1 | 12:d472f9811262 | 45 | const uint32_t timeout_clock); |
uci1 | 8:95a325df1f6b | 46 | |
uci1 | 8:95a325df1f6b | 47 | virtual SnConfigFrame::EDatPackBit GetCommType() const=0; |
uci1 | 8:95a325df1f6b | 48 | |
uci1 | 8:95a325df1f6b | 49 | virtual int32_t ReceiveAll(char* const buf, const uint32_t mlen, |
uci1 | 8:95a325df1f6b | 50 | const uint32_t timeout_clock)=0; |
uci1 | 8:95a325df1f6b | 51 | virtual int32_t SendAll(char* const data, const uint32_t length, |
uci1 | 8:95a325df1f6b | 52 | const uint32_t timeout_clock)=0; |
uci1 | 12:d472f9811262 | 53 | |
uci1 | 12:d472f9811262 | 54 | bool IsTimedOut(const uint32_t timeout_clock) const; |
uci1 | 8:95a325df1f6b | 55 | |
uci1 | 12:d472f9811262 | 56 | |
uci1 | 1:e392595b4b76 | 57 | public: |
uci1 | 1:e392595b4b76 | 58 | virtual ~SnCommWin() {} |
uci1 | 1:e392595b4b76 | 59 | |
uci1 | 8:95a325df1f6b | 60 | virtual void Set(const SnConfigFrame& conf)=0; |
uci1 | 8:95a325df1f6b | 61 | |
uci1 | 1:e392595b4b76 | 62 | virtual ECommWinResult OpenWindow(const uint32_t timeout, |
uci1 | 1:e392595b4b76 | 63 | const bool sendStatus, |
uci1 | 1:e392595b4b76 | 64 | const SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 65 | const SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 66 | const SnPowerFrame& pow, |
uci1 | 10:3c93db1cfb12 | 67 | const uint16_t seq, |
uci1 | 10:3c93db1cfb12 | 68 | const float thmrate, |
uci1 | 10:3c93db1cfb12 | 69 | const float evtrate, |
uci1 | 2:e67f7c158087 | 70 | char* const genBuf)=0; |
uci1 | 1:e392595b4b76 | 71 | |
uci1 | 1:e392595b4b76 | 72 | virtual bool Connect(const uint32_t timeout)=0; |
uci1 | 12:d472f9811262 | 73 | virtual bool CloseConn()=0; |
uci1 | 12:d472f9811262 | 74 | |
uci1 | 3:24c5f0f50bf1 | 75 | virtual ECommWinResult WaitHandshake(const uint32_t timeout, |
uci1 | 3:24c5f0f50bf1 | 76 | char* const buf, |
uci1 | 6:6f002d202f59 | 77 | const uint32_t bsize, |
uci1 | 8:95a325df1f6b | 78 | uint8_t& hndShkCode); |
uci1 | 3:24c5f0f50bf1 | 79 | |
uci1 | 8:95a325df1f6b | 80 | ECommWinResult GetConfig(SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 81 | const uint32_t timeOut, |
uci1 | 8:95a325df1f6b | 82 | char* const confBuf, |
uci1 | 8:95a325df1f6b | 83 | const uint32_t bsize); |
uci1 | 1:e392595b4b76 | 84 | |
uci1 | 8:95a325df1f6b | 85 | ECommWinResult SendStatus(const SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 86 | const SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 87 | const SnPowerFrame& pow, |
uci1 | 10:3c93db1cfb12 | 88 | const uint16_t seq, |
uci1 | 10:3c93db1cfb12 | 89 | const float thmrate, |
uci1 | 10:3c93db1cfb12 | 90 | const float evtrate, |
uci1 | 8:95a325df1f6b | 91 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 92 | const uint32_t timeout_clock); |
uci1 | 1:e392595b4b76 | 93 | |
uci1 | 8:95a325df1f6b | 94 | ECommWinResult SendFilename(const char* fn, |
uci1 | 8:95a325df1f6b | 95 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 96 | const uint32_t timeout_clock); |
uci1 | 6:6f002d202f59 | 97 | |
uci1 | 8:95a325df1f6b | 98 | ECommWinResult SendData(FILE* inf, const char* infn, |
uci1 | 8:95a325df1f6b | 99 | const SnConfigFrame& curConf, |
uci1 | 8:95a325df1f6b | 100 | SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 101 | SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 102 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 103 | const uint32_t bsize, |
uci1 | 8:95a325df1f6b | 104 | const uint32_t nevts, |
uci1 | 8:95a325df1f6b | 105 | const uint32_t timeout_clock, |
uci1 | 12:d472f9811262 | 106 | const uint32_t handshakeTimeout); |
uci1 | 6:6f002d202f59 | 107 | |
uci1 | 8:95a325df1f6b | 108 | ECommWinResult SendData(SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 109 | SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 110 | SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 111 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 112 | const uint32_t bsize, |
uci1 | 12:d472f9811262 | 113 | const uint32_t timeout, |
uci1 | 12:d472f9811262 | 114 | const uint32_t handshakeTimeout); |
uci1 | 8:95a325df1f6b | 115 | |
uci1 | 1:e392595b4b76 | 116 | }; |
uci1 | 1:e392595b4b76 | 117 | |
uci1 | 1:e392595b4b76 | 118 | #endif // SN_SnCommWin |