Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnCommWin.cpp@0:664899e0b988, 2012-06-30 (annotated)
- Committer:
- uci1
- Date:
- Sat Jun 30 02:03:51 2012 +0000
- Revision:
- 0:664899e0b988
- Child:
- 1:e392595b4b76
first version. SD card writing and data readout works. communications not tested.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 0:664899e0b988 | 1 | #include "SnCommWin.h" |
uci1 | 0:664899e0b988 | 2 | |
uci1 | 0:664899e0b988 | 3 | #include "SnConfigFrame.h" |
uci1 | 0:664899e0b988 | 4 | #include "SnSDUtils.h" |
uci1 | 0:664899e0b988 | 5 | |
uci1 | 0:664899e0b988 | 6 | /* |
uci1 | 0:664899e0b988 | 7 | bool SnCommWin::fgCommEst = false; |
uci1 | 0:664899e0b988 | 8 | bool SnCommWin::fgWinOpen = false; |
uci1 | 0:664899e0b988 | 9 | */ |
uci1 | 0:664899e0b988 | 10 | |
uci1 | 0:664899e0b988 | 11 | SnCommWin::ECommWinResult SnCommWin::SendData(SnConfigFrame& conf, |
uci1 | 0:664899e0b988 | 12 | SnEventFrame& evt, |
uci1 | 0:664899e0b988 | 13 | char* const evtBuf, |
uci1 | 0:664899e0b988 | 14 | char* const confBuf) { |
uci1 | 0:664899e0b988 | 15 | ECommWinResult res = kUndefFail; |
uci1 | 0:664899e0b988 | 16 | if (conf.IsSendingAllFiles()) { |
uci1 | 0:664899e0b988 | 17 | res = SnSDUtils::SendAllFiles(this, conf.IsDeletingFiles()); |
uci1 | 0:664899e0b988 | 18 | } else { |
uci1 | 0:664899e0b988 | 19 | if (conf.GetCommSendData()==0) { |
uci1 | 0:664899e0b988 | 20 | res = kOkNoMsg; |
uci1 | 0:664899e0b988 | 21 | } else { |
uci1 | 0:664899e0b988 | 22 | res = SendData(SnSDUtils::GetCurFileName(), conf, evt, |
uci1 | 0:664899e0b988 | 23 | evtBuf, confBuf, conf.GetCommSendData()); |
uci1 | 0:664899e0b988 | 24 | } |
uci1 | 0:664899e0b988 | 25 | } |
uci1 | 0:664899e0b988 | 26 | return res; |
uci1 | 0:664899e0b988 | 27 | } |
uci1 | 0:664899e0b988 | 28 | |
uci1 | 0:664899e0b988 | 29 | SnCommWin::ECommWinResult SnCommWin::SendData(const char* infn, |
uci1 | 0:664899e0b988 | 30 | const SnConfigFrame& curConf, |
uci1 | 0:664899e0b988 | 31 | SnEventFrame& evt, |
uci1 | 0:664899e0b988 | 32 | char* const evtBuf, |
uci1 | 0:664899e0b988 | 33 | char* const confBuf, |
uci1 | 0:664899e0b988 | 34 | const uint32_t nevts, |
uci1 | 0:664899e0b988 | 35 | const uint32_t firstEvt) { |
uci1 | 0:664899e0b988 | 36 | // nevts==0 ==> send all events |
uci1 | 0:664899e0b988 | 37 | // evtBuf should be 0 only if nevts==0 |
uci1 | 0:664899e0b988 | 38 | |
uci1 | 0:664899e0b988 | 39 | ECommWinResult res = kUndefFail; |
uci1 | 0:664899e0b988 | 40 | FILE* inf = fopen(infn, "rb"); |
uci1 | 0:664899e0b988 | 41 | if (inf!=0) { |
uci1 | 0:664899e0b988 | 42 | if (nevts==0) { |
uci1 | 0:664899e0b988 | 43 | res = SendData(inf); |
uci1 | 0:664899e0b988 | 44 | if (curConf.IsDeletingFiles() && res>=kOkMsgSent) { |
uci1 | 0:664899e0b988 | 45 | SnSDUtilsWhisperer::DeleteFile(inf, infn); |
uci1 | 0:664899e0b988 | 46 | } |
uci1 | 0:664899e0b988 | 47 | } else { |
uci1 | 0:664899e0b988 | 48 | if (evtBuf!=0) { |
uci1 | 0:664899e0b988 | 49 | res = SendConfAndEvents(inf, curConf, evt, evtBuf, confBuf, nevts, firstEvt); |
uci1 | 0:664899e0b988 | 50 | } |
uci1 | 0:664899e0b988 | 51 | } |
uci1 | 0:664899e0b988 | 52 | if (inf!=0) { |
uci1 | 0:664899e0b988 | 53 | fclose(inf); |
uci1 | 0:664899e0b988 | 54 | } |
uci1 | 0:664899e0b988 | 55 | } |
uci1 | 0:664899e0b988 | 56 | return res; |
uci1 | 0:664899e0b988 | 57 | } |