Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnCommWin.h@8:95a325df1f6b, 2012-08-08 (annotated)
- Committer:
- uci1
- Date:
- Wed Aug 08 23:27:37 2012 +0000
- Revision:
- 8:95a325df1f6b
- Parent:
- 6:6f002d202f59
- Child:
- 10:3c93db1cfb12
Check power for low pow running. Average power over 500 readings. Use RTOS timers instead of tickers. Allow data taking of events, power readings or both, even if cards are off. Bug in EthernetInterface prevents IPs being reset. Lots of debug output.
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 | 1:e392595b4b76 | 27 | kOkWithMsg // successfully received message |
uci1 | 1:e392595b4b76 | 28 | }; |
uci1 | 2:e67f7c158087 | 29 | |
uci1 | 1:e392595b4b76 | 30 | |
uci1 | 3:24c5f0f50bf1 | 31 | protected: |
uci1 | 8:95a325df1f6b | 32 | virtual ECommWinResult SendFileContents(FILE* inf, |
uci1 | 8:95a325df1f6b | 33 | const SnConfigFrame& curConf, |
uci1 | 8:95a325df1f6b | 34 | SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 35 | SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 36 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 37 | uint32_t nevts, |
uci1 | 8:95a325df1f6b | 38 | const uint32_t timeout_clock, |
uci1 | 8:95a325df1f6b | 39 | const uint32_t firstEvt=0); |
uci1 | 8:95a325df1f6b | 40 | |
uci1 | 8:95a325df1f6b | 41 | virtual SnConfigFrame::EDatPackBit GetCommType() const=0; |
uci1 | 8:95a325df1f6b | 42 | |
uci1 | 8:95a325df1f6b | 43 | virtual int32_t ReceiveAll(char* const buf, const uint32_t mlen, |
uci1 | 8:95a325df1f6b | 44 | const uint32_t timeout_clock)=0; |
uci1 | 8:95a325df1f6b | 45 | virtual int32_t SendAll(char* const data, const uint32_t length, |
uci1 | 8:95a325df1f6b | 46 | const uint32_t timeout_clock)=0; |
uci1 | 8:95a325df1f6b | 47 | |
uci1 | 1:e392595b4b76 | 48 | public: |
uci1 | 1:e392595b4b76 | 49 | virtual ~SnCommWin() {} |
uci1 | 1:e392595b4b76 | 50 | |
uci1 | 8:95a325df1f6b | 51 | virtual void Set(const SnConfigFrame& conf)=0; |
uci1 | 8:95a325df1f6b | 52 | |
uci1 | 1:e392595b4b76 | 53 | virtual ECommWinResult OpenWindow(const uint32_t timeout, |
uci1 | 1:e392595b4b76 | 54 | const bool sendStatus, |
uci1 | 1:e392595b4b76 | 55 | const SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 56 | const SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 57 | const SnPowerFrame& pow, |
uci1 | 2:e67f7c158087 | 58 | char* const genBuf)=0; |
uci1 | 1:e392595b4b76 | 59 | |
uci1 | 1:e392595b4b76 | 60 | virtual bool Connect(const uint32_t timeout)=0; |
uci1 | 1:e392595b4b76 | 61 | |
uci1 | 3:24c5f0f50bf1 | 62 | virtual ECommWinResult WaitHandshake(const uint32_t timeout, |
uci1 | 3:24c5f0f50bf1 | 63 | char* const buf, |
uci1 | 6:6f002d202f59 | 64 | const uint32_t bsize, |
uci1 | 8:95a325df1f6b | 65 | uint8_t& hndShkCode); |
uci1 | 3:24c5f0f50bf1 | 66 | |
uci1 | 8:95a325df1f6b | 67 | ECommWinResult GetConfig(SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 68 | const uint32_t timeOut, |
uci1 | 8:95a325df1f6b | 69 | char* const confBuf, |
uci1 | 8:95a325df1f6b | 70 | const uint32_t bsize); |
uci1 | 1:e392595b4b76 | 71 | |
uci1 | 8:95a325df1f6b | 72 | ECommWinResult SendStatus(const SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 73 | const SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 74 | const SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 75 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 76 | const uint32_t timeout_clock); |
uci1 | 1:e392595b4b76 | 77 | |
uci1 | 8:95a325df1f6b | 78 | ECommWinResult SendFilename(const char* fn, |
uci1 | 8:95a325df1f6b | 79 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 80 | const uint32_t timeout_clock); |
uci1 | 6:6f002d202f59 | 81 | |
uci1 | 8:95a325df1f6b | 82 | ECommWinResult SendData(FILE* inf, const char* infn, |
uci1 | 8:95a325df1f6b | 83 | const SnConfigFrame& curConf, |
uci1 | 8:95a325df1f6b | 84 | SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 85 | SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 86 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 87 | const uint32_t bsize, |
uci1 | 8:95a325df1f6b | 88 | const uint32_t nevts, |
uci1 | 8:95a325df1f6b | 89 | const uint32_t timeout_clock, |
uci1 | 8:95a325df1f6b | 90 | const uint32_t firstEvt=0); |
uci1 | 6:6f002d202f59 | 91 | |
uci1 | 8:95a325df1f6b | 92 | ECommWinResult SendData(SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 93 | SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 94 | SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 95 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 96 | const uint32_t bsize, |
uci1 | 8:95a325df1f6b | 97 | const uint32_t timeout); |
uci1 | 8:95a325df1f6b | 98 | |
uci1 | 1:e392595b4b76 | 99 | }; |
uci1 | 1:e392595b4b76 | 100 | |
uci1 | 1:e392595b4b76 | 101 | #endif // SN_SnCommWin |