Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnCommAfarTCP.cpp
- Revision:
- 18:55f1581f2ee4
- Parent:
- 16:744ce85aede2
--- a/SnCommAfarTCP.cpp Wed Sep 12 22:50:25 2012 +0000 +++ b/SnCommAfarTCP.cpp Sat Sep 29 04:54:15 2012 +0000 @@ -1,3 +1,4 @@ +#if 0 #include "SnCommAfarTCP.h" @@ -65,24 +66,39 @@ const uint32_t timeout_clock, TCPSendRecv fcn) { // TODO: if B64, must return number of bytes of raw (non encoded) message +#ifdef DEBUG + printf("SnCommAfarTCP::DoIO data:\r\n"); + dispStrBytes(data, length); + printf("\r\n"); +#endif int res=0; uint32_t b=0; while ( (length>b) ) { if (IsTimedOut(timeout_clock)) { +#ifdef DEBUG + printf("SnCommAfarTCP::DoIO timing out\r\n"); +#endif break; } res = CALL_MEMBER_FN(*fSock, fcn)(data+b, length-b); + /* switch (res) { case -1: // TODO: how to check the error? continue; case 0: - return res; + return b; default: b += res; }; - Watchdog::kick(); // don't reset; wait until timeout + */ + if (res>0) { + b += res; + } + //wait_ms(100); + //Watchdog::kick(); // don't reset; wait until timeout } + printf("return b=%d\r\n",b); return b; // timeout } @@ -98,7 +114,7 @@ const uint32_t timeout_clock) { // TODO: if B64, must return number of bytes of raw (non encoded) message //return DoIO(data, length, timeout_clock, &TCPSocketConnection::send_all); - // use regular sell; DoIO will do a send_all but use our timeout + // use regular send; DoIO will do a send_all but use our timeout return DoIO(data, length, timeout_clock, &TCPSocketConnection::send); } @@ -109,7 +125,7 @@ #endif bool isConn = false; - while ( (isConn==false) && ( time(0) < timeout) ) { + while ( (isConn==false) && (IsTimedOut(timeout)==false) ) { wait_ms(250); isConn = (fEth->connect()==0); } @@ -118,7 +134,7 @@ #endif isConn=false; - while ( (isConn==false) && ( time(0) < timeout) ) { + while ( (isConn==false) && (IsTimedOut(timeout)==false) ) { wait_ms(250); isConn = (fSock->connect(fRserv.c_str(), fRport)==0); } @@ -146,6 +162,9 @@ : SnCommWin::kCanNotConnect; if (canCon && sendStatus) { +#ifdef DEBUG + printf("calling SendStatus\r\n"); +#endif ret = SendStatus(conf, evt, pow, seq, thmrate, evtrate, genBuf, timeout); } @@ -155,3 +174,5 @@ bool SnCommAfarTCP::CloseConn(const uint32_t) { return (fSock->close())==0; } + +#endif