Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnSDUtils.cpp
- Revision:
- 8:95a325df1f6b
- Parent:
- 7:079617408fec
- Child:
- 10:3c93db1cfb12
--- a/SnSDUtils.cpp Sat Aug 04 01:48:55 2012 +0000 +++ b/SnSDUtils.cpp Wed Aug 08 23:27:37 2012 +0000 @@ -11,10 +11,10 @@ const char* const SnSDUtils::kSDsubDir = "/sd"; char SnSDUtils::fgCurFileName[kFNBufSize]={0}; FILE* SnSDUtils::fgCurFile = 0; -const uint8_t SnSDUtils::kIOvers = 2; +const uint8_t SnSDUtils::kIOvers = 3; const uint32_t SnSDUtils::kMaxSizeOfFileHdr = sizeof(uint8_t)+sizeof(uint64_t)+sizeof(uint32_t)+sizeof(uint16_t) - +SnPowerFrame::kMaxSizeOf; + +(sizeof(uint8_t)+(2u*sizeof(uint16_t))); // power frame v1 static const uint16_t __kMaxUShort = ~0; @@ -103,8 +103,7 @@ } FILE* SnSDUtils::OpenNewOutputFile(const uint64_t macadr, - const uint32_t run, - const uint16_t v1, const uint16_t v2) { + const uint32_t run) { // opens a new file in the specified directory and writes this // this mbed's mac address as the first sizeof(uint64_t) bytes (i.e. 4 bytes) // @@ -116,7 +115,7 @@ if (fgCurFileName!=NULL) { fgCurFile = OpenSDFile(fgCurFileName, "wb"); if (fgCurFile!=NULL && ferror(fgCurFile)==0) { - WriteFileHeader(fgCurFile, macadr, run, seq, v1, v2); + WriteFileHeader(fgCurFile, macadr, run, seq); } } return fgCurFile; @@ -130,6 +129,8 @@ uint8_t sLoseLSB=0, sLoseMSB=0; uint16_t sWvBase=0; conf.GetPackParsFor(SnConfigFrame::kSDcard, sLoseLSB, sLoseMSB, sWvBase); + SnHeaderFrame::WriteTo(efile, SnHeaderFrame::kEventCode, + evt.SizeOf(SnEventFrame::kIOVers, sLoseLSB, sLoseMSB)); const bool ret = evt.WriteTo(efile, evtBuf, sLoseLSB, sLoseMSB, sWvBase); fflush(efile); return ret; @@ -137,6 +138,8 @@ bool SnSDUtils::WriteConfig(FILE* efile, const SnConfigFrame& conf) { + SnHeaderFrame::WriteTo(efile, SnHeaderFrame::kConfigCode, + conf.SizeOf(SnConfigFrame::kIOVers)); conf.WriteTo(efile); return true; } @@ -153,7 +156,8 @@ char* const buf, const uint32_t bsize, const SnConfigFrame& curConf, - SnEventFrame& evt) { + SnEventFrame& evt, + SnPowerFrame& pow) { DIR* d; struct dirent* dent; @@ -173,7 +177,7 @@ f = OpenExistingFile(dent->d_name, false); } rs = comm->SendData(f, dent->d_name, - curConf, evt, buf, bsize, + curConf, evt, pow, buf, bsize, 0, timeout, 0); if (isCurFile) { // move (back) to the end of the file