Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Committer:
uci1
Date:
Wed Sep 12 04:47:22 2012 +0000
Revision:
16:744ce85aede2
Parent:
15:f2569d8e4176
Child:
18:55f1581f2ee4
SBD comm seems to be working. USB comm seems to be working (at 115200 baud). AFAR comm seems to be working. This version is set for USB communication and has zero text output.

Who changed what in which revision?

UserRevisionLine numberNew 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 int32_t ReceiveAll(char* const buf, const uint32_t mlen,
uci1 8:95a325df1f6b 48 const uint32_t timeout_clock)=0;
uci1 8:95a325df1f6b 49 virtual int32_t SendAll(char* const data, const uint32_t length,
uci1 8:95a325df1f6b 50 const uint32_t timeout_clock)=0;
uci1 12:d472f9811262 51
uci1 12:d472f9811262 52 bool IsTimedOut(const uint32_t timeout_clock) const;
uci1 8:95a325df1f6b 53
uci1 12:d472f9811262 54
uci1 1:e392595b4b76 55 public:
uci1 1:e392595b4b76 56 virtual ~SnCommWin() {}
uci1 1:e392595b4b76 57
uci1 16:744ce85aede2 58 virtual SnConfigFrame::EDatPackBit GetCommType() const=0;
uci1 16:744ce85aede2 59
uci1 16:744ce85aede2 60 virtual bool TrySetSysTimeUnix(const uint32_t timeout) { return 0; }
uci1 16:744ce85aede2 61
uci1 8:95a325df1f6b 62 virtual void Set(const SnConfigFrame& conf)=0;
uci1 8:95a325df1f6b 63
uci1 1:e392595b4b76 64 virtual ECommWinResult OpenWindow(const uint32_t timeout,
uci1 1:e392595b4b76 65 const bool sendStatus,
uci1 1:e392595b4b76 66 const SnConfigFrame& conf,
uci1 1:e392595b4b76 67 const SnEventFrame& evt,
uci1 8:95a325df1f6b 68 const SnPowerFrame& pow,
uci1 10:3c93db1cfb12 69 const uint16_t seq,
uci1 10:3c93db1cfb12 70 const float thmrate,
uci1 10:3c93db1cfb12 71 const float evtrate,
uci1 2:e67f7c158087 72 char* const genBuf)=0;
uci1 1:e392595b4b76 73
uci1 1:e392595b4b76 74 virtual bool Connect(const uint32_t timeout)=0;
uci1 15:f2569d8e4176 75 virtual bool CloseConn(const uint32_t timeout)=0;
uci1 16:744ce85aede2 76 virtual uint32_t GetConnectTimeout() const;
uci1 16:744ce85aede2 77 virtual uint32_t GetListenTimeout() const;
uci1 3:24c5f0f50bf1 78 virtual ECommWinResult WaitHandshake(const uint32_t timeout,
uci1 3:24c5f0f50bf1 79 char* const buf,
uci1 6:6f002d202f59 80 const uint32_t bsize,
uci1 8:95a325df1f6b 81 uint8_t& hndShkCode);
uci1 3:24c5f0f50bf1 82
uci1 8:95a325df1f6b 83 ECommWinResult GetConfig(SnConfigFrame& conf,
uci1 8:95a325df1f6b 84 const uint32_t timeOut,
uci1 8:95a325df1f6b 85 char* const confBuf,
uci1 8:95a325df1f6b 86 const uint32_t bsize);
uci1 1:e392595b4b76 87
uci1 8:95a325df1f6b 88 ECommWinResult SendStatus(const SnConfigFrame& conf,
uci1 8:95a325df1f6b 89 const SnEventFrame& evt,
uci1 8:95a325df1f6b 90 const SnPowerFrame& pow,
uci1 10:3c93db1cfb12 91 const uint16_t seq,
uci1 10:3c93db1cfb12 92 const float thmrate,
uci1 10:3c93db1cfb12 93 const float evtrate,
uci1 8:95a325df1f6b 94 char* const genBuf,
uci1 8:95a325df1f6b 95 const uint32_t timeout_clock);
uci1 1:e392595b4b76 96
uci1 8:95a325df1f6b 97 ECommWinResult SendFilename(const char* fn,
uci1 8:95a325df1f6b 98 char* const genBuf,
uci1 8:95a325df1f6b 99 const uint32_t timeout_clock);
uci1 6:6f002d202f59 100
uci1 8:95a325df1f6b 101 ECommWinResult SendData(FILE* inf, const char* infn,
uci1 8:95a325df1f6b 102 const SnConfigFrame& curConf,
uci1 8:95a325df1f6b 103 SnEventFrame& evt,
uci1 8:95a325df1f6b 104 SnPowerFrame& pow,
uci1 8:95a325df1f6b 105 char* const genBuf,
uci1 8:95a325df1f6b 106 const uint32_t bsize,
uci1 8:95a325df1f6b 107 const uint32_t nevts,
uci1 8:95a325df1f6b 108 const uint32_t timeout_clock,
uci1 12:d472f9811262 109 const uint32_t handshakeTimeout);
uci1 6:6f002d202f59 110
uci1 8:95a325df1f6b 111 ECommWinResult SendData(SnConfigFrame& conf,
uci1 8:95a325df1f6b 112 SnEventFrame& evt,
uci1 8:95a325df1f6b 113 SnPowerFrame& pow,
uci1 8:95a325df1f6b 114 char* const genBuf,
uci1 8:95a325df1f6b 115 const uint32_t bsize,
uci1 12:d472f9811262 116 const uint32_t timeout,
uci1 12:d472f9811262 117 const uint32_t handshakeTimeout);
uci1 8:95a325df1f6b 118
uci1 1:e392595b4b76 119 };
uci1 1:e392595b4b76 120
uci1 1:e392595b4b76 121 #endif // SN_SnCommWin