Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnSignalStrengthFrame.h
- Revision:
- 41:d6f5e2f09e07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SnSignalStrengthFrame.h Tue Oct 08 23:44:00 2013 +0000 @@ -0,0 +1,63 @@ +#ifndef SNS_SnSignalStrengthFrame +#define SNS_SnSignalStrengthFrame + +#include "mbed.h" +#include <stdint.h> + +#include "SnCommWin.h" + +class SnSignalStrengthFrame { + public: + static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes + static const uint32_t kMaxSizeOf = 2u*sizeof(uint8_t) + sizeof(float) + sizeof(uint32_t); + + + private: + uint8_t fCommType; + float fSigStr; + uint32_t fSSTime; + + public: + SnSignalStrengthFrame() : + fCommType(0), fSigStr(0), fSSTime(0) {} + virtual ~SnSignalStrengthFrame() {} + + void SetSigStr(const float ss, const uint32_t stim) { + fSigStr = ss; + fSSTime = stim; + } + + void SetCommType(const uint8_t t) { fCommType = t; } + + static + uint32_t SizeOf(const uint8_t rv=SnSignalStrengthFrame::kIOVers) + { return kMaxSizeOf; } + + template<class T> + SnCommWin::ECommWinResult WriteTo(T& x) { + // expect 'x' to be a MODSERIAL or a char const* or a FILE* + x = SnBitUtils::WriteTo(x, kIOVers); + x = SnBitUtils::WriteTo(x, fCommType); + x = SnBitUtils::WriteTo(x, fSigStr); + x = SnBitUtils::WriteTo(x, fSSTime); + return SnCommWin::kOkMsgSent; + } + + template<class T> + static + SnCommWin::ECommWinResult ReadFrom(T& b, + uint8_t& commtype, + float& sigstr, + uint32_t& stim) { + uint8_t Rv=0; + b = SnBitUtils::ReadFrom(b, Rv); + b = SnBitUtils::ReadFrom(b, commtype); + b = SnBitUtils::ReadFrom(b, sigstr); + b = SnBitUtils::ReadFrom(b, stim); + return SnCommWin::kOkWithMsg; + } + + +}; + +#endif // SNS_SnSignalStrengthFrame