Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Committer:
uci1
Date:
Fri Aug 03 23:50:57 2012 +0000
Revision:
6:6f002d202f59
Parent:
3:24c5f0f50bf1
Child:
8:95a325df1f6b
Remove line that powered amps outside of SetPower. Still lots of debugging output. Communication systems totally unimplemented.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uci1 2:e67f7c158087 1 #include "SnCommWin.h"
uci1 2:e67f7c158087 2
uci1 6:6f002d202f59 3 #include "SnHeaderFrame.h"
uci1 2:e67f7c158087 4 #include "SnConfigFrame.h"
uci1 2:e67f7c158087 5 #include "SnSDUtils.h"
uci1 2:e67f7c158087 6
uci1 2:e67f7c158087 7 SnCommWin::ECommWinResult SnCommWin::SendData(SnConfigFrame& conf,
uci1 2:e67f7c158087 8 SnEventFrame& evt,
uci1 2:e67f7c158087 9 char* const genBuf,
uci1 3:24c5f0f50bf1 10 const uint32_t bsize,
uci1 2:e67f7c158087 11 const uint32_t timeout) {
uci1 3:24c5f0f50bf1 12 printf("SnCommWin::SendData\r\n");
uci1 2:e67f7c158087 13 ECommWinResult res = kUndefFail;
uci1 6:6f002d202f59 14 const uint32_t to = (conf.IsObeyingTimeout()) ? timeout : kSecsPerYear;
uci1 2:e67f7c158087 15 if (conf.IsSendingAllFiles()) {
uci1 3:24c5f0f50bf1 16 printf("sending all files\r\n");
uci1 6:6f002d202f59 17 res = SnSDUtils::SendAllFiles(this, conf.IsDeletingFiles(), to,
uci1 6:6f002d202f59 18 genBuf, bsize, conf, evt);
uci1 2:e67f7c158087 19 } else {
uci1 2:e67f7c158087 20 if (conf.GetCommSendData()==0) {
uci1 3:24c5f0f50bf1 21 printf("no data to send\r\n");
uci1 2:e67f7c158087 22 res = kOkNoMsg;
uci1 2:e67f7c158087 23 } else {
uci1 2:e67f7c158087 24 const uint32_t nev = (conf.GetCommSendData()>0) ?
uci1 3:24c5f0f50bf1 25 conf.GetCommSendData() // send N events
uci1 3:24c5f0f50bf1 26 : 0u; // send all events in last file
uci1 2:e67f7c158087 27 res = SendData(SnSDUtils::GetCurFile(), SnSDUtils::GetCurFileName(),
uci1 6:6f002d202f59 28 conf, evt, genBuf, bsize, nev, to);
uci1 3:24c5f0f50bf1 29 printf("after send data cur file, res=%d\r\n",(int)res);
uci1 2:e67f7c158087 30 }
uci1 2:e67f7c158087 31 }
uci1 2:e67f7c158087 32 return res;
uci1 2:e67f7c158087 33 }
uci1 2:e67f7c158087 34
uci1 2:e67f7c158087 35 SnCommWin::ECommWinResult SnCommWin::SendData(FILE* inf, const char* infn,
uci1 2:e67f7c158087 36 const SnConfigFrame& curConf,
uci1 2:e67f7c158087 37 SnEventFrame& evt,
uci1 2:e67f7c158087 38 char* const genBuf,
uci1 6:6f002d202f59 39 const uint32_t bsize,
uci1 2:e67f7c158087 40 const uint32_t nevts,
uci1 6:6f002d202f59 41 const uint32_t timeout_clock,
uci1 2:e67f7c158087 42 const uint32_t firstEvt) {
uci1 2:e67f7c158087 43 // nevts==0 ==> send all events
uci1 2:e67f7c158087 44
uci1 3:24c5f0f50bf1 45 printf("SnCommWin::SendData cur file\r\n");
uci1 2:e67f7c158087 46 ECommWinResult res = kUndefFail;
uci1 2:e67f7c158087 47 if (inf!=0) {
uci1 6:6f002d202f59 48 // send the file name
uci1 6:6f002d202f59 49 res = SendFilename(infn, genBuf, timeout_clock);
uci1 3:24c5f0f50bf1 50 if (res>kAllFails) {
uci1 6:6f002d202f59 51 if (genBuf!=0) {
uci1 6:6f002d202f59 52 // send the contents
uci1 6:6f002d202f59 53 res = SendFileContents(inf, curConf, evt, genBuf,
uci1 6:6f002d202f59 54 nevts, timeout_clock, firstEvt);
uci1 6:6f002d202f59 55 if (res>SnCommWin::kAllFails) {
uci1 6:6f002d202f59 56 // wait for handshake
uci1 6:6f002d202f59 57 uint8_t hndshk=0;
uci1 6:6f002d202f59 58 res = WaitHandshake(timeout_clock, genBuf, bsize, hndshk);
uci1 6:6f002d202f59 59 if ( (res==SnCommWin::kOkWithMsg) // got handshake
uci1 6:6f002d202f59 60 && (nevts==0) // sent whole file
uci1 6:6f002d202f59 61 && curConf.IsDeletingFiles() // want to delete
uci1 6:6f002d202f59 62 //&& (strcmp(infn, SnSDUtils::GetCurFileName()!=0) // not current file (TODO?)
uci1 6:6f002d202f59 63 && (hndshk==SnHeaderFrame::kHnShOkComplCode)) { // whole file received
uci1 6:6f002d202f59 64 // delete it
uci1 6:6f002d202f59 65 SnSDUtilsWhisperer::DeleteFile(inf, infn);
uci1 6:6f002d202f59 66 }
uci1 3:24c5f0f50bf1 67 }
uci1 2:e67f7c158087 68 }
uci1 2:e67f7c158087 69 }
uci1 2:e67f7c158087 70 }
uci1 2:e67f7c158087 71 return res;
uci1 2:e67f7c158087 72 }