Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnHeartbeatFrame.h
- Committer:
- uci1
- Date:
- 2013-10-05
- Revision:
- 40:1324da35afd4
- Parent:
- 22:f957c4f840ad
- Child:
- 84:80b15993944e
File content as of revision 40:1324da35afd4:
#ifndef SN_SnHeartbeatFrame #define SN_SnHeartbeatFrame #include <stdint.h> #include "SnCommWin.h" class SnHeartbeatFrame { 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) + sizeof(uint8_t); public: SnHeartbeatFrame() {} virtual ~SnHeartbeatFrame() {} static uint32_t SizeOf(const uint8_t rv) { if (rv>1) { return kMaxSizeOf; } else { return kMaxSizeOf - sizeof(uint8_t); } } template<class T> static SnCommWin::ECommWinResult WriteTo(T& x, 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; } template<class T> static 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; } }; #endif // SN_SnHeartbeatFrame