Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnCommWin.h@3:24c5f0f50bf1, 2012-07-31 (annotated)
- Committer:
- uci1
- Date:
- Tue Jul 31 04:59:16 2012 +0000
- Revision:
- 3:24c5f0f50bf1
- Parent:
- 2:e67f7c158087
- Child:
- 6:6f002d202f59
Test bench version. Communications not completed. Debugging output present. But will read the local config file and save events that can be used for testing.
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 | 1:e392595b4b76 | 7 | class SnConfigFrame; |
uci1 | 1:e392595b4b76 | 8 | class SnEventFrame; |
uci1 | 1:e392595b4b76 | 9 | |
uci1 | 1:e392595b4b76 | 10 | // ABC for communication types |
uci1 | 1:e392595b4b76 | 11 | |
uci1 | 1:e392595b4b76 | 12 | class SnCommWin { |
uci1 | 1:e392595b4b76 | 13 | public: |
uci1 | 1:e392595b4b76 | 14 | enum ECommWinResult { |
uci1 | 1:e392595b4b76 | 15 | kUndefFail, // undefined fail type |
uci1 | 1:e392595b4b76 | 16 | kCanNotConnect, // unable to connect to port |
uci1 | 1:e392595b4b76 | 17 | kFailTimeout, // timed out but message required |
uci1 | 2:e67f7c158087 | 18 | kFailNoneSent, // none of the message sent |
uci1 | 1:e392595b4b76 | 19 | kFailPartSent, // only part of the message sent |
uci1 | 3:24c5f0f50bf1 | 20 | kUnexpectedRec, // unexpected / unhandled message received |
uci1 | 1:e392595b4b76 | 21 | kAllFails, // to be used for "if (ret > kAllFails) ==> success" |
uci1 | 1:e392595b4b76 | 22 | // only successes should go below |
uci1 | 1:e392595b4b76 | 23 | kConnected, // connection established, no messaging attempted |
uci1 | 1:e392595b4b76 | 24 | kOkMsgSent, // message sent without waiting for "received" handshake |
uci1 | 1:e392595b4b76 | 25 | kOkNoMsg, // timed out with no message, but that is ok |
uci1 | 1:e392595b4b76 | 26 | kOkWithMsg // successfully received message |
uci1 | 1:e392595b4b76 | 27 | }; |
uci1 | 2:e67f7c158087 | 28 | |
uci1 | 1:e392595b4b76 | 29 | private: |
uci1 | 1:e392595b4b76 | 30 | //bool fWinOpen; // whether this comm should listen |
uci1 | 1:e392595b4b76 | 31 | |
uci1 | 1:e392595b4b76 | 32 | ECommWinResult SendData(FILE* inf, const char* infn, |
uci1 | 1:e392595b4b76 | 33 | const SnConfigFrame& curConf, |
uci1 | 1:e392595b4b76 | 34 | SnEventFrame& evt, |
uci1 | 2:e67f7c158087 | 35 | char* const genBuf, |
uci1 | 1:e392595b4b76 | 36 | const uint32_t nevts, |
uci1 | 1:e392595b4b76 | 37 | const uint32_t firstEvt=0); |
uci1 | 3:24c5f0f50bf1 | 38 | /* |
uci1 | 1:e392595b4b76 | 39 | ECommWinResult SendData(const char* infn, |
uci1 | 1:e392595b4b76 | 40 | const SnConfigFrame& curConf, |
uci1 | 1:e392595b4b76 | 41 | SnEventFrame& evt, |
uci1 | 2:e67f7c158087 | 42 | char* const genBuf, |
uci1 | 1:e392595b4b76 | 43 | const uint32_t nevts, |
uci1 | 1:e392595b4b76 | 44 | const uint32_t firstEvt=0); |
uci1 | 3:24c5f0f50bf1 | 45 | */ |
uci1 | 1:e392595b4b76 | 46 | |
uci1 | 3:24c5f0f50bf1 | 47 | protected: |
uci1 | 1:e392595b4b76 | 48 | virtual ECommWinResult SendConfAndEvents(FILE* inf, |
uci1 | 1:e392595b4b76 | 49 | const SnConfigFrame& curConf, |
uci1 | 1:e392595b4b76 | 50 | SnEventFrame& evt, |
uci1 | 2:e67f7c158087 | 51 | char* const genBuf, |
uci1 | 1:e392595b4b76 | 52 | const uint32_t nevts, |
uci1 | 1:e392595b4b76 | 53 | const uint32_t firstEvt=0)=0; |
uci1 | 1:e392595b4b76 | 54 | public: |
uci1 | 1:e392595b4b76 | 55 | virtual ~SnCommWin() {} |
uci1 | 1:e392595b4b76 | 56 | |
uci1 | 1:e392595b4b76 | 57 | virtual ECommWinResult OpenWindow(const uint32_t timeout, |
uci1 | 1:e392595b4b76 | 58 | const bool sendStatus, |
uci1 | 1:e392595b4b76 | 59 | const SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 60 | const SnEventFrame& evt, |
uci1 | 2:e67f7c158087 | 61 | char* const genBuf)=0; |
uci1 | 1:e392595b4b76 | 62 | |
uci1 | 1:e392595b4b76 | 63 | virtual bool Connect(const uint32_t timeout)=0; |
uci1 | 1:e392595b4b76 | 64 | |
uci1 | 3:24c5f0f50bf1 | 65 | virtual ECommWinResult WaitHandshake(const uint32_t timeout, |
uci1 | 3:24c5f0f50bf1 | 66 | char* const buf, |
uci1 | 3:24c5f0f50bf1 | 67 | const uint32_t bsize)=0; |
uci1 | 3:24c5f0f50bf1 | 68 | |
uci1 | 1:e392595b4b76 | 69 | virtual ECommWinResult GetConfig(SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 70 | const uint32_t timeOut, |
uci1 | 3:24c5f0f50bf1 | 71 | char* const confBuf, |
uci1 | 3:24c5f0f50bf1 | 72 | const uint32_t bsize)=0; |
uci1 | 1:e392595b4b76 | 73 | |
uci1 | 3:24c5f0f50bf1 | 74 | virtual ECommWinResult SendFilename(const char* fn, char* const genBuf)=0; |
uci1 | 3:24c5f0f50bf1 | 75 | |
uci1 | 1:e392595b4b76 | 76 | virtual ECommWinResult SendStatus(const SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 77 | const SnEventFrame& evt, |
uci1 | 2:e67f7c158087 | 78 | char* const genBuf)=0; |
uci1 | 1:e392595b4b76 | 79 | |
uci1 | 1:e392595b4b76 | 80 | ECommWinResult SendData(SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 81 | SnEventFrame& evt, |
uci1 | 2:e67f7c158087 | 82 | char* const genBuf, |
uci1 | 3:24c5f0f50bf1 | 83 | const uint32_t bsize, |
uci1 | 1:e392595b4b76 | 84 | const uint32_t timeout); |
uci1 | 1:e392595b4b76 | 85 | |
uci1 | 1:e392595b4b76 | 86 | virtual ECommWinResult SendData(FILE* inf)=0; |
uci1 | 1:e392595b4b76 | 87 | |
uci1 | 1:e392595b4b76 | 88 | }; |
uci1 | 1:e392595b4b76 | 89 | |
uci1 | 1:e392595b4b76 | 90 | #endif // SN_SnCommWin |