Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnConfigFrame.h@19:74155d652c37, 2012-10-02 (annotated)
- Committer:
- uci1
- Date:
- Tue Oct 02 01:58:50 2012 +0000
- Revision:
- 19:74155d652c37
- Parent:
- 18:55f1581f2ee4
- Child:
- 21:ce51bb0ba4a5
Moved output directory of event files to /sd/data in order to avoid the SD file system's maximum number of files in its root directory. Fix bug in SnConfigFrame::SizeOf to account for new i/o version 4 (number of bytes should be equal, tho). This versi...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 3:24c5f0f50bf1 | 1 | #ifndef SN_SnConfigFrame |
uci1 | 3:24c5f0f50bf1 | 2 | #define SN_SnConfigFrame |
uci1 | 3:24c5f0f50bf1 | 3 | |
uci1 | 3:24c5f0f50bf1 | 4 | #include <stdint.h> |
uci1 | 3:24c5f0f50bf1 | 5 | #include "SnConstants.h" |
uci1 | 3:24c5f0f50bf1 | 6 | #include "SnBitUtils.h" |
uci1 | 3:24c5f0f50bf1 | 7 | |
uci1 | 16:744ce85aede2 | 8 | //#define DEBUG |
uci1 | 16:744ce85aede2 | 9 | |
uci1 | 3:24c5f0f50bf1 | 10 | class SnConfigFrame { |
uci1 | 3:24c5f0f50bf1 | 11 | public: |
uci1 | 3:24c5f0f50bf1 | 12 | static const uint32_t kMinCommWinPrdLowPwr; // exclusive min low power comm win period (s) |
uci1 | 3:24c5f0f50bf1 | 13 | static const uint32_t kMaxCommWinPrdLowPwr; // exclusive max low power comm win period (s) |
uci1 | 3:24c5f0f50bf1 | 14 | static const uint32_t kMinCommWinDurLowPwr; // exclusive min low power comm win duration (s) |
uci1 | 3:24c5f0f50bf1 | 15 | static const uint32_t kMaxCommWinDurLowPwr; // exclusive max low power comm win duration (s) |
uci1 | 3:24c5f0f50bf1 | 16 | static const uint8_t kConfLblLen=64; // length of configuration label char array (63+'\0') |
uci1 | 8:95a325df1f6b | 17 | static const uint8_t kIPLen=16; // length of IP string. matches MBED's Socket class (so no ipv6) |
uci1 | 3:24c5f0f50bf1 | 18 | |
uci1 | 3:24c5f0f50bf1 | 19 | static const char* const kDefConfFile; // default configuration file |
uci1 | 3:24c5f0f50bf1 | 20 | |
uci1 | 8:95a325df1f6b | 21 | static const uint32_t kMaxSizeOfV1 = |
uci1 | 8:95a325df1f6b | 22 | + (9u*sizeof(uint32_t)) + (6u*sizeof(uint16_t)) |
uci1 | 8:95a325df1f6b | 23 | + (10u*sizeof(uint8_t)) + (3u*kNplas*sizeof(uint16_t)) |
uci1 | 3:24c5f0f50bf1 | 24 | + (kTotDacs*sizeof(uint16_t)) |
uci1 | 3:24c5f0f50bf1 | 25 | + (kConfLblLen*sizeof(uint8_t)); |
uci1 | 8:95a325df1f6b | 26 | static const uint32_t kMaxSizeOfV2 = |
uci1 | 8:95a325df1f6b | 27 | kMaxSizeOfV1 + sizeof(uint32_t) + sizeof(uint8_t); |
uci1 | 8:95a325df1f6b | 28 | static const uint32_t kMaxSizeOfV3 = |
uci1 | 8:95a325df1f6b | 29 | kMaxSizeOfV2 + (2u*sizeof(uint16_t)) + (4u*kIPLen*sizeof(char)); |
uci1 | 18:55f1581f2ee4 | 30 | static const uint32_t kMaxSizeOfV4 = kMaxSizeOfV3 + (sizeof(float)-sizeof(uint16_t)); |
uci1 | 18:55f1581f2ee4 | 31 | static const uint32_t kMaxSizeOf = kMaxSizeOfV4; |
uci1 | 3:24c5f0f50bf1 | 32 | |
uci1 | 3:24c5f0f50bf1 | 33 | enum EDatPackBit { |
uci1 | 3:24c5f0f50bf1 | 34 | kSDcard = BIT(0), |
uci1 | 3:24c5f0f50bf1 | 35 | kIrid = BIT(1), |
uci1 | 3:24c5f0f50bf1 | 36 | kAfar = BIT(2), |
uci1 | 3:24c5f0f50bf1 | 37 | kUSB = BIT(3) |
uci1 | 3:24c5f0f50bf1 | 38 | }; |
uci1 | 3:24c5f0f50bf1 | 39 | |
uci1 | 3:24c5f0f50bf1 | 40 | enum ESendDataBit { |
uci1 | 3:24c5f0f50bf1 | 41 | // can't use BIT(0)! (-0 = 0 => send nothing) |
uci1 | 13:7a1fb885a8e4 | 42 | kAllFiles = BIT(1), // if bit=0 => send most recent file |
uci1 | 13:7a1fb885a8e4 | 43 | kTimeout = BIT(2), // if bit=0 => ignore timeout |
uci1 | 13:7a1fb885a8e4 | 44 | kDelete = BIT(3), // if bit=0 => do not delete sent files |
uci1 | 13:7a1fb885a8e4 | 45 | kForceSBDdata = BIT(4), // if bit=0 => do not send data over SBD |
uci1 | 13:7a1fb885a8e4 | 46 | kUseBits = -BIT(15) // useful to initialize fCommSendData as a bit word |
uci1 | 3:24c5f0f50bf1 | 47 | }; |
uci1 | 3:24c5f0f50bf1 | 48 | |
uci1 | 4:a91682e19d6b | 49 | enum EPowerModeBit { |
uci1 | 4:a91682e19d6b | 50 | kAmpsDatTak = BIT(0), |
uci1 | 4:a91682e19d6b | 51 | kCardDatTak = BIT(1), |
uci1 | 4:a91682e19d6b | 52 | kIridDatTak = BIT(2), |
uci1 | 4:a91682e19d6b | 53 | kAfarDatTak = BIT(3), |
uci1 | 4:a91682e19d6b | 54 | kAmpsComWin = BIT(4), |
uci1 | 4:a91682e19d6b | 55 | kCardComWin = BIT(5), |
uci1 | 4:a91682e19d6b | 56 | kIridComWin = BIT(6), |
uci1 | 4:a91682e19d6b | 57 | kAfarComWin = BIT(7) |
uci1 | 4:a91682e19d6b | 58 | }; |
uci1 | 4:a91682e19d6b | 59 | |
uci1 | 3:24c5f0f50bf1 | 60 | enum ERunMode { |
uci1 | 8:95a325df1f6b | 61 | kSingleSeqBit = BIT(0), // if 0, infinite sequences |
uci1 | 8:95a325df1f6b | 62 | kCountPowerBit = BIT(1), // if 0, count events |
uci1 | 3:24c5f0f50bf1 | 63 | }; |
uci1 | 3:24c5f0f50bf1 | 64 | |
uci1 | 3:24c5f0f50bf1 | 65 | // i/o version |
uci1 | 3:24c5f0f50bf1 | 66 | static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes (==> also if kNchans, etc. change!) |
uci1 | 3:24c5f0f50bf1 | 67 | |
uci1 | 3:24c5f0f50bf1 | 68 | private: |
uci1 | 3:24c5f0f50bf1 | 69 | // !! |
uci1 | 3:24c5f0f50bf1 | 70 | // !! If any member variables change, update: SizeOf function and kIOVers value! (also if kNchans, etc. change!) |
uci1 | 3:24c5f0f50bf1 | 71 | // !! |
uci1 | 3:24c5f0f50bf1 | 72 | |
uci1 | 3:24c5f0f50bf1 | 73 | // mbed mac address |
uci1 | 3:24c5f0f50bf1 | 74 | static uint64_t fgMacAdr; // mbed mac address |
uci1 | 3:24c5f0f50bf1 | 75 | // conf header |
uci1 | 3:24c5f0f50bf1 | 76 | char fLabel[kConfLblLen]; // configuration label |
uci1 | 3:24c5f0f50bf1 | 77 | uint32_t fConfTime; // cpu config time |
uci1 | 3:24c5f0f50bf1 | 78 | uint32_t fRun; // run number |
uci1 | 3:24c5f0f50bf1 | 79 | uint32_t fFirstEvt; // starting event number |
uci1 | 3:24c5f0f50bf1 | 80 | uint32_t fEvtsPerSeq; // number of events per file |
uci1 | 3:24c5f0f50bf1 | 81 | uint8_t fRunMode; // mode of running (see ERunMode) |
uci1 | 3:24c5f0f50bf1 | 82 | uint8_t fStreamHiLoPlas; // (1byte bool) if true, add the separated hi/lo thresh PLA patterns to the i/o |
uci1 | 3:24c5f0f50bf1 | 83 | // data packing |
uci1 | 3:24c5f0f50bf1 | 84 | uint8_t fWvLoseLSB; // number of least significant bits to lose when packing waveform data |
uci1 | 3:24c5f0f50bf1 | 85 | uint8_t fWvLoseMSB; // number of most significant bits to lose when packing waveform data |
uci1 | 3:24c5f0f50bf1 | 86 | uint16_t fWvBaseline; // global baseline to use when packing data (useful to reduce clipping on the high end) |
uci1 | 3:24c5f0f50bf1 | 87 | uint8_t fDatPackType; // type of data packing. OR'd bitword: if bit 1, will pack for writing. see EDatPackBit. default: always pack (all 1's) |
uci1 | 3:24c5f0f50bf1 | 88 | // trigger setup |
uci1 | 3:24c5f0f50bf1 | 89 | uint16_t fDAC[kNchans][kNfpgaDacs]; //[card id][dac id] values should be 0-4095 here (not checked tho) |
uci1 | 3:24c5f0f50bf1 | 90 | uint8_t fNumPlas; // number of patterns to use. must be <= kNplas. |
uci1 | 3:24c5f0f50bf1 | 91 | uint16_t fPLA[kNplas]; //[pattern id] (same for each card) |
uci1 | 3:24c5f0f50bf1 | 92 | uint8_t fNumCardsMajLog; // number of cards participating in the MajLogic trigger (1 to 4) |
uci1 | 3:24c5f0f50bf1 | 93 | uint8_t fEnableThermTrig; // (1byte bool) whether or not to allow thermal triggers |
uci1 | 18:55f1581f2ee4 | 94 | float fForceTrigPeriod; // number of seconds between force triggers (0=none) |
uci1 | 3:24c5f0f50bf1 | 95 | uint16_t fHeartBeatPeriod; // number of seconds between heartbeats (0=none) |
uci1 | 3:24c5f0f50bf1 | 96 | uint8_t fAmpsOn; // which amps are on (bit word. uint8_t => 8 amps max) |
uci1 | 3:24c5f0f50bf1 | 97 | uint16_t fEvtThrtlPeriodMs; // throttle period to write events (ms) |
uci1 | 3:24c5f0f50bf1 | 98 | // power |
uci1 | 4:a91682e19d6b | 99 | uint8_t fPowerMode; // power mode bit word: see EPowerModeBit |
uci1 | 3:24c5f0f50bf1 | 100 | int16_t fBatVoltLowPwr; // battery level at which to switch to low power (not used?) |
uci1 | 8:95a325df1f6b | 101 | uint16_t fVoltCheckPeriod; // how often to check the voltages (s) |
uci1 | 3:24c5f0f50bf1 | 102 | // communication |
uci1 | 3:24c5f0f50bf1 | 103 | uint32_t fCommWinPeriod; // seconds between communication window startup (0=always on) |
uci1 | 3:24c5f0f50bf1 | 104 | uint32_t fCommWinDuration; // seconds that communication window stays open (0=always open) |
uci1 | 3:24c5f0f50bf1 | 105 | int16_t fCommSendData; // data to send during comm win (=0: none, >0=send up to x events from last file until comm win closes, <0=see ESendDataBit) |
uci1 | 3:24c5f0f50bf1 | 106 | uint32_t fCommWinPrdLowPwr; // low power communication window period (seconds) (range enforced) |
uci1 | 3:24c5f0f50bf1 | 107 | uint32_t fCommWinDurLowPwr; // low power communication window duration (seconds) (range enforced) |
uci1 | 8:95a325df1f6b | 108 | char fRemoteServer[kIPLen]; // IP address of remote server (for afar) |
uci1 | 8:95a325df1f6b | 109 | uint16_t fRemotePort; // port number of remote server (for afar) |
uci1 | 8:95a325df1f6b | 110 | char fMbedIP[kIPLen]; // IP address of this mbed |
uci1 | 8:95a325df1f6b | 111 | char fMbedMask[kIPLen]; // IP address of this mbed mask |
uci1 | 8:95a325df1f6b | 112 | char fMbedGate[kIPLen]; // IP address of this mbed gateway |
uci1 | 3:24c5f0f50bf1 | 113 | // watchdog |
uci1 | 3:24c5f0f50bf1 | 114 | uint32_t fWatchDogPeriod; // number of seconds of inactivity for watchdog to issue a reset |
uci1 | 3:24c5f0f50bf1 | 115 | |
uci1 | 8:95a325df1f6b | 116 | // in case of low power, store regular settings |
uci1 | 8:95a325df1f6b | 117 | // these are not sent over i/o or stored in the file |
uci1 | 8:95a325df1f6b | 118 | // so they are not included in SizeOf |
uci1 | 8:95a325df1f6b | 119 | bool fIsLowPower; |
uci1 | 8:95a325df1f6b | 120 | char fNormLabel[kConfLblLen]; |
uci1 | 8:95a325df1f6b | 121 | uint8_t fNormPowerMode; |
uci1 | 8:95a325df1f6b | 122 | |
uci1 | 3:24c5f0f50bf1 | 123 | void SetHardDefaults(); |
uci1 | 3:24c5f0f50bf1 | 124 | |
uci1 | 3:24c5f0f50bf1 | 125 | static |
uci1 | 8:95a325df1f6b | 126 | uint32_t SizeOf(const uint8_t rv, |
uci1 | 8:95a325df1f6b | 127 | const bool streamHiLoPlas, |
uci1 | 3:24c5f0f50bf1 | 128 | const uint8_t nplas, |
uci1 | 3:24c5f0f50bf1 | 129 | const uint8_t lblLen) { |
uci1 | 3:24c5f0f50bf1 | 130 | // private because it cannot be used to read from a buffer |
uci1 | 3:24c5f0f50bf1 | 131 | // (the label length and fStreamHiLoPlas are not known a priori) |
uci1 | 3:24c5f0f50bf1 | 132 | // returns the num of bytes needed to stream this object |
uci1 | 3:24c5f0f50bf1 | 133 | // = size of member vars + 1 for i/o version + extra PLA strings (maybe) |
uci1 | 8:95a325df1f6b | 134 | uint32_t maxsize = kMaxSizeOf; |
uci1 | 8:95a325df1f6b | 135 | if (rv==1) { |
uci1 | 8:95a325df1f6b | 136 | maxsize = kMaxSizeOfV1; |
uci1 | 8:95a325df1f6b | 137 | } else if (rv==2) { |
uci1 | 8:95a325df1f6b | 138 | maxsize = kMaxSizeOfV2; |
uci1 | 19:74155d652c37 | 139 | } else if (rv==3) { |
uci1 | 19:74155d652c37 | 140 | maxsize = kMaxSizeOfV3; |
uci1 | 8:95a325df1f6b | 141 | } |
uci1 | 8:95a325df1f6b | 142 | uint32_t sz = maxsize - kConfLblLen + lblLen; |
uci1 | 3:24c5f0f50bf1 | 143 | static const uint32_t mhlp = 2u*kNplas*sizeof(uint16_t); |
uci1 | 3:24c5f0f50bf1 | 144 | const int32_t dp = (nplas-kNplas)*sizeof(uint16_t); |
uci1 | 3:24c5f0f50bf1 | 145 | const uint8_t fac = (streamHiLoPlas) ? 3u : 1u; |
uci1 | 3:24c5f0f50bf1 | 146 | sz += (fac*dp); |
uci1 | 3:24c5f0f50bf1 | 147 | if (streamHiLoPlas==false) { |
uci1 | 3:24c5f0f50bf1 | 148 | sz -= mhlp; |
uci1 | 3:24c5f0f50bf1 | 149 | } |
uci1 | 3:24c5f0f50bf1 | 150 | return sz; |
uci1 | 3:24c5f0f50bf1 | 151 | } |
uci1 | 3:24c5f0f50bf1 | 152 | |
uci1 | 3:24c5f0f50bf1 | 153 | public: |
uci1 | 8:95a325df1f6b | 154 | SnConfigFrame() : fIsLowPower(false) { Reset(); } |
uci1 | 3:24c5f0f50bf1 | 155 | virtual ~SnConfigFrame() {} |
uci1 | 3:24c5f0f50bf1 | 156 | |
uci1 | 8:95a325df1f6b | 157 | bool IsCountingPowerReadings() const { return ((fRunMode & kCountPowerBit)!=0); } |
uci1 | 8:95a325df1f6b | 158 | bool IsSingleSeqRunMode() const { return ((fRunMode & kSingleSeqBit)!=0); } |
uci1 | 8:95a325df1f6b | 159 | bool IsLowPowerMode() const { return fIsLowPower; } |
uci1 | 3:24c5f0f50bf1 | 160 | const char* GetLabel() const { return fLabel; } |
uci1 | 3:24c5f0f50bf1 | 161 | uint32_t GetLabelStrLen() const { return strlen(fLabel); } |
uci1 | 3:24c5f0f50bf1 | 162 | uint32_t GetRun() const { return fRun; } |
uci1 | 3:24c5f0f50bf1 | 163 | uint32_t GetFirstEvt() const { return fFirstEvt; } |
uci1 | 3:24c5f0f50bf1 | 164 | uint32_t GetEvtsPerFile() const { return fEvtsPerSeq; } |
uci1 | 3:24c5f0f50bf1 | 165 | uint16_t GetEvtThrtlPeriodMs() const { return fEvtThrtlPeriodMs; } |
uci1 | 18:55f1581f2ee4 | 166 | float GetForceTrigPeriod() const { return fForceTrigPeriod; } |
uci1 | 3:24c5f0f50bf1 | 167 | uint16_t GetHeartbeatPeriod() const { return fHeartBeatPeriod; } |
uci1 | 8:95a325df1f6b | 168 | uint16_t GetBatVoltLowPwr() const { return fBatVoltLowPwr; } |
uci1 | 8:95a325df1f6b | 169 | uint16_t GetVoltCheckPeriod() const { return fVoltCheckPeriod; } |
uci1 | 3:24c5f0f50bf1 | 170 | uint32_t GetWatchdogPeriod() const { return fWatchDogPeriod; } |
uci1 | 3:24c5f0f50bf1 | 171 | uint16_t GetDac(const uint8_t ch, const uint8_t dn) const { return fDAC[ch][dn]; } |
uci1 | 3:24c5f0f50bf1 | 172 | uint8_t GetNumPlas() const { return fNumPlas; } |
uci1 | 3:24c5f0f50bf1 | 173 | uint16_t GetPla(const uint8_t pn) const { return fPLA[pn]; } |
uci1 | 3:24c5f0f50bf1 | 174 | uint8_t GetNumCardsMajLog() const { return fNumCardsMajLog; } |
uci1 | 3:24c5f0f50bf1 | 175 | bool IsThermTrigEnabled() const { return fEnableThermTrig!=0; } |
uci1 | 3:24c5f0f50bf1 | 176 | bool IsEachAmpOn() const { |
uci1 | 3:24c5f0f50bf1 | 177 | bool allon=true; |
uci1 | 3:24c5f0f50bf1 | 178 | for (uint8_t i=0; (i<kNchans) && allon; i++) { |
uci1 | 3:24c5f0f50bf1 | 179 | allon = (fAmpsOn & BIT(i))!=0; |
uci1 | 3:24c5f0f50bf1 | 180 | } |
uci1 | 3:24c5f0f50bf1 | 181 | return allon; |
uci1 | 3:24c5f0f50bf1 | 182 | } |
uci1 | 3:24c5f0f50bf1 | 183 | // TODO: allow check for individual amps, when they can be turned on individually |
uci1 | 3:24c5f0f50bf1 | 184 | |
uci1 | 8:95a325df1f6b | 185 | const char* GetRemoteServer() const { return fRemoteServer; } |
uci1 | 8:95a325df1f6b | 186 | uint16_t GetRemotePort() const { return fRemotePort; } |
uci1 | 8:95a325df1f6b | 187 | const char* GetMbedIP() const { return fMbedIP; } |
uci1 | 8:95a325df1f6b | 188 | const char* GetMbedMask() const { return fMbedMask; } |
uci1 | 8:95a325df1f6b | 189 | const char* GetMbedGate() const { return fMbedGate; } |
uci1 | 8:95a325df1f6b | 190 | uint32_t GetCommWinPeriod() const { return fIsLowPower ? fCommWinPrdLowPwr : fCommWinPeriod; } |
uci1 | 8:95a325df1f6b | 191 | uint32_t GetCommWinDuration() const { return fIsLowPower ? fCommWinDurLowPwr : fCommWinDuration; } |
uci1 | 3:24c5f0f50bf1 | 192 | int16_t GetCommSendData() const { return fCommSendData; } |
uci1 | 3:24c5f0f50bf1 | 193 | |
uci1 | 3:24c5f0f50bf1 | 194 | bool IsSendingAllFiles() const |
uci1 | 3:24c5f0f50bf1 | 195 | { return (fCommSendData<0) && ((fCommSendData & kAllFiles)!=0); } |
uci1 | 3:24c5f0f50bf1 | 196 | bool IsObeyingTimeout() const |
uci1 | 3:24c5f0f50bf1 | 197 | { return (fCommSendData<0) && ((fCommSendData & kTimeout)!=0); } |
uci1 | 3:24c5f0f50bf1 | 198 | bool IsDeletingFiles() const |
uci1 | 3:24c5f0f50bf1 | 199 | { return (fCommSendData<0) && ((fCommSendData & kDelete)!=0); } |
uci1 | 15:f2569d8e4176 | 200 | bool IsForcingSBDdata() const |
uci1 | 15:f2569d8e4176 | 201 | { return (fCommSendData<0) && ((fCommSendData & kForceSBDdata)!=0); } |
uci1 | 3:24c5f0f50bf1 | 202 | |
uci1 | 4:a91682e19d6b | 203 | uint8_t GetPowerMode() const { return fPowerMode; } |
uci1 | 8:95a325df1f6b | 204 | int GetPowPinSetting(const EPowerModeBit p) const { |
uci1 | 8:95a325df1f6b | 205 | // return int to correspond to what DigitalOut::operator= expects |
uci1 | 8:95a325df1f6b | 206 | const bool on = IsPoweredFor(p); |
uci1 | 5:9cea89700c66 | 207 | if (p==kCardDatTak || p==kCardComWin || |
uci1 | 5:9cea89700c66 | 208 | p==kAmpsDatTak || p==kAmpsComWin) { |
uci1 | 5:9cea89700c66 | 209 | return on ? 0 : 1; |
uci1 | 5:9cea89700c66 | 210 | } else { |
uci1 | 5:9cea89700c66 | 211 | return on ? 1 : 0; |
uci1 | 5:9cea89700c66 | 212 | } |
uci1 | 5:9cea89700c66 | 213 | } |
uci1 | 8:95a325df1f6b | 214 | bool IsPoweredFor(const EPowerModeBit p) const { |
uci1 | 8:95a325df1f6b | 215 | return ((fPowerMode & p)!=0); |
uci1 | 8:95a325df1f6b | 216 | } |
uci1 | 8:95a325df1f6b | 217 | |
uci1 | 8:95a325df1f6b | 218 | void EnablePowerFor(const EPowerModeBit p) { fPowerMode |= p; } |
uci1 | 8:95a325df1f6b | 219 | void DisablePowerFor(const EPowerModeBit p) { fPowerMode &= ~p; } |
uci1 | 8:95a325df1f6b | 220 | |
uci1 | 8:95a325df1f6b | 221 | void ChangeToLowPower(); |
uci1 | 8:95a325df1f6b | 222 | void ChangeToNormPower(); |
uci1 | 3:24c5f0f50bf1 | 223 | |
uci1 | 3:24c5f0f50bf1 | 224 | const char* GetOutFileName(const char* dir) const; |
uci1 | 3:24c5f0f50bf1 | 225 | |
uci1 | 3:24c5f0f50bf1 | 226 | // waveform packing info |
uci1 | 3:24c5f0f50bf1 | 227 | uint16_t GetWvBaseline() const { return fWvBaseline; } |
uci1 | 3:24c5f0f50bf1 | 228 | uint8_t GetWvLoseLSB() const { return fWvLoseLSB; } |
uci1 | 3:24c5f0f50bf1 | 229 | uint8_t GetWvLoseMSB() const { return fWvLoseMSB; } |
uci1 | 3:24c5f0f50bf1 | 230 | bool IsDatPackedFor(const EDatPackBit d) const { return (fDatPackType & d)!=0; } |
uci1 | 3:24c5f0f50bf1 | 231 | void GetPackParsFor(const EDatPackBit d, |
uci1 | 3:24c5f0f50bf1 | 232 | uint8_t& loseLSB, uint8_t& loseMSB, |
uci1 | 3:24c5f0f50bf1 | 233 | uint16_t& wvBase) const; |
uci1 | 3:24c5f0f50bf1 | 234 | |
uci1 | 3:24c5f0f50bf1 | 235 | // i/o |
uci1 | 3:24c5f0f50bf1 | 236 | template<class T> |
uci1 | 3:24c5f0f50bf1 | 237 | void ReadFrom(T& b) { |
uci1 | 3:24c5f0f50bf1 | 238 | // no check on the length of buf is done here |
uci1 | 3:24c5f0f50bf1 | 239 | // that should be been done already |
uci1 | 3:24c5f0f50bf1 | 240 | // |
uci1 | 3:24c5f0f50bf1 | 241 | // must match WriteTo |
uci1 | 3:24c5f0f50bf1 | 242 | |
uci1 | 3:24c5f0f50bf1 | 243 | uint8_t Rv=0; |
uci1 | 3:24c5f0f50bf1 | 244 | b = SnBitUtils::ReadFrom(b, Rv); // i/o version |
uci1 | 12:d472f9811262 | 245 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 246 | printf("Rv=%hhu\r\n",Rv); |
uci1 | 12:d472f9811262 | 247 | #endif |
uci1 | 3:24c5f0f50bf1 | 248 | if (Rv>0) { |
uci1 | 3:24c5f0f50bf1 | 249 | uint32_t llen=kConfLblLen; |
uci1 | 3:24c5f0f50bf1 | 250 | b = SnBitUtils::ReadFrom(b, llen); |
uci1 | 12:d472f9811262 | 251 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 252 | printf("llen=%u\r\n",llen); |
uci1 | 12:d472f9811262 | 253 | #endif |
uci1 | 3:24c5f0f50bf1 | 254 | b = SnBitUtils::ReadFrom(b, fLabel, llen); |
uci1 | 12:d472f9811262 | 255 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 256 | printf("lbl=%s\r\n",fLabel); |
uci1 | 12:d472f9811262 | 257 | #endif |
uci1 | 3:24c5f0f50bf1 | 258 | b = SnBitUtils::ReadFrom(b, fConfTime); |
uci1 | 12:d472f9811262 | 259 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 260 | printf("ct=%u\r\n",fConfTime); |
uci1 | 12:d472f9811262 | 261 | #endif |
uci1 | 3:24c5f0f50bf1 | 262 | b = SnBitUtils::ReadFrom(b, fRun); |
uci1 | 12:d472f9811262 | 263 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 264 | printf("run=%u\r\n",fRun); |
uci1 | 12:d472f9811262 | 265 | #endif |
uci1 | 3:24c5f0f50bf1 | 266 | b = SnBitUtils::ReadFrom(b, fFirstEvt); |
uci1 | 12:d472f9811262 | 267 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 268 | printf("fe=%u\r\n",fFirstEvt); |
uci1 | 12:d472f9811262 | 269 | #endif |
uci1 | 3:24c5f0f50bf1 | 270 | if (Rv>1) { |
uci1 | 3:24c5f0f50bf1 | 271 | b = SnBitUtils::ReadFrom(b, fEvtsPerSeq); |
uci1 | 12:d472f9811262 | 272 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 273 | printf("eps=%u\r\n",fEvtsPerSeq); |
uci1 | 12:d472f9811262 | 274 | #endif |
uci1 | 3:24c5f0f50bf1 | 275 | b = SnBitUtils::ReadFrom(b, fRunMode); |
uci1 | 12:d472f9811262 | 276 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 277 | printf("rm=%hhu\r\n",fRunMode); |
uci1 | 12:d472f9811262 | 278 | #endif |
uci1 | 3:24c5f0f50bf1 | 279 | } |
uci1 | 3:24c5f0f50bf1 | 280 | b = SnBitUtils::ReadFrom(b, fStreamHiLoPlas); |
uci1 | 12:d472f9811262 | 281 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 282 | printf("shilo=%d\r\n",(int)fStreamHiLoPlas); |
uci1 | 12:d472f9811262 | 283 | #endif |
uci1 | 3:24c5f0f50bf1 | 284 | b = SnBitUtils::ReadFrom(b, fWvLoseLSB); |
uci1 | 12:d472f9811262 | 285 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 286 | printf("lsb=%hhu\r\n",fWvLoseLSB); |
uci1 | 12:d472f9811262 | 287 | #endif |
uci1 | 3:24c5f0f50bf1 | 288 | b = SnBitUtils::ReadFrom(b, fWvLoseMSB); |
uci1 | 12:d472f9811262 | 289 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 290 | printf("msb=%hhu\r\n",fWvLoseMSB); |
uci1 | 12:d472f9811262 | 291 | #endif |
uci1 | 3:24c5f0f50bf1 | 292 | b = SnBitUtils::ReadFrom(b, fWvBaseline); |
uci1 | 12:d472f9811262 | 293 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 294 | printf("bl=%hu\r\n",fWvBaseline); |
uci1 | 12:d472f9811262 | 295 | #endif |
uci1 | 3:24c5f0f50bf1 | 296 | b = SnBitUtils::ReadFrom(b, fDatPackType); |
uci1 | 12:d472f9811262 | 297 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 298 | printf("dp=%hhu\r\n",fDatPackType); |
uci1 | 12:d472f9811262 | 299 | #endif |
uci1 | 3:24c5f0f50bf1 | 300 | uint16_t* dc = &(fDAC[0][0]); |
uci1 | 3:24c5f0f50bf1 | 301 | for (uint16_t i=0; i<kTotDacs; i++, dc++) { |
uci1 | 3:24c5f0f50bf1 | 302 | b = SnBitUtils::ReadFrom(b, *dc); |
uci1 | 12:d472f9811262 | 303 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 304 | printf("dac[%hu]=%hu\r\n",i,*dc); |
uci1 | 12:d472f9811262 | 305 | #endif |
uci1 | 3:24c5f0f50bf1 | 306 | } |
uci1 | 3:24c5f0f50bf1 | 307 | b = SnBitUtils::ReadFrom(b, fNumPlas); |
uci1 | 12:d472f9811262 | 308 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 309 | printf("npla=%hhu\r\n",fNumPlas); |
uci1 | 12:d472f9811262 | 310 | #endif |
uci1 | 3:24c5f0f50bf1 | 311 | uint16_t* pl = &(fPLA[0]); |
uci1 | 3:24c5f0f50bf1 | 312 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 3:24c5f0f50bf1 | 313 | b = SnBitUtils::ReadFrom(b, *pl); |
uci1 | 12:d472f9811262 | 314 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 315 | printf("pla[%hhu]=%hu\r\n",j,*pl); |
uci1 | 12:d472f9811262 | 316 | #endif |
uci1 | 3:24c5f0f50bf1 | 317 | } |
uci1 | 3:24c5f0f50bf1 | 318 | b = SnBitUtils::ReadFrom(b, fNumCardsMajLog); |
uci1 | 12:d472f9811262 | 319 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 320 | printf("mj=%hhu\r\n",fNumCardsMajLog); |
uci1 | 12:d472f9811262 | 321 | #endif |
uci1 | 3:24c5f0f50bf1 | 322 | b = SnBitUtils::ReadFrom(b, fEnableThermTrig); |
uci1 | 12:d472f9811262 | 323 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 324 | printf("thm=%d\r\n",(int)fEnableThermTrig); |
uci1 | 12:d472f9811262 | 325 | #endif |
uci1 | 18:55f1581f2ee4 | 326 | if (Rv>3) { |
uci1 | 18:55f1581f2ee4 | 327 | b = SnBitUtils::ReadFrom(b, fForceTrigPeriod); |
uci1 | 18:55f1581f2ee4 | 328 | } else { |
uci1 | 18:55f1581f2ee4 | 329 | uint16_t ftrg(0); |
uci1 | 18:55f1581f2ee4 | 330 | b = SnBitUtils::ReadFrom(b, ftrg); |
uci1 | 18:55f1581f2ee4 | 331 | fForceTrigPeriod = ftrg; |
uci1 | 18:55f1581f2ee4 | 332 | } |
uci1 | 12:d472f9811262 | 333 | #ifdef DEBUG |
uci1 | 18:55f1581f2ee4 | 334 | printf("force=%g\r\n",fForceTrigPeriod); |
uci1 | 12:d472f9811262 | 335 | #endif |
uci1 | 3:24c5f0f50bf1 | 336 | b = SnBitUtils::ReadFrom(b, fHeartBeatPeriod); |
uci1 | 12:d472f9811262 | 337 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 338 | printf("heart=%hu\r\n",fHeartBeatPeriod); |
uci1 | 12:d472f9811262 | 339 | #endif |
uci1 | 3:24c5f0f50bf1 | 340 | b = SnBitUtils::ReadFrom(b, fAmpsOn); |
uci1 | 12:d472f9811262 | 341 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 342 | printf("amps=%hhu\r\n",fAmpsOn); |
uci1 | 12:d472f9811262 | 343 | #endif |
uci1 | 3:24c5f0f50bf1 | 344 | b = SnBitUtils::ReadFrom(b, fEvtThrtlPeriodMs); |
uci1 | 12:d472f9811262 | 345 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 346 | printf("throt=%hu\r\n",fEvtThrtlPeriodMs); |
uci1 | 12:d472f9811262 | 347 | #endif |
uci1 | 3:24c5f0f50bf1 | 348 | b = SnBitUtils::ReadFrom(b, fPowerMode); |
uci1 | 12:d472f9811262 | 349 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 350 | printf("pow=%hhu\r\n",fPowerMode); |
uci1 | 12:d472f9811262 | 351 | #endif |
uci1 | 3:24c5f0f50bf1 | 352 | b = SnBitUtils::ReadFrom(b, fBatVoltLowPwr); |
uci1 | 12:d472f9811262 | 353 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 354 | printf("batlow=%hd\r\n",fBatVoltLowPwr); |
uci1 | 12:d472f9811262 | 355 | #endif |
uci1 | 8:95a325df1f6b | 356 | if (Rv>2) { |
uci1 | 8:95a325df1f6b | 357 | b = SnBitUtils::ReadFrom(b, fVoltCheckPeriod); |
uci1 | 12:d472f9811262 | 358 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 359 | printf("vltchk=%hu\r\n",fVoltCheckPeriod); |
uci1 | 12:d472f9811262 | 360 | #endif |
uci1 | 8:95a325df1f6b | 361 | } |
uci1 | 3:24c5f0f50bf1 | 362 | b = SnBitUtils::ReadFrom(b, fCommWinPeriod); |
uci1 | 12:d472f9811262 | 363 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 364 | printf("cmper=%u\r\n",fCommWinPeriod); |
uci1 | 12:d472f9811262 | 365 | #endif |
uci1 | 3:24c5f0f50bf1 | 366 | b = SnBitUtils::ReadFrom(b, fCommWinDuration); |
uci1 | 12:d472f9811262 | 367 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 368 | printf("cmdur=%u\r\n",fCommWinDuration); |
uci1 | 12:d472f9811262 | 369 | #endif |
uci1 | 3:24c5f0f50bf1 | 370 | b = SnBitUtils::ReadFrom(b, fCommSendData); |
uci1 | 12:d472f9811262 | 371 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 372 | printf("send=%d\r\n",fCommSendData); |
uci1 | 12:d472f9811262 | 373 | #endif |
uci1 | 3:24c5f0f50bf1 | 374 | b = SnBitUtils::ReadFrom(b, fCommWinPrdLowPwr); |
uci1 | 12:d472f9811262 | 375 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 376 | printf("cmperlp=%u\r\n",fCommWinPrdLowPwr); |
uci1 | 12:d472f9811262 | 377 | #endif |
uci1 | 3:24c5f0f50bf1 | 378 | b = SnBitUtils::ReadFrom(b, fCommWinDurLowPwr); |
uci1 | 12:d472f9811262 | 379 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 380 | printf("cmdurlp=%u\r\n",fCommWinDurLowPwr); |
uci1 | 12:d472f9811262 | 381 | #endif |
uci1 | 8:95a325df1f6b | 382 | if (Rv>2) { |
uci1 | 8:95a325df1f6b | 383 | b = SnBitUtils::ReadFrom(b, fRemoteServer, kIPLen); |
uci1 | 12:d472f9811262 | 384 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 385 | printf("rserv=%s\r\n",fRemoteServer); |
uci1 | 12:d472f9811262 | 386 | #endif |
uci1 | 8:95a325df1f6b | 387 | b = SnBitUtils::ReadFrom(b, fRemotePort); |
uci1 | 12:d472f9811262 | 388 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 389 | printf("rport=%hu\r\n",fRemotePort); |
uci1 | 12:d472f9811262 | 390 | #endif |
uci1 | 8:95a325df1f6b | 391 | b = SnBitUtils::ReadFrom(b, fMbedIP, kIPLen); |
uci1 | 12:d472f9811262 | 392 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 393 | printf("mbedip=%s\r\n",fMbedIP); |
uci1 | 12:d472f9811262 | 394 | #endif |
uci1 | 8:95a325df1f6b | 395 | b = SnBitUtils::ReadFrom(b, fMbedMask, kIPLen); |
uci1 | 12:d472f9811262 | 396 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 397 | printf("mbedmask=%s\r\n",fMbedMask); |
uci1 | 12:d472f9811262 | 398 | #endif |
uci1 | 8:95a325df1f6b | 399 | b = SnBitUtils::ReadFrom(b, fMbedGate, kIPLen); |
uci1 | 12:d472f9811262 | 400 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 401 | printf("mbedgate=%s\r\n",fMbedGate); |
uci1 | 12:d472f9811262 | 402 | #endif |
uci1 | 8:95a325df1f6b | 403 | } |
uci1 | 3:24c5f0f50bf1 | 404 | b = SnBitUtils::ReadFrom(b, fWatchDogPeriod); |
uci1 | 12:d472f9811262 | 405 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 406 | printf("watch=%u\r\n",fWatchDogPeriod); |
uci1 | 12:d472f9811262 | 407 | #endif |
uci1 | 3:24c5f0f50bf1 | 408 | if (fStreamHiLoPlas!=0) { |
uci1 | 3:24c5f0f50bf1 | 409 | uint16_t hi, lo; |
uci1 | 3:24c5f0f50bf1 | 410 | for (uint8_t j=0; j<fNumPlas; j++) { |
uci1 | 3:24c5f0f50bf1 | 411 | b = SnBitUtils::ReadFrom(b, hi); |
uci1 | 12:d472f9811262 | 412 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 413 | printf("hi=%hu\r\n",hi); |
uci1 | 12:d472f9811262 | 414 | #endif |
uci1 | 3:24c5f0f50bf1 | 415 | b = SnBitUtils::ReadFrom(b, lo); |
uci1 | 12:d472f9811262 | 416 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 417 | printf("lo=%hu\r\n",lo); |
uci1 | 12:d472f9811262 | 418 | #endif |
uci1 | 3:24c5f0f50bf1 | 419 | // don't save these |
uci1 | 3:24c5f0f50bf1 | 420 | } |
uci1 | 3:24c5f0f50bf1 | 421 | } |
uci1 | 3:24c5f0f50bf1 | 422 | } |
uci1 | 12:d472f9811262 | 423 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 424 | printf("read from done\r\n"); |
uci1 | 12:d472f9811262 | 425 | #endif |
uci1 | 3:24c5f0f50bf1 | 426 | } |
uci1 | 3:24c5f0f50bf1 | 427 | |
uci1 | 3:24c5f0f50bf1 | 428 | template <class T> |
uci1 | 3:24c5f0f50bf1 | 429 | void WriteTo(T& b) const { |
uci1 | 3:24c5f0f50bf1 | 430 | // no check on the length of the buf is done here |
uci1 | 3:24c5f0f50bf1 | 431 | // that should be done already |
uci1 | 3:24c5f0f50bf1 | 432 | // |
uci1 | 3:24c5f0f50bf1 | 433 | // must match ReadFromBuf |
uci1 | 3:24c5f0f50bf1 | 434 | // |
uci1 | 3:24c5f0f50bf1 | 435 | // intentionally not writing mac address here, so we don't have to read it in |
uci1 | 3:24c5f0f50bf1 | 436 | |
uci1 | 3:24c5f0f50bf1 | 437 | const uint32_t llen = strlen(fLabel); |
uci1 | 3:24c5f0f50bf1 | 438 | b = SnBitUtils::WriteTo(b, kIOVers); // i/o version |
uci1 | 3:24c5f0f50bf1 | 439 | b = SnBitUtils::WriteTo(b, llen); |
uci1 | 3:24c5f0f50bf1 | 440 | b = SnBitUtils::WriteTo(b, fLabel, llen); |
uci1 | 3:24c5f0f50bf1 | 441 | b = SnBitUtils::WriteTo(b, fConfTime); |
uci1 | 3:24c5f0f50bf1 | 442 | b = SnBitUtils::WriteTo(b, fRun); |
uci1 | 3:24c5f0f50bf1 | 443 | b = SnBitUtils::WriteTo(b, fFirstEvt); |
uci1 | 3:24c5f0f50bf1 | 444 | b = SnBitUtils::WriteTo(b, fEvtsPerSeq); |
uci1 | 3:24c5f0f50bf1 | 445 | b = SnBitUtils::WriteTo(b, fRunMode); |
uci1 | 3:24c5f0f50bf1 | 446 | b = SnBitUtils::WriteTo(b, fStreamHiLoPlas); |
uci1 | 3:24c5f0f50bf1 | 447 | b = SnBitUtils::WriteTo(b, fWvLoseLSB); |
uci1 | 3:24c5f0f50bf1 | 448 | b = SnBitUtils::WriteTo(b, fWvLoseMSB); |
uci1 | 3:24c5f0f50bf1 | 449 | b = SnBitUtils::WriteTo(b, fWvBaseline); |
uci1 | 3:24c5f0f50bf1 | 450 | b = SnBitUtils::WriteTo(b, fDatPackType); |
uci1 | 3:24c5f0f50bf1 | 451 | const uint16_t* dc = &(fDAC[0][0]); |
uci1 | 3:24c5f0f50bf1 | 452 | for (uint16_t i=0; i<kTotDacs; i++, dc++) { |
uci1 | 3:24c5f0f50bf1 | 453 | b = SnBitUtils::WriteTo(b, *dc); |
uci1 | 3:24c5f0f50bf1 | 454 | } |
uci1 | 3:24c5f0f50bf1 | 455 | b = SnBitUtils::WriteTo(b, fNumPlas); |
uci1 | 3:24c5f0f50bf1 | 456 | const uint16_t* pl = &(fPLA[0]); |
uci1 | 3:24c5f0f50bf1 | 457 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 3:24c5f0f50bf1 | 458 | b = SnBitUtils::WriteTo(b, *pl); |
uci1 | 3:24c5f0f50bf1 | 459 | } |
uci1 | 3:24c5f0f50bf1 | 460 | b = SnBitUtils::WriteTo(b, fNumCardsMajLog); |
uci1 | 3:24c5f0f50bf1 | 461 | b = SnBitUtils::WriteTo(b, fEnableThermTrig); |
uci1 | 3:24c5f0f50bf1 | 462 | b = SnBitUtils::WriteTo(b, fForceTrigPeriod); |
uci1 | 3:24c5f0f50bf1 | 463 | b = SnBitUtils::WriteTo(b, fHeartBeatPeriod); |
uci1 | 3:24c5f0f50bf1 | 464 | b = SnBitUtils::WriteTo(b, fAmpsOn); |
uci1 | 3:24c5f0f50bf1 | 465 | b = SnBitUtils::WriteTo(b, fEvtThrtlPeriodMs); |
uci1 | 3:24c5f0f50bf1 | 466 | b = SnBitUtils::WriteTo(b, fPowerMode); |
uci1 | 3:24c5f0f50bf1 | 467 | b = SnBitUtils::WriteTo(b, fBatVoltLowPwr); |
uci1 | 8:95a325df1f6b | 468 | b = SnBitUtils::WriteTo(b, fVoltCheckPeriod); |
uci1 | 3:24c5f0f50bf1 | 469 | b = SnBitUtils::WriteTo(b, fCommWinPeriod); |
uci1 | 3:24c5f0f50bf1 | 470 | b = SnBitUtils::WriteTo(b, fCommWinDuration); |
uci1 | 3:24c5f0f50bf1 | 471 | b = SnBitUtils::WriteTo(b, fCommSendData); |
uci1 | 3:24c5f0f50bf1 | 472 | b = SnBitUtils::WriteTo(b, fCommWinPrdLowPwr); |
uci1 | 3:24c5f0f50bf1 | 473 | b = SnBitUtils::WriteTo(b, fCommWinDurLowPwr); |
uci1 | 8:95a325df1f6b | 474 | b = SnBitUtils::WriteTo(b, fRemoteServer, kIPLen); |
uci1 | 8:95a325df1f6b | 475 | b = SnBitUtils::WriteTo(b, fRemotePort); |
uci1 | 8:95a325df1f6b | 476 | b = SnBitUtils::WriteTo(b, fMbedIP, kIPLen); |
uci1 | 8:95a325df1f6b | 477 | b = SnBitUtils::WriteTo(b, fMbedMask, kIPLen); |
uci1 | 8:95a325df1f6b | 478 | b = SnBitUtils::WriteTo(b, fMbedGate, kIPLen); |
uci1 | 3:24c5f0f50bf1 | 479 | b = SnBitUtils::WriteTo(b, fWatchDogPeriod); |
uci1 | 3:24c5f0f50bf1 | 480 | if (fStreamHiLoPlas!=0) { |
uci1 | 3:24c5f0f50bf1 | 481 | pl = fPLA; |
uci1 | 3:24c5f0f50bf1 | 482 | uint16_t hi, lo; |
uci1 | 3:24c5f0f50bf1 | 483 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 3:24c5f0f50bf1 | 484 | GetHiLoPlas(*pl, hi, lo); |
uci1 | 3:24c5f0f50bf1 | 485 | b = SnBitUtils::WriteTo(b, hi); |
uci1 | 3:24c5f0f50bf1 | 486 | b = SnBitUtils::WriteTo(b, lo); |
uci1 | 3:24c5f0f50bf1 | 487 | } |
uci1 | 3:24c5f0f50bf1 | 488 | } |
uci1 | 3:24c5f0f50bf1 | 489 | } |
uci1 | 3:24c5f0f50bf1 | 490 | |
uci1 | 3:24c5f0f50bf1 | 491 | bool ReadFromFile(const char* cfile); |
uci1 | 3:24c5f0f50bf1 | 492 | bool WriteToFile(const char* cfile) const; |
uci1 | 3:24c5f0f50bf1 | 493 | |
uci1 | 3:24c5f0f50bf1 | 494 | void Reset() { |
uci1 | 3:24c5f0f50bf1 | 495 | memset(fLabel, 0, sizeof(char)*kConfLblLen); |
uci1 | 3:24c5f0f50bf1 | 496 | if (ReadFromFile(kDefConfFile)==false) { |
uci1 | 3:24c5f0f50bf1 | 497 | // couldn't get default. use hardcoded version. |
uci1 | 3:24c5f0f50bf1 | 498 | SetHardDefaults(); |
uci1 | 3:24c5f0f50bf1 | 499 | } |
uci1 | 16:744ce85aede2 | 500 | #ifdef DEBUG |
uci1 | 16:744ce85aede2 | 501 | printf("config reset to %s\r\n",fLabel); |
uci1 | 16:744ce85aede2 | 502 | #endif |
uci1 | 3:24c5f0f50bf1 | 503 | } |
uci1 | 3:24c5f0f50bf1 | 504 | |
uci1 | 8:95a325df1f6b | 505 | uint32_t SizeOf(const uint8_t rv) const { |
uci1 | 3:24c5f0f50bf1 | 506 | // returns the num of bytes needed to stream this object |
uci1 | 3:24c5f0f50bf1 | 507 | // = size of member vars + 1 for i/o version + extra PLA strings (maybe) |
uci1 | 3:24c5f0f50bf1 | 508 | // + length of label string |
uci1 | 8:95a325df1f6b | 509 | return SizeOf(rv, fStreamHiLoPlas!=0, fNumPlas, strlen(fLabel)); |
uci1 | 3:24c5f0f50bf1 | 510 | } |
uci1 | 3:24c5f0f50bf1 | 511 | |
uci1 | 3:24c5f0f50bf1 | 512 | static void SetMacAddress(); |
uci1 | 3:24c5f0f50bf1 | 513 | static uint64_t GetMacAddress() { |
uci1 | 3:24c5f0f50bf1 | 514 | if (fgMacAdr==0) { |
uci1 | 3:24c5f0f50bf1 | 515 | SetMacAddress(); |
uci1 | 3:24c5f0f50bf1 | 516 | } |
uci1 | 3:24c5f0f50bf1 | 517 | return fgMacAdr; |
uci1 | 3:24c5f0f50bf1 | 518 | } |
uci1 | 3:24c5f0f50bf1 | 519 | |
uci1 | 3:24c5f0f50bf1 | 520 | static uint32_t GetLabelMaxLen() { return kConfLblLen; } |
uci1 | 3:24c5f0f50bf1 | 521 | |
uci1 | 3:24c5f0f50bf1 | 522 | static void GetHiLoPlas(const uint16_t pla, |
uci1 | 3:24c5f0f50bf1 | 523 | uint16_t& hiPla, |
uci1 | 3:24c5f0f50bf1 | 524 | uint16_t& loPla, |
uci1 | 3:24c5f0f50bf1 | 525 | const bool r2l=false); |
uci1 | 3:24c5f0f50bf1 | 526 | }; |
uci1 | 3:24c5f0f50bf1 | 527 | |
uci1 | 3:24c5f0f50bf1 | 528 | #endif // SN_SnConfigFrame |