Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Committer:
uci1
Date:
Tue Jul 31 04:59:16 2012 +0000
Revision:
3:24c5f0f50bf1
Child:
4:a91682e19d6b
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?

UserRevisionLine numberNew contents of line
uci1 3:24c5f0f50bf1 1 /*
uci1 3:24c5f0f50bf1 2 #include "SnCommAfarTCP.h"
uci1 3:24c5f0f50bf1 3
uci1 3:24c5f0f50bf1 4 SnCommAfarTCP::SnCommAfarTCP(char* const b64buf, const uint32_t bblen) :
uci1 3:24c5f0f50bf1 5 fB64buf(b64buf), fbblen(bblen), fRmtServ(remote),
uci1 3:24c5f0f50bf1 6 fEth(new EthernetInterface), fSock(new TCPSocketConnection) {
uci1 3:24c5f0f50bf1 7
uci1 3:24c5f0f50bf1 8 fEth->init("128.195.204.148", // my IP
uci1 3:24c5f0f50bf1 9 "255.255.255.0", // mask
uci1 3:24c5f0f50bf1 10 "128.195.204.1"); // gateway
uci1 3:24c5f0f50bf1 11
uci1 3:24c5f0f50bf1 12 fRserv = "128.195.204.151";
uci1 3:24c5f0f50bf1 13 fRport = 6655;
uci1 3:24c5f0f50bf1 14
uci1 3:24c5f0f50bf1 15 }
uci1 3:24c5f0f50bf1 16
uci1 3:24c5f0f50bf1 17 SnCommAfarTCP::~SnCommAfarTCP() {
uci1 3:24c5f0f50bf1 18 delete fEth;
uci1 3:24c5f0f50bf1 19 delete fSock;
uci1 3:24c5f0f50bf1 20 }
uci1 3:24c5f0f50bf1 21
uci1 3:24c5f0f50bf1 22 int SnCommAfarTCP::SendAll(const char* const data, const uint32_t length,
uci1 3:24c5f0f50bf1 23 const uint32_t timeout_clock) {
uci1 3:24c5f0f50bf1 24 const char* dd = data;
uci1 3:24c5f0f50bf1 25 int res=0;
uci1 3:24c5f0f50bf1 26 uint32_t b=0;
uci1 3:24c5f0f50bf1 27 while ( (length>b) && (time(0)<timeout_clock) ) {
uci1 3:24c5f0f50bf1 28 res = fSock->
uci1 3:24c5f0f50bf1 29 }
uci1 3:24c5f0f50bf1 30 }
uci1 3:24c5f0f50bf1 31
uci1 3:24c5f0f50bf1 32
uci1 3:24c5f0f50bf1 33 bool SnCommAfarTCP::Connect(const uint32_t timeout) {
uci1 3:24c5f0f50bf1 34 bool isConn = false;
uci1 3:24c5f0f50bf1 35
uci1 3:24c5f0f50bf1 36 while ( (isConn==false) && ( time(0) < timeout) ) {
uci1 3:24c5f0f50bf1 37 wait_ms(250);
uci1 3:24c5f0f50bf1 38 isConn = (fEth->connect()==0);
uci1 3:24c5f0f50bf1 39 }
uci1 3:24c5f0f50bf1 40
uci1 3:24c5f0f50bf1 41 while ( (isConn==false) && ( time(0) < timeout) ) {
uci1 3:24c5f0f50bf1 42 wait_ms(250);
uci1 3:24c5f0f50bf1 43 isConn = (fSock->connect(fRserv.c_str(), fRport)==0);s
uci1 3:24c5f0f50bf1 44 }
uci1 3:24c5f0f50bf1 45
uci1 3:24c5f0f50bf1 46 return isConn;
uci1 3:24c5f0f50bf1 47 }
uci1 3:24c5f0f50bf1 48
uci1 3:24c5f0f50bf1 49 SnCommWin::ECommWinResult SnCommAfarTCP::OpenWindow(const uint32_t timeout,
uci1 3:24c5f0f50bf1 50 const bool sendStatus,
uci1 3:24c5f0f50bf1 51 const SnConfigFrame& conf,
uci1 3:24c5f0f50bf1 52 const SnEventFrame& evt,
uci1 3:24c5f0f50bf1 53 char* const genBuf) {
uci1 3:24c5f0f50bf1 54 const bool canCon = Connect(timeout);
uci1 3:24c5f0f50bf1 55
uci1 3:24c5f0f50bf1 56 SnCommWin::ECommWinResult ret = canCon ? SnCommWin::kConnected
uci1 3:24c5f0f50bf1 57 : SnCommWin::kCanNotConnect;
uci1 3:24c5f0f50bf1 58
uci1 3:24c5f0f50bf1 59 if (canCon && sendStatus) {
uci1 3:24c5f0f50bf1 60 ret = SendStatus(conf, evt, genBuf);
uci1 3:24c5f0f50bf1 61 }
uci1 3:24c5f0f50bf1 62
uci1 3:24c5f0f50bf1 63 return ret;
uci1 3:24c5f0f50bf1 64 }
uci1 3:24c5f0f50bf1 65 */