Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnCommWin.h@10:3c93db1cfb12, 2012-08-10 (annotated)
- Committer:
- uci1
- Date:
- Fri Aug 10 18:35:43 2012 +0000
- Revision:
- 10:3c93db1cfb12
- Parent:
- 8:95a325df1f6b
- Child:
- 12:d472f9811262
Ensure that lockRegisters (p20) is 0 before accessing the SD card, for example when closing the file. This fixes an issue seen when running in power count mode. Communications still under dev. Many debug outputs.
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 | 10:3c93db1cfb12 | 58 | const uint16_t seq, |
uci1 | 10:3c93db1cfb12 | 59 | const float thmrate, |
uci1 | 10:3c93db1cfb12 | 60 | const float evtrate, |
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 | 6:6f002d202f59 | 67 | const uint32_t bsize, |
uci1 | 8:95a325df1f6b | 68 | uint8_t& hndShkCode); |
uci1 | 3:24c5f0f50bf1 | 69 | |
uci1 | 8:95a325df1f6b | 70 | ECommWinResult GetConfig(SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 71 | const uint32_t timeOut, |
uci1 | 8:95a325df1f6b | 72 | char* const confBuf, |
uci1 | 8:95a325df1f6b | 73 | const uint32_t bsize); |
uci1 | 1:e392595b4b76 | 74 | |
uci1 | 8:95a325df1f6b | 75 | ECommWinResult SendStatus(const SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 76 | const SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 77 | const SnPowerFrame& pow, |
uci1 | 10:3c93db1cfb12 | 78 | const uint16_t seq, |
uci1 | 10:3c93db1cfb12 | 79 | const float thmrate, |
uci1 | 10:3c93db1cfb12 | 80 | const float evtrate, |
uci1 | 8:95a325df1f6b | 81 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 82 | const uint32_t timeout_clock); |
uci1 | 1:e392595b4b76 | 83 | |
uci1 | 8:95a325df1f6b | 84 | ECommWinResult SendFilename(const char* fn, |
uci1 | 8:95a325df1f6b | 85 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 86 | const uint32_t timeout_clock); |
uci1 | 6:6f002d202f59 | 87 | |
uci1 | 8:95a325df1f6b | 88 | ECommWinResult SendData(FILE* inf, const char* infn, |
uci1 | 8:95a325df1f6b | 89 | const SnConfigFrame& curConf, |
uci1 | 8:95a325df1f6b | 90 | SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 91 | SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 92 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 93 | const uint32_t bsize, |
uci1 | 8:95a325df1f6b | 94 | const uint32_t nevts, |
uci1 | 8:95a325df1f6b | 95 | const uint32_t timeout_clock, |
uci1 | 8:95a325df1f6b | 96 | const uint32_t firstEvt=0); |
uci1 | 6:6f002d202f59 | 97 | |
uci1 | 8:95a325df1f6b | 98 | ECommWinResult SendData(SnConfigFrame& conf, |
uci1 | 8:95a325df1f6b | 99 | SnEventFrame& evt, |
uci1 | 8:95a325df1f6b | 100 | SnPowerFrame& pow, |
uci1 | 8:95a325df1f6b | 101 | char* const genBuf, |
uci1 | 8:95a325df1f6b | 102 | const uint32_t bsize, |
uci1 | 8:95a325df1f6b | 103 | const uint32_t timeout); |
uci1 | 8:95a325df1f6b | 104 | |
uci1 | 1:e392595b4b76 | 105 | }; |
uci1 | 1:e392595b4b76 | 106 | |
uci1 | 1:e392595b4b76 | 107 | #endif // SN_SnCommWin |