![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnSignalStrengthFrame.h@125:ce4045184366, 2019-06-05 (annotated)
- Committer:
- uci1
- Date:
- Wed Jun 05 17:29:31 2019 +0000
- Revision:
- 125:ce4045184366
- Parent:
- 41:d6f5e2f09e07
Added SnRateListner proto-class, publishing this version of the code in order to enable exporting of most recent features.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 41:d6f5e2f09e07 | 1 | #ifndef SNS_SnSignalStrengthFrame |
uci1 | 41:d6f5e2f09e07 | 2 | #define SNS_SnSignalStrengthFrame |
uci1 | 41:d6f5e2f09e07 | 3 | |
uci1 | 41:d6f5e2f09e07 | 4 | #include "mbed.h" |
uci1 | 41:d6f5e2f09e07 | 5 | #include <stdint.h> |
uci1 | 41:d6f5e2f09e07 | 6 | |
uci1 | 41:d6f5e2f09e07 | 7 | #include "SnCommWin.h" |
uci1 | 41:d6f5e2f09e07 | 8 | |
uci1 | 41:d6f5e2f09e07 | 9 | class SnSignalStrengthFrame { |
uci1 | 41:d6f5e2f09e07 | 10 | public: |
uci1 | 41:d6f5e2f09e07 | 11 | static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes |
uci1 | 41:d6f5e2f09e07 | 12 | static const uint32_t kMaxSizeOf = 2u*sizeof(uint8_t) + sizeof(float) + sizeof(uint32_t); |
uci1 | 41:d6f5e2f09e07 | 13 | |
uci1 | 41:d6f5e2f09e07 | 14 | |
uci1 | 41:d6f5e2f09e07 | 15 | private: |
uci1 | 41:d6f5e2f09e07 | 16 | uint8_t fCommType; |
uci1 | 41:d6f5e2f09e07 | 17 | float fSigStr; |
uci1 | 41:d6f5e2f09e07 | 18 | uint32_t fSSTime; |
uci1 | 41:d6f5e2f09e07 | 19 | |
uci1 | 41:d6f5e2f09e07 | 20 | public: |
uci1 | 41:d6f5e2f09e07 | 21 | SnSignalStrengthFrame() : |
uci1 | 41:d6f5e2f09e07 | 22 | fCommType(0), fSigStr(0), fSSTime(0) {} |
uci1 | 41:d6f5e2f09e07 | 23 | virtual ~SnSignalStrengthFrame() {} |
uci1 | 41:d6f5e2f09e07 | 24 | |
uci1 | 41:d6f5e2f09e07 | 25 | void SetSigStr(const float ss, const uint32_t stim) { |
uci1 | 41:d6f5e2f09e07 | 26 | fSigStr = ss; |
uci1 | 41:d6f5e2f09e07 | 27 | fSSTime = stim; |
uci1 | 41:d6f5e2f09e07 | 28 | } |
uci1 | 41:d6f5e2f09e07 | 29 | |
uci1 | 41:d6f5e2f09e07 | 30 | void SetCommType(const uint8_t t) { fCommType = t; } |
uci1 | 41:d6f5e2f09e07 | 31 | |
uci1 | 41:d6f5e2f09e07 | 32 | static |
uci1 | 41:d6f5e2f09e07 | 33 | uint32_t SizeOf(const uint8_t rv=SnSignalStrengthFrame::kIOVers) |
uci1 | 41:d6f5e2f09e07 | 34 | { return kMaxSizeOf; } |
uci1 | 41:d6f5e2f09e07 | 35 | |
uci1 | 41:d6f5e2f09e07 | 36 | template<class T> |
uci1 | 41:d6f5e2f09e07 | 37 | SnCommWin::ECommWinResult WriteTo(T& x) { |
uci1 | 41:d6f5e2f09e07 | 38 | // expect 'x' to be a MODSERIAL or a char const* or a FILE* |
uci1 | 41:d6f5e2f09e07 | 39 | x = SnBitUtils::WriteTo(x, kIOVers); |
uci1 | 41:d6f5e2f09e07 | 40 | x = SnBitUtils::WriteTo(x, fCommType); |
uci1 | 41:d6f5e2f09e07 | 41 | x = SnBitUtils::WriteTo(x, fSigStr); |
uci1 | 41:d6f5e2f09e07 | 42 | x = SnBitUtils::WriteTo(x, fSSTime); |
uci1 | 41:d6f5e2f09e07 | 43 | return SnCommWin::kOkMsgSent; |
uci1 | 41:d6f5e2f09e07 | 44 | } |
uci1 | 41:d6f5e2f09e07 | 45 | |
uci1 | 41:d6f5e2f09e07 | 46 | template<class T> |
uci1 | 41:d6f5e2f09e07 | 47 | static |
uci1 | 41:d6f5e2f09e07 | 48 | SnCommWin::ECommWinResult ReadFrom(T& b, |
uci1 | 41:d6f5e2f09e07 | 49 | uint8_t& commtype, |
uci1 | 41:d6f5e2f09e07 | 50 | float& sigstr, |
uci1 | 41:d6f5e2f09e07 | 51 | uint32_t& stim) { |
uci1 | 41:d6f5e2f09e07 | 52 | uint8_t Rv=0; |
uci1 | 41:d6f5e2f09e07 | 53 | b = SnBitUtils::ReadFrom(b, Rv); |
uci1 | 41:d6f5e2f09e07 | 54 | b = SnBitUtils::ReadFrom(b, commtype); |
uci1 | 41:d6f5e2f09e07 | 55 | b = SnBitUtils::ReadFrom(b, sigstr); |
uci1 | 41:d6f5e2f09e07 | 56 | b = SnBitUtils::ReadFrom(b, stim); |
uci1 | 41:d6f5e2f09e07 | 57 | return SnCommWin::kOkWithMsg; |
uci1 | 41:d6f5e2f09e07 | 58 | } |
uci1 | 41:d6f5e2f09e07 | 59 | |
uci1 | 41:d6f5e2f09e07 | 60 | |
uci1 | 41:d6f5e2f09e07 | 61 | }; |
uci1 | 41:d6f5e2f09e07 | 62 | |
uci1 | 41:d6f5e2f09e07 | 63 | #endif // SNS_SnSignalStrengthFrame |