![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnHeartbeatFrame.h@40:1324da35afd4, 2013-10-05 (annotated)
- Committer:
- uci1
- Date:
- Sat Oct 05 04:45:22 2013 +0000
- Revision:
- 40:1324da35afd4
- Parent:
- 22:f957c4f840ad
- Child:
- 84:80b15993944e
first commit of major overhaul to 2013-2014 mbed code. NOT YET FULLY TESTED. too many changes to list (fix local file receive, fix rates, external comm packes, big SD cards, get to comm win w/o SD, v8 config frame, v4 files, SBD buffering changes...)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 22:f957c4f840ad | 1 | #ifndef SN_SnHeartbeatFrame |
uci1 | 22:f957c4f840ad | 2 | #define SN_SnHeartbeatFrame |
uci1 | 22:f957c4f840ad | 3 | |
uci1 | 22:f957c4f840ad | 4 | #include <stdint.h> |
uci1 | 22:f957c4f840ad | 5 | #include "SnCommWin.h" |
uci1 | 22:f957c4f840ad | 6 | |
uci1 | 22:f957c4f840ad | 7 | class SnHeartbeatFrame { |
uci1 | 22:f957c4f840ad | 8 | public: |
uci1 | 22:f957c4f840ad | 9 | // i/o version |
uci1 | 22:f957c4f840ad | 10 | static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes |
uci1 | 40:1324da35afd4 | 11 | static const uint32_t kMaxSizeOf = 2u*sizeof(uint32_t) + sizeof(uint8_t); |
uci1 | 22:f957c4f840ad | 12 | |
uci1 | 22:f957c4f840ad | 13 | public: |
uci1 | 22:f957c4f840ad | 14 | SnHeartbeatFrame() {} |
uci1 | 22:f957c4f840ad | 15 | virtual ~SnHeartbeatFrame() {} |
uci1 | 22:f957c4f840ad | 16 | |
uci1 | 22:f957c4f840ad | 17 | static |
uci1 | 40:1324da35afd4 | 18 | uint32_t SizeOf(const uint8_t rv) { |
uci1 | 40:1324da35afd4 | 19 | if (rv>1) { |
uci1 | 40:1324da35afd4 | 20 | return kMaxSizeOf; |
uci1 | 40:1324da35afd4 | 21 | } else { |
uci1 | 40:1324da35afd4 | 22 | return kMaxSizeOf - sizeof(uint8_t); |
uci1 | 40:1324da35afd4 | 23 | } |
uci1 | 40:1324da35afd4 | 24 | } |
uci1 | 22:f957c4f840ad | 25 | |
uci1 | 22:f957c4f840ad | 26 | template<class T> |
uci1 | 22:f957c4f840ad | 27 | static |
uci1 | 22:f957c4f840ad | 28 | SnCommWin::ECommWinResult WriteTo(T& x, |
uci1 | 22:f957c4f840ad | 29 | const uint32_t time, |
uci1 | 22:f957c4f840ad | 30 | const uint32_t num) { |
uci1 | 22:f957c4f840ad | 31 | // expect 'x' to be a MODSERIAL or a char const* |
uci1 | 40:1324da35afd4 | 32 | x = SnBitUtils::WriteTo(x, kIOVers); |
uci1 | 22:f957c4f840ad | 33 | x = SnBitUtils::WriteTo(x, time); |
uci1 | 22:f957c4f840ad | 34 | x = SnBitUtils::WriteTo(x, num); |
uci1 | 22:f957c4f840ad | 35 | return SnCommWin::kOkMsgSent; |
uci1 | 22:f957c4f840ad | 36 | } |
uci1 | 22:f957c4f840ad | 37 | |
uci1 | 22:f957c4f840ad | 38 | template<class T> |
uci1 | 22:f957c4f840ad | 39 | static |
uci1 | 22:f957c4f840ad | 40 | SnCommWin::ECommWinResult ReadFrom(T& b, |
uci1 | 22:f957c4f840ad | 41 | uint32_t& time, |
uci1 | 22:f957c4f840ad | 42 | uint32_t& num) { |
uci1 | 40:1324da35afd4 | 43 | // this can't read V1 of the heartbeat |
uci1 | 40:1324da35afd4 | 44 | uint8_t Rv=0; |
uci1 | 40:1324da35afd4 | 45 | b = SnBitUtils::ReadFrom(b, Rv); |
uci1 | 40:1324da35afd4 | 46 | b = SnBitUtils::ReadFrom(b, time); |
uci1 | 40:1324da35afd4 | 47 | b = SnBitUtils::ReadFrom(b, num); |
uci1 | 40:1324da35afd4 | 48 | return SnCommWin::kOkWithMsg; |
uci1 | 40:1324da35afd4 | 49 | } |
uci1 | 40:1324da35afd4 | 50 | |
uci1 | 40:1324da35afd4 | 51 | template<class T> |
uci1 | 40:1324da35afd4 | 52 | static |
uci1 | 40:1324da35afd4 | 53 | SnCommWin::ECommWinResult ReadFromV1(T& b, |
uci1 | 40:1324da35afd4 | 54 | uint32_t& time, |
uci1 | 40:1324da35afd4 | 55 | uint32_t& num) { |
uci1 | 40:1324da35afd4 | 56 | // need a special fcn to read V1 of this frame, |
uci1 | 40:1324da35afd4 | 57 | // since the i/o version was not written out in V1 |
uci1 | 22:f957c4f840ad | 58 | b = SnBitUtils::ReadFrom(b, time); |
uci1 | 22:f957c4f840ad | 59 | b = SnBitUtils::ReadFrom(b, num); |
uci1 | 22:f957c4f840ad | 60 | return SnCommWin::kOkWithMsg; |
uci1 | 22:f957c4f840ad | 61 | } |
uci1 | 22:f957c4f840ad | 62 | |
uci1 | 22:f957c4f840ad | 63 | |
uci1 | 22:f957c4f840ad | 64 | }; |
uci1 | 22:f957c4f840ad | 65 | |
uci1 | 22:f957c4f840ad | 66 | #endif // SN_SnHeartbeatFrame |