Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnHeartbeatFrame.h
- Revision:
- 40:1324da35afd4
- Parent:
- 22:f957c4f840ad
- Child:
- 84:80b15993944e
--- a/SnHeartbeatFrame.h Tue Jul 30 02:03:21 2013 +0000 +++ b/SnHeartbeatFrame.h Sat Oct 05 04:45:22 2013 +0000 @@ -8,14 +8,20 @@ public: // i/o version static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes - static const uint32_t kMaxSizeOf = 2u*sizeof(uint32_t); + static const uint32_t kMaxSizeOf = 2u*sizeof(uint32_t) + sizeof(uint8_t); public: SnHeartbeatFrame() {} virtual ~SnHeartbeatFrame() {} static - uint32_t SizeOf(const uint8_t rv) { return kMaxSizeOf; } + uint32_t SizeOf(const uint8_t rv) { + if (rv>1) { + return kMaxSizeOf; + } else { + return kMaxSizeOf - sizeof(uint8_t); + } + } template<class T> static @@ -23,6 +29,7 @@ const uint32_t time, const uint32_t num) { // expect 'x' to be a MODSERIAL or a char const* + x = SnBitUtils::WriteTo(x, kIOVers); x = SnBitUtils::WriteTo(x, time); x = SnBitUtils::WriteTo(x, num); return SnCommWin::kOkMsgSent; @@ -33,6 +40,21 @@ SnCommWin::ECommWinResult ReadFrom(T& b, uint32_t& time, uint32_t& num) { + // this can't read V1 of the heartbeat + uint8_t Rv=0; + b = SnBitUtils::ReadFrom(b, Rv); + b = SnBitUtils::ReadFrom(b, time); + b = SnBitUtils::ReadFrom(b, num); + return SnCommWin::kOkWithMsg; + } + + template<class T> + static + SnCommWin::ECommWinResult ReadFromV1(T& b, + uint32_t& time, + uint32_t& num) { + // need a special fcn to read V1 of this frame, + // since the i/o version was not written out in V1 b = SnBitUtils::ReadFrom(b, time); b = SnBitUtils::ReadFrom(b, num); return SnCommWin::kOkWithMsg;