Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnSDUtils.cpp
- Revision:
- 22:f957c4f840ad
- Parent:
- 21:ce51bb0ba4a5
- Child:
- 25:57b2627fe756
diff -r ce51bb0ba4a5 -r f957c4f840ad SnSDUtils.cpp --- a/SnSDUtils.cpp Wed Oct 10 05:54:12 2012 +0000 +++ b/SnSDUtils.cpp Tue Oct 16 04:47:44 2012 +0000 @@ -8,6 +8,7 @@ #include "SnConfigFrame.h" #include "SnEventFrame.h" +#include "SnHeartbeatFrame.h" //#define DEBUG @@ -152,12 +153,21 @@ // 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) // +#ifdef DEBUG + printf("getting seq num\r\n"); +#endif fgCurSeq = GetSeqNum(macadr, run); +#ifdef DEBUG + printf("getting output file name\r\n"); +#endif memset(fgCurFileName, 0, sizeof(char)*kFNBufSize); strncpy(fgCurFileName,GetOutFileName(macadr, run, fgCurSeq),kFNBufSize-1); //fprintf(stderr,"cur file = %s (%hu)\n\r",fgCurFileName,fgCurSeq); fgCurFile = 0; if (fgCurFileName!=NULL) { +#ifdef DEBUG + printf("opening SD file\r\n"); +#endif fgCurFile = OpenSDFile(fgCurFileName, "wb"); if (fgCurFile!=NULL && ferror(fgCurFile)==0) { #ifdef DEBUG @@ -186,11 +196,23 @@ closedir(d); } #ifdef DEBUG - printf("GetDirProps: %s :: nf=%u, tb=%u\r\n", + printf("GetDirProps: %s :: nf=%u, tb=%g\r\n", dirname, nfiles, totbytes); #endif } +bool SnSDUtils::WriteHeartbeatTo(FILE* file, + const uint32_t time, + const uint32_t num) { + const SnCommWin::ECommWinResult r1 = + SnHeaderFrame::WriteTo(file, SnHeaderFrame::kHeartbeatCode, + SnHeartbeatFrame::SizeOf(SnHeartbeatFrame::kIOVers)); + const SnCommWin::ECommWinResult r2 = + SnHeartbeatFrame::WriteTo(file, time, num); + return ((r1==SnCommWin::kOkMsgSent) + && (r2==SnCommWin::kOkMsgSent)); +} + bool SnSDUtils::WriteEventTo(FILE* efile, char* const evtBuf, const SnEventFrame& evt, const SnConfigFrame& conf) {