Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnConfigFrame.h
- Revision:
- 1:e392595b4b76
- Parent:
- 0:664899e0b988
- Child:
- 3:24c5f0f50bf1
--- a/SnConfigFrame.h Sat Jun 30 02:03:51 2012 +0000 +++ b/SnConfigFrame.h Fri Jul 20 19:04:02 2012 +0000 @@ -7,18 +7,18 @@ class SnConfigFrame { public: - static const uint32_t kMinCommWinPrdLowPwr; // exclusive min low power comm win period (s) - static const uint32_t kMaxCommWinPrdLowPwr; // exclusive max low power comm win period (s) - static const uint32_t kMinCommWinDurLowPwr; // exclusive min low power comm win duration (s) - static const uint32_t kMaxCommWinDurLowPwr; // exclusive max low power comm win duration (s) - static const uint8_t kConfLblLen=64; // length of configuration label char array (63+'\0') + static const uint32_t kMinCommWinPrdLowPwr; // exclusive min low power comm win period (s) + static const uint32_t kMaxCommWinPrdLowPwr; // exclusive max low power comm win period (s) + static const uint32_t kMinCommWinDurLowPwr; // exclusive min low power comm win duration (s) + static const uint32_t kMaxCommWinDurLowPwr; // exclusive max low power comm win duration (s) + static const uint8_t kConfLblLen=64; // length of configuration label char array (63+'\0') - static const char* kDefConfFile; // default configuration file + static const char* const kDefConfFile; // default configuration file static const uint32_t kMaxSizeOf = - 1u + // the i/o version - + (8u*sizeof(uint32_t)) + (8u*sizeof(uint16_t)) - + (9u*sizeof(uint8_t)) + (2u*kNplas*sizeof(uint16_t)) + + (9u*sizeof(uint32_t)) + (6u*sizeof(uint16_t)) + + (10u*sizeof(uint8_t)) + (3u*kNplas*sizeof(uint16_t)) + + (kTotDacs*sizeof(uint16_t)) + (kConfLblLen*sizeof(uint8_t)); @@ -31,13 +31,14 @@ enum ESendDataBit { // can't use BIT(0)! (-0 = 0 => send nothing) - kAllFiles = BIT(1), // if bit=0 => send most recent file - kTimeout = BIT(2), // if bit=0 => ignore timeout - kDelete = BIT(3) // if bit=0 => do not delete sent files + kAllFiles = BIT(1), // if bit=0 => send most recent file + kTimeout = BIT(2), // if bit=0 => ignore timeout + kDelete = BIT(3), // if bit=0 => do not delete sent files + kUseBits = -BIT(10) // useful to initialize fCommSendData as a bit word }; // i/o version - static const int8_t kIOVers; // MUST BE INCREASED if any member var changes (==> also if kNchans, etc. change!) + static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes (==> also if kNchans, etc. change!) private: // !! @@ -82,15 +83,20 @@ void SetHardDefaults(); static - uint32_t SizeOf(const bool streamHiLoPlas, const uint8_t lblLen) { + uint32_t SizeOf(const bool streamHiLoPlas, + const uint8_t nplas, + const uint8_t lblLen) { // private because it cannot be used to read from a buffer // (the label length and fStreamHiLoPlas are not known a priori) // returns the num of bytes needed to stream this object // = size of member vars + 1 for i/o version + extra PLA strings (maybe) uint32_t sz = kMaxSizeOf - kConfLblLen + lblLen; + static const uint32_t mhlp = 2u*kNplas*sizeof(uint16_t); + const int32_t dp = (nplas-kNplas)*sizeof(uint16_t); + const uint8_t fac = (streamHiLoPlas) ? 3u : 1u; + sz -= (fac*dp); if (streamHiLoPlas==false) { - static const uint32_t shlp = 2u*kNplas*sizeof(uint16_t); - sz -= shlp; + sz -= mhlp; } return sz; } @@ -151,7 +157,7 @@ // // must match WriteTo - int8_t Rv=0; + uint8_t Rv=0; b = SnBitUtils::ReadFrom(b, Rv); // i/o version if (Rv>0) { uint32_t llen=kConfLblLen; @@ -189,12 +195,11 @@ b = SnBitUtils::ReadFrom(b, fCommWinDurLowPwr); b = SnBitUtils::ReadFrom(b, fWatchDogPeriod); if (fStreamHiLoPlas!=0) { - pl = fPLA; uint16_t hi, lo; - for (uint8_t j=0; j<fNumPlas; j++, pl++) { - GetHiLoPlas(*pl, hi, lo); + for (uint8_t j=0; j<fNumPlas; j++) { b = SnBitUtils::ReadFrom(b, hi); b = SnBitUtils::ReadFrom(b, lo); + // don't save these } } } @@ -271,7 +276,7 @@ // returns the num of bytes needed to stream this object // = size of member vars + 1 for i/o version + extra PLA strings (maybe) // + length of label string - return SizeOf(fStreamHiLoPlas!=0, strlen(fLabel)); + return SizeOf(fStreamHiLoPlas!=0, fNumPlas, strlen(fLabel)); } static void SetMacAddress();