Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnConfigFrame.h@59:21128cc24b04, 2014-10-31 (annotated)
- Committer:
- uci1
- Date:
- Fri Oct 31 23:33:31 2014 +0000
- Revision:
- 59:21128cc24b04
- Parent:
- 56:0bba0ef15697
- Child:
- 67:ec999336fcd1
Enable safety nets. Allow IP setting via text files on mbed.
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 | 31:b5bd3b189150 | 12 | static bool fgApplySafetyNets; // whether to apply safety bounds on certain parameters in ReadFrom (default: true) |
uci1 | 31:b5bd3b189150 | 13 | |
uci1 | 3:24c5f0f50bf1 | 14 | static const uint32_t kMinCommWinPrdLowPwr; // exclusive min low power comm win period (s) |
uci1 | 3:24c5f0f50bf1 | 15 | static const uint32_t kMaxCommWinPrdLowPwr; // exclusive max low power comm win period (s) |
uci1 | 3:24c5f0f50bf1 | 16 | static const uint32_t kMinCommWinDurLowPwr; // exclusive min low power comm win duration (s) |
uci1 | 3:24c5f0f50bf1 | 17 | static const uint32_t kMaxCommWinDurLowPwr; // exclusive max low power comm win duration (s) |
uci1 | 56:0bba0ef15697 | 18 | static const uint8_t kConfLblLen=64; // length of configuration label char array (63+'\0') (must not change!! used in i/o sizes) |
uci1 | 56:0bba0ef15697 | 19 | static const uint8_t kIPLen=16; // length of IP string. matches MBED's Socket class (so no ipv6) (must not change!! used in i/o sizes) |
uci1 | 3:24c5f0f50bf1 | 20 | |
uci1 | 3:24c5f0f50bf1 | 21 | static const char* const kDefConfFile; // default configuration file |
uci1 | 59:21128cc24b04 | 22 | static const char* const kDefRemIpFilen; |
uci1 | 59:21128cc24b04 | 23 | static const char* const kDefRemPortFilen; |
uci1 | 59:21128cc24b04 | 24 | static const char* const kDefMbedIPFilen; |
uci1 | 59:21128cc24b04 | 25 | static const char* const kDefMbedMaskFilen; |
uci1 | 59:21128cc24b04 | 26 | static const char* const kDefMbedGateFilen; |
uci1 | 28:484943132bb0 | 27 | static const char* const kDefIPflag; // flag to use IP default |
uci1 | 3:24c5f0f50bf1 | 28 | |
uci1 | 56:0bba0ef15697 | 29 | // ATWD 4channel configs |
uci1 | 8:95a325df1f6b | 30 | static const uint32_t kMaxSizeOfV1 = |
uci1 | 8:95a325df1f6b | 31 | + (9u*sizeof(uint32_t)) + (6u*sizeof(uint16_t)) |
uci1 | 56:0bba0ef15697 | 32 | + (10u*sizeof(uint8_t)) + (3u*kNplasV1*sizeof(uint16_t)) // 3*Nplas because if StreamHiLo is set, will stream 3 values (composite, high side, low side) |
uci1 | 56:0bba0ef15697 | 33 | + (kTotDacsAtwd4ch*sizeof(uint16_t)) |
uci1 | 3:24c5f0f50bf1 | 34 | + (kConfLblLen*sizeof(uint8_t)); |
uci1 | 8:95a325df1f6b | 35 | static const uint32_t kMaxSizeOfV2 = |
uci1 | 8:95a325df1f6b | 36 | kMaxSizeOfV1 + sizeof(uint32_t) + sizeof(uint8_t); |
uci1 | 8:95a325df1f6b | 37 | static const uint32_t kMaxSizeOfV3 = |
uci1 | 8:95a325df1f6b | 38 | kMaxSizeOfV2 + (2u*sizeof(uint16_t)) + (4u*kIPLen*sizeof(char)); |
uci1 | 40:1324da35afd4 | 39 | static const uint32_t kMaxSizeOfV4 = kMaxSizeOfV3 + (sizeof(float)-sizeof(uint16_t)); // forced trig per to float |
uci1 | 39:2f17131d22a5 | 40 | static const uint32_t kMaxSizeOfV5 = kMaxSizeOfV4; |
uci1 | 40:1324da35afd4 | 41 | static const uint32_t kMaxSizeOfV6 = kMaxSizeOfV5 + sizeof(uint16_t); // To/From Low Power |
uci1 | 40:1324da35afd4 | 42 | static const uint32_t kMaxSizeOfV7 = kMaxSizeOfV6 + (2u*sizeof(uint8_t)); // add ConnTOmins, ListenTOmins |
uci1 | 40:1324da35afd4 | 43 | static const uint32_t kMaxSizeOfV8 = kMaxSizeOfV7 - sizeof(uint32_t) + sizeof(uint16_t); // FirstEvt -> FirstSeq |
uci1 | 56:0bba0ef15697 | 44 | |
uci1 | 56:0bba0ef15697 | 45 | // SST 4channel configs |
uci1 | 56:0bba0ef15697 | 46 | static const uint32_t kMaxSizeOfV9 = kMaxSizeOfV8 |
uci1 | 56:0bba0ef15697 | 47 | - (3u*kNplasV1*sizeof(uint16_t)) // no patterns in SST |
uci1 | 56:0bba0ef15697 | 48 | - (kTotDacsAtwd4ch*sizeof(uint16_t)) |
uci1 | 56:0bba0ef15697 | 49 | + (kTotDacsSst4ch*sizeof(uint16_t)) // switch to number of SST dacs |
uci1 | 56:0bba0ef15697 | 50 | - sizeof(uint8_t) // no stream hi/lo pla flag |
uci1 | 56:0bba0ef15697 | 51 | - sizeof(uint8_t); // no num plas variable |
uci1 | 56:0bba0ef15697 | 52 | static const uint32_t kMaxSizeOfV10 = kMaxSizeOfV9 + sizeof(int8_t); // add fTempCheckPeriod |
uci1 | 56:0bba0ef15697 | 53 | |
uci1 | 56:0bba0ef15697 | 54 | static const uint32_t kMaxSizeOf = kMaxSizeOfV7; // should be the biggest one |
uci1 | 3:24c5f0f50bf1 | 55 | |
uci1 | 3:24c5f0f50bf1 | 56 | enum EDatPackBit { |
uci1 | 3:24c5f0f50bf1 | 57 | kSDcard = BIT(0), |
uci1 | 3:24c5f0f50bf1 | 58 | kIrid = BIT(1), |
uci1 | 3:24c5f0f50bf1 | 59 | kAfar = BIT(2), |
uci1 | 3:24c5f0f50bf1 | 60 | kUSB = BIT(3) |
uci1 | 3:24c5f0f50bf1 | 61 | }; |
uci1 | 3:24c5f0f50bf1 | 62 | |
uci1 | 3:24c5f0f50bf1 | 63 | enum ESendDataBit { |
uci1 | 3:24c5f0f50bf1 | 64 | // can't use BIT(0)! (-0 = 0 => send nothing) |
uci1 | 13:7a1fb885a8e4 | 65 | kAllFiles = BIT(1), // if bit=0 => send most recent file |
uci1 | 13:7a1fb885a8e4 | 66 | kTimeout = BIT(2), // if bit=0 => ignore timeout |
uci1 | 13:7a1fb885a8e4 | 67 | kDelete = BIT(3), // if bit=0 => do not delete sent files |
uci1 | 13:7a1fb885a8e4 | 68 | kForceSBDdata = BIT(4), // if bit=0 => do not send data over SBD |
uci1 | 40:1324da35afd4 | 69 | kHnShBefSendDat = BIT(5), // if bit=0 => do not wait for a handshake after GetConfig before calling SendData |
uci1 | 56:0bba0ef15697 | 70 | kSendRunSeqList = BIT(6), // if bit=1 and kAllFiles bit=0, send all files in the run/seq list (instead of most recent file) |
uci1 | 39:2f17131d22a5 | 71 | kUseBits = static_cast<int16_t>(-BIT(14)) // useful to initialize fCommSendData as a bit word |
uci1 | 3:24c5f0f50bf1 | 72 | }; |
uci1 | 3:24c5f0f50bf1 | 73 | |
uci1 | 4:a91682e19d6b | 74 | enum EPowerModeBit { |
uci1 | 4:a91682e19d6b | 75 | kAmpsDatTak = BIT(0), |
uci1 | 4:a91682e19d6b | 76 | kCardDatTak = BIT(1), |
uci1 | 4:a91682e19d6b | 77 | kIridDatTak = BIT(2), |
uci1 | 4:a91682e19d6b | 78 | kAfarDatTak = BIT(3), |
uci1 | 4:a91682e19d6b | 79 | kAmpsComWin = BIT(4), |
uci1 | 4:a91682e19d6b | 80 | kCardComWin = BIT(5), |
uci1 | 4:a91682e19d6b | 81 | kIridComWin = BIT(6), |
uci1 | 4:a91682e19d6b | 82 | kAfarComWin = BIT(7) |
uci1 | 4:a91682e19d6b | 83 | }; |
uci1 | 4:a91682e19d6b | 84 | |
uci1 | 3:24c5f0f50bf1 | 85 | enum ERunMode { |
uci1 | 8:95a325df1f6b | 86 | kSingleSeqBit = BIT(0), // if 0, infinite sequences |
uci1 | 8:95a325df1f6b | 87 | kCountPowerBit = BIT(1), // if 0, count events |
uci1 | 56:0bba0ef15697 | 88 | kDualThreshBit = BIT(2), // if 0, single sided thresholds on SST |
uci1 | 56:0bba0ef15697 | 89 | kDiffTrigBit = BIT(3), // if 0, send result of each comparator on SST |
uci1 | 56:0bba0ef15697 | 90 | kLowPwrSBDonly = BIT(4), // if 0, low power afar/sbd power settings same as normal. if 1, afar off and sbd on during low power mode |
uci1 | 56:0bba0ef15697 | 91 | kRSListOneCW = BIT(5) // if 0, only clear run/seq list after files sent from it |
uci1 | 56:0bba0ef15697 | 92 | }; |
uci1 | 3:24c5f0f50bf1 | 93 | |
uci1 | 3:24c5f0f50bf1 | 94 | // i/o version |
uci1 | 3:24c5f0f50bf1 | 95 | static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes (==> also if kNchans, etc. change!) |
uci1 | 3:24c5f0f50bf1 | 96 | |
uci1 | 3:24c5f0f50bf1 | 97 | private: |
uci1 | 3:24c5f0f50bf1 | 98 | // !! |
uci1 | 3:24c5f0f50bf1 | 99 | // !! If any member variables change, update: SizeOf function and kIOVers value! (also if kNchans, etc. change!) |
uci1 | 3:24c5f0f50bf1 | 100 | // !! |
uci1 | 3:24c5f0f50bf1 | 101 | |
uci1 | 3:24c5f0f50bf1 | 102 | // mbed mac address |
uci1 | 3:24c5f0f50bf1 | 103 | static uint64_t fgMacAdr; // mbed mac address |
uci1 | 3:24c5f0f50bf1 | 104 | // conf header |
uci1 | 3:24c5f0f50bf1 | 105 | char fLabel[kConfLblLen]; // configuration label |
uci1 | 3:24c5f0f50bf1 | 106 | uint32_t fConfTime; // cpu config time |
uci1 | 3:24c5f0f50bf1 | 107 | uint32_t fRun; // run number |
uci1 | 40:1324da35afd4 | 108 | uint16_t fFirstSeq; // starting sequence number |
uci1 | 3:24c5f0f50bf1 | 109 | uint32_t fEvtsPerSeq; // number of events per file |
uci1 | 3:24c5f0f50bf1 | 110 | uint8_t fRunMode; // mode of running (see ERunMode) |
uci1 | 56:0bba0ef15697 | 111 | #if CHIPBOARD==ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 112 | uint8_t fStreamHiLoPlas; // (1byte bool) if true, add the separated hi/lo thresh PLA patterns to the i/o |
uci1 | 56:0bba0ef15697 | 113 | #endif |
uci1 | 3:24c5f0f50bf1 | 114 | // data packing |
uci1 | 3:24c5f0f50bf1 | 115 | uint8_t fWvLoseLSB; // number of least significant bits to lose when packing waveform data |
uci1 | 3:24c5f0f50bf1 | 116 | uint8_t fWvLoseMSB; // number of most significant bits to lose when packing waveform data |
uci1 | 3:24c5f0f50bf1 | 117 | uint16_t fWvBaseline; // global baseline to use when packing data (useful to reduce clipping on the high end) |
uci1 | 3:24c5f0f50bf1 | 118 | 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 | 119 | // trigger setup |
uci1 | 56:0bba0ef15697 | 120 | uint16_t fDAC[kNchans][kNchanDacs]; //[card id][dac id] values should be 0-4095 here (not checked tho) |
uci1 | 56:0bba0ef15697 | 121 | #if CHIPBOARD==ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 122 | uint8_t fNumPlas; // number of patterns to use. must be <= kNplas. |
uci1 | 3:24c5f0f50bf1 | 123 | uint16_t fPLA[kNplas]; //[pattern id] (same for each card) |
uci1 | 56:0bba0ef15697 | 124 | #endif |
uci1 | 3:24c5f0f50bf1 | 125 | uint8_t fNumCardsMajLog; // number of cards participating in the MajLogic trigger (1 to 4) |
uci1 | 3:24c5f0f50bf1 | 126 | uint8_t fEnableThermTrig; // (1byte bool) whether or not to allow thermal triggers |
uci1 | 18:55f1581f2ee4 | 127 | float fForceTrigPeriod; // number of seconds between force triggers (0=none) |
uci1 | 3:24c5f0f50bf1 | 128 | uint16_t fHeartBeatPeriod; // number of seconds between heartbeats (0=none) |
uci1 | 3:24c5f0f50bf1 | 129 | uint8_t fAmpsOn; // which amps are on (bit word. uint8_t => 8 amps max) |
uci1 | 3:24c5f0f50bf1 | 130 | uint16_t fEvtThrtlPeriodMs; // throttle period to write events (ms) |
uci1 | 3:24c5f0f50bf1 | 131 | // power |
uci1 | 4:a91682e19d6b | 132 | uint8_t fPowerMode; // power mode bit word: see EPowerModeBit |
uci1 | 40:1324da35afd4 | 133 | uint16_t fBatVoltToLowPwr; // battery level at which to switch to low power (not used?) |
uci1 | 40:1324da35afd4 | 134 | uint16_t fBatVoltFromLowPwr; // battery level at which to switch back from low power (not used?) |
uci1 | 8:95a325df1f6b | 135 | uint16_t fVoltCheckPeriod; // how often to check the voltages (s) |
uci1 | 3:24c5f0f50bf1 | 136 | // communication |
uci1 | 3:24c5f0f50bf1 | 137 | uint32_t fCommWinPeriod; // seconds between communication window startup (0=always on) |
uci1 | 3:24c5f0f50bf1 | 138 | uint32_t fCommWinDuration; // seconds that communication window stays open (0=always open) |
uci1 | 3:24c5f0f50bf1 | 139 | 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 | 140 | uint32_t fCommWinPrdLowPwr; // low power communication window period (seconds) (range enforced) |
uci1 | 3:24c5f0f50bf1 | 141 | uint32_t fCommWinDurLowPwr; // low power communication window duration (seconds) (range enforced) |
uci1 | 40:1324da35afd4 | 142 | uint8_t fCommWinConnectTOMin; // comm win connection timeout (minutes) (range enforced) |
uci1 | 40:1324da35afd4 | 143 | uint8_t fCommWinListenTOMin; // comm win listening timeout (minutes) (range enforced) |
uci1 | 8:95a325df1f6b | 144 | char fRemoteServer[kIPLen]; // IP address of remote server (for afar) |
uci1 | 8:95a325df1f6b | 145 | uint16_t fRemotePort; // port number of remote server (for afar) |
uci1 | 8:95a325df1f6b | 146 | char fMbedIP[kIPLen]; // IP address of this mbed |
uci1 | 8:95a325df1f6b | 147 | char fMbedMask[kIPLen]; // IP address of this mbed mask |
uci1 | 8:95a325df1f6b | 148 | char fMbedGate[kIPLen]; // IP address of this mbed gateway |
uci1 | 3:24c5f0f50bf1 | 149 | // watchdog |
uci1 | 3:24c5f0f50bf1 | 150 | uint32_t fWatchDogPeriod; // number of seconds of inactivity for watchdog to issue a reset |
uci1 | 56:0bba0ef15697 | 151 | // temp |
uci1 | 56:0bba0ef15697 | 152 | int8_t fTempCheckPeriod; // number of minutes between temperature checks. if negative, uses parasite power. if 0, never check. |
uci1 | 3:24c5f0f50bf1 | 153 | |
uci1 | 8:95a325df1f6b | 154 | // in case of low power, store regular settings |
uci1 | 8:95a325df1f6b | 155 | // these are not sent over i/o or stored in the file |
uci1 | 8:95a325df1f6b | 156 | // so they are not included in SizeOf |
uci1 | 8:95a325df1f6b | 157 | bool fIsLowPower; |
uci1 | 8:95a325df1f6b | 158 | char fNormLabel[kConfLblLen]; |
uci1 | 8:95a325df1f6b | 159 | uint8_t fNormPowerMode; |
uci1 | 8:95a325df1f6b | 160 | |
uci1 | 3:24c5f0f50bf1 | 161 | void SetHardDefaults(); |
uci1 | 59:21128cc24b04 | 162 | |
uci1 | 3:24c5f0f50bf1 | 163 | static |
uci1 | 56:0bba0ef15697 | 164 | uint16_t GetTotDacsForIOVers(const uint8_t rv) { |
uci1 | 56:0bba0ef15697 | 165 | if (rv<9) { |
uci1 | 56:0bba0ef15697 | 166 | return kTotDacsAtwd4ch; |
uci1 | 56:0bba0ef15697 | 167 | } else { |
uci1 | 56:0bba0ef15697 | 168 | return kTotDacsSst4ch; |
uci1 | 56:0bba0ef15697 | 169 | } |
uci1 | 56:0bba0ef15697 | 170 | } |
uci1 | 56:0bba0ef15697 | 171 | |
uci1 | 56:0bba0ef15697 | 172 | static |
uci1 | 56:0bba0ef15697 | 173 | uint16_t GetMaxPlasForIOVers(const uint8_t rv) { |
uci1 | 56:0bba0ef15697 | 174 | if (rv<9) { |
uci1 | 56:0bba0ef15697 | 175 | return kNplasV1; |
uci1 | 56:0bba0ef15697 | 176 | } else { |
uci1 | 56:0bba0ef15697 | 177 | return 0; |
uci1 | 56:0bba0ef15697 | 178 | } |
uci1 | 56:0bba0ef15697 | 179 | } |
uci1 | 56:0bba0ef15697 | 180 | |
uci1 | 56:0bba0ef15697 | 181 | static |
uci1 | 8:95a325df1f6b | 182 | uint32_t SizeOf(const uint8_t rv, |
uci1 | 8:95a325df1f6b | 183 | const bool streamHiLoPlas, |
uci1 | 3:24c5f0f50bf1 | 184 | const uint8_t nplas, |
uci1 | 3:24c5f0f50bf1 | 185 | const uint8_t lblLen) { |
uci1 | 3:24c5f0f50bf1 | 186 | // private because it cannot be used to read from a buffer |
uci1 | 3:24c5f0f50bf1 | 187 | // (the label length and fStreamHiLoPlas are not known a priori) |
uci1 | 3:24c5f0f50bf1 | 188 | // returns the num of bytes needed to stream this object |
uci1 | 3:24c5f0f50bf1 | 189 | // = size of member vars + 1 for i/o version + extra PLA strings (maybe) |
uci1 | 8:95a325df1f6b | 190 | uint32_t maxsize = kMaxSizeOf; |
uci1 | 8:95a325df1f6b | 191 | if (rv==1) { |
uci1 | 8:95a325df1f6b | 192 | maxsize = kMaxSizeOfV1; |
uci1 | 8:95a325df1f6b | 193 | } else if (rv==2) { |
uci1 | 8:95a325df1f6b | 194 | maxsize = kMaxSizeOfV2; |
uci1 | 19:74155d652c37 | 195 | } else if (rv==3) { |
uci1 | 19:74155d652c37 | 196 | maxsize = kMaxSizeOfV3; |
uci1 | 39:2f17131d22a5 | 197 | } else if (rv==4) { |
uci1 | 39:2f17131d22a5 | 198 | maxsize = kMaxSizeOfV4; |
uci1 | 39:2f17131d22a5 | 199 | } else if (rv==5) { |
uci1 | 39:2f17131d22a5 | 200 | maxsize = kMaxSizeOfV5; |
uci1 | 39:2f17131d22a5 | 201 | } else if (rv==6) { |
uci1 | 40:1324da35afd4 | 202 | maxsize = kMaxSizeOfV6; |
uci1 | 40:1324da35afd4 | 203 | } else if (rv==7) { |
uci1 | 40:1324da35afd4 | 204 | maxsize = kMaxSizeOfV7; |
uci1 | 40:1324da35afd4 | 205 | } else if (rv==8) { |
uci1 | 40:1324da35afd4 | 206 | maxsize = kMaxSizeOfV8; |
uci1 | 56:0bba0ef15697 | 207 | } else if (rv==9) { |
uci1 | 56:0bba0ef15697 | 208 | maxsize = kMaxSizeOfV9; |
uci1 | 56:0bba0ef15697 | 209 | } else if (rv==10) { |
uci1 | 56:0bba0ef15697 | 210 | maxsize = kMaxSizeOfV10; |
uci1 | 8:95a325df1f6b | 211 | } |
uci1 | 39:2f17131d22a5 | 212 | const int32_t lbldiff = kConfLblLen - lblLen; |
uci1 | 39:2f17131d22a5 | 213 | uint32_t sz = maxsize - lbldiff; |
uci1 | 39:2f17131d22a5 | 214 | if ((lbldiff!=0) && (rv>=4)) { |
uci1 | 39:2f17131d22a5 | 215 | sz += 1; // the \0 at the end of the string |
uci1 | 39:2f17131d22a5 | 216 | } |
uci1 | 56:0bba0ef15697 | 217 | |
uci1 | 56:0bba0ef15697 | 218 | #if CHIPBOARD==ATWD4CH |
uci1 | 56:0bba0ef15697 | 219 | if (rv<9) { |
uci1 | 56:0bba0ef15697 | 220 | // streaming hi/lo plas separately? |
uci1 | 56:0bba0ef15697 | 221 | const uint32_t mhlp = 2u*GetMaxPlasForIOVers(rv)*sizeof(uint16_t); |
uci1 | 56:0bba0ef15697 | 222 | const int32_t dp = (nplas-GetMaxPlasForIOVers(rv))*sizeof(uint16_t); |
uci1 | 56:0bba0ef15697 | 223 | const uint8_t fac = (streamHiLoPlas) ? 3u : 1u; |
uci1 | 56:0bba0ef15697 | 224 | sz += (fac*dp); |
uci1 | 56:0bba0ef15697 | 225 | if (streamHiLoPlas==false) { |
uci1 | 56:0bba0ef15697 | 226 | sz -= mhlp; |
uci1 | 56:0bba0ef15697 | 227 | } |
uci1 | 3:24c5f0f50bf1 | 228 | } |
uci1 | 56:0bba0ef15697 | 229 | #endif |
uci1 | 3:24c5f0f50bf1 | 230 | return sz; |
uci1 | 3:24c5f0f50bf1 | 231 | } |
uci1 | 28:484943132bb0 | 232 | |
uci1 | 59:21128cc24b04 | 233 | bool ReadDefaultIPFiles(); |
uci1 | 59:21128cc24b04 | 234 | bool ReadOneIPFrom(const char* ipfname, char* ipstr); |
uci1 | 59:21128cc24b04 | 235 | bool ReadDefaultRemoteServer(); |
uci1 | 59:21128cc24b04 | 236 | bool ReadDefaultRemotePort(); |
uci1 | 59:21128cc24b04 | 237 | bool ReadDefaultMbedIP(); |
uci1 | 59:21128cc24b04 | 238 | bool ReadDefaultMbedMask(); |
uci1 | 59:21128cc24b04 | 239 | bool ReadDefaultMbedGate(); |
uci1 | 28:484943132bb0 | 240 | void SetDefaultIPs(); |
uci1 | 28:484943132bb0 | 241 | void SetDefaultRemoteServ(); |
uci1 | 28:484943132bb0 | 242 | void SetDefaultRemotePort(); |
uci1 | 28:484943132bb0 | 243 | void SetDefaultMbedIP(); |
uci1 | 28:484943132bb0 | 244 | void SetDefaultMaskIP(); |
uci1 | 28:484943132bb0 | 245 | void SetDefaultGateIP(); |
uci1 | 28:484943132bb0 | 246 | void ApplySafetyNets(); |
uci1 | 28:484943132bb0 | 247 | |
uci1 | 3:24c5f0f50bf1 | 248 | public: |
uci1 | 31:b5bd3b189150 | 249 | SnConfigFrame(const bool applySafety=true) : fIsLowPower(false) { |
uci1 | 31:b5bd3b189150 | 250 | fgApplySafetyNets = applySafety; |
uci1 | 31:b5bd3b189150 | 251 | Reset(); |
uci1 | 31:b5bd3b189150 | 252 | } |
uci1 | 3:24c5f0f50bf1 | 253 | virtual ~SnConfigFrame() {} |
uci1 | 40:1324da35afd4 | 254 | |
uci1 | 40:1324da35afd4 | 255 | void ApplyConnectListenSafetyNets(); |
uci1 | 3:24c5f0f50bf1 | 256 | |
uci1 | 8:95a325df1f6b | 257 | bool IsCountingPowerReadings() const { return ((fRunMode & kCountPowerBit)!=0); } |
uci1 | 8:95a325df1f6b | 258 | bool IsSingleSeqRunMode() const { return ((fRunMode & kSingleSeqBit)!=0); } |
uci1 | 56:0bba0ef15697 | 259 | bool IsDualThresholdMode() const { return ((fRunMode & kDualThreshBit)!=0); } |
uci1 | 56:0bba0ef15697 | 260 | bool IsDifferentialTrigMode() const { return ((fRunMode & kDiffTrigBit)!=0); } |
uci1 | 56:0bba0ef15697 | 261 | bool IsSBDonlyLowPwrMode() const { return ((fRunMode & kLowPwrSBDonly)!=0); } |
uci1 | 56:0bba0ef15697 | 262 | bool IsRunSeqListOneCommWinOnly() const { return ((fRunMode & kRSListOneCW)!=0); } |
uci1 | 8:95a325df1f6b | 263 | bool IsLowPowerMode() const { return fIsLowPower; } |
uci1 | 3:24c5f0f50bf1 | 264 | const char* GetLabel() const { return fLabel; } |
uci1 | 3:24c5f0f50bf1 | 265 | uint32_t GetLabelStrLen() const { return strlen(fLabel); } |
uci1 | 3:24c5f0f50bf1 | 266 | uint32_t GetRun() const { return fRun; } |
uci1 | 40:1324da35afd4 | 267 | uint16_t GetFirstSeq() const { return fFirstSeq; } |
uci1 | 3:24c5f0f50bf1 | 268 | uint32_t GetEvtsPerFile() const { return fEvtsPerSeq; } |
uci1 | 56:0bba0ef15697 | 269 | inline |
uci1 | 3:24c5f0f50bf1 | 270 | uint16_t GetEvtThrtlPeriodMs() const { return fEvtThrtlPeriodMs; } |
uci1 | 18:55f1581f2ee4 | 271 | float GetForceTrigPeriod() const { return fForceTrigPeriod; } |
uci1 | 3:24c5f0f50bf1 | 272 | uint16_t GetHeartbeatPeriod() const { return fHeartBeatPeriod; } |
uci1 | 39:2f17131d22a5 | 273 | uint16_t GetBatVoltToLowPwr() const { return fBatVoltToLowPwr; } |
uci1 | 39:2f17131d22a5 | 274 | uint16_t GetBatVoltFromLowPwr() const { return fBatVoltFromLowPwr; } |
uci1 | 8:95a325df1f6b | 275 | uint16_t GetVoltCheckPeriod() const { return fVoltCheckPeriod; } |
uci1 | 3:24c5f0f50bf1 | 276 | uint32_t GetWatchdogPeriod() const { return fWatchDogPeriod; } |
uci1 | 56:0bba0ef15697 | 277 | uint16_t GetTempCheckPeriod() const { |
uci1 | 56:0bba0ef15697 | 278 | const uint16_t t = (fTempCheckPeriod<0) ? (-fTempCheckPeriod) : fTempCheckPeriod; |
uci1 | 56:0bba0ef15697 | 279 | return t*60; |
uci1 | 56:0bba0ef15697 | 280 | } |
uci1 | 56:0bba0ef15697 | 281 | bool IsTempUsingParasitePower() const { return (fTempCheckPeriod<0); } |
uci1 | 3:24c5f0f50bf1 | 282 | uint16_t GetDac(const uint8_t ch, const uint8_t dn) const { return fDAC[ch][dn]; } |
uci1 | 56:0bba0ef15697 | 283 | #if CHIPBOARD==ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 284 | uint8_t GetNumPlas() const { return fNumPlas; } |
uci1 | 3:24c5f0f50bf1 | 285 | uint16_t GetPla(const uint8_t pn) const { return fPLA[pn]; } |
uci1 | 56:0bba0ef15697 | 286 | #endif |
uci1 | 3:24c5f0f50bf1 | 287 | uint8_t GetNumCardsMajLog() const { return fNumCardsMajLog; } |
uci1 | 3:24c5f0f50bf1 | 288 | bool IsThermTrigEnabled() const { return fEnableThermTrig!=0; } |
uci1 | 3:24c5f0f50bf1 | 289 | bool IsEachAmpOn() const { |
uci1 | 3:24c5f0f50bf1 | 290 | bool allon=true; |
uci1 | 3:24c5f0f50bf1 | 291 | for (uint8_t i=0; (i<kNchans) && allon; i++) { |
uci1 | 3:24c5f0f50bf1 | 292 | allon = (fAmpsOn & BIT(i))!=0; |
uci1 | 3:24c5f0f50bf1 | 293 | } |
uci1 | 3:24c5f0f50bf1 | 294 | return allon; |
uci1 | 3:24c5f0f50bf1 | 295 | } |
uci1 | 3:24c5f0f50bf1 | 296 | // TODO: allow check for individual amps, when they can be turned on individually |
uci1 | 3:24c5f0f50bf1 | 297 | |
uci1 | 8:95a325df1f6b | 298 | const char* GetRemoteServer() const { return fRemoteServer; } |
uci1 | 8:95a325df1f6b | 299 | uint16_t GetRemotePort() const { return fRemotePort; } |
uci1 | 8:95a325df1f6b | 300 | const char* GetMbedIP() const { return fMbedIP; } |
uci1 | 8:95a325df1f6b | 301 | const char* GetMbedMask() const { return fMbedMask; } |
uci1 | 8:95a325df1f6b | 302 | const char* GetMbedGate() const { return fMbedGate; } |
uci1 | 8:95a325df1f6b | 303 | uint32_t GetCommWinPeriod() const { return fIsLowPower ? fCommWinPrdLowPwr : fCommWinPeriod; } |
uci1 | 8:95a325df1f6b | 304 | uint32_t GetCommWinDuration() const { return fIsLowPower ? fCommWinDurLowPwr : fCommWinDuration; } |
uci1 | 40:1324da35afd4 | 305 | uint32_t GetCommWinConnectTO() const { return (static_cast<uint32_t>(fCommWinConnectTOMin) * 60u); } |
uci1 | 40:1324da35afd4 | 306 | uint32_t GetCommWinListenTO() const { return (static_cast<uint32_t>(fCommWinListenTOMin) * 60u); } |
uci1 | 3:24c5f0f50bf1 | 307 | int16_t GetCommSendData() const { return fCommSendData; } |
uci1 | 3:24c5f0f50bf1 | 308 | |
uci1 | 3:24c5f0f50bf1 | 309 | bool IsSendingAllFiles() const |
uci1 | 3:24c5f0f50bf1 | 310 | { return (fCommSendData<0) && ((fCommSendData & kAllFiles)!=0); } |
uci1 | 3:24c5f0f50bf1 | 311 | bool IsObeyingTimeout() const |
uci1 | 3:24c5f0f50bf1 | 312 | { return (fCommSendData<0) && ((fCommSendData & kTimeout)!=0); } |
uci1 | 3:24c5f0f50bf1 | 313 | bool IsDeletingFiles() const |
uci1 | 3:24c5f0f50bf1 | 314 | { return (fCommSendData<0) && ((fCommSendData & kDelete)!=0); } |
uci1 | 15:f2569d8e4176 | 315 | bool IsForcingSBDdata() const |
uci1 | 15:f2569d8e4176 | 316 | { return (fCommSendData<0) && ((fCommSendData & kForceSBDdata)!=0); } |
uci1 | 40:1324da35afd4 | 317 | bool IsWaitingHndShkBeforeSendData() const |
uci1 | 40:1324da35afd4 | 318 | { return (fCommSendData<0) && ((fCommSendData & kHnShBefSendDat)!=0); } |
uci1 | 56:0bba0ef15697 | 319 | bool IsSendingFilesRunSeqList() const |
uci1 | 56:0bba0ef15697 | 320 | { return (fCommSendData<0) && ((fCommSendData & kSendRunSeqList)!=0); } |
uci1 | 3:24c5f0f50bf1 | 321 | |
uci1 | 4:a91682e19d6b | 322 | uint8_t GetPowerMode() const { return fPowerMode; } |
uci1 | 30:f869ed4bcc08 | 323 | int GetPowPinSetting(const EPowerModeBit p, const bool isOn) const { |
uci1 | 56:0bba0ef15697 | 324 | #if CHIPBOARD==ATWD4CH |
uci1 | 5:9cea89700c66 | 325 | if (p==kCardDatTak || p==kCardComWin || |
uci1 | 5:9cea89700c66 | 326 | p==kAmpsDatTak || p==kAmpsComWin) { |
uci1 | 30:f869ed4bcc08 | 327 | return isOn ? 0 : 1; |
uci1 | 5:9cea89700c66 | 328 | } else { |
uci1 | 30:f869ed4bcc08 | 329 | return isOn ? 1 : 0; |
uci1 | 5:9cea89700c66 | 330 | } |
uci1 | 56:0bba0ef15697 | 331 | #else |
uci1 | 56:0bba0ef15697 | 332 | return isOn ? 1 : 0; |
uci1 | 56:0bba0ef15697 | 333 | #endif |
uci1 | 5:9cea89700c66 | 334 | } |
uci1 | 30:f869ed4bcc08 | 335 | int GetPowPinSetting(const EPowerModeBit p) const { |
uci1 | 30:f869ed4bcc08 | 336 | // return int to correspond to what DigitalOut::operator= expects |
uci1 | 30:f869ed4bcc08 | 337 | return GetPowPinSetting(p, IsPoweredFor(p)); |
uci1 | 30:f869ed4bcc08 | 338 | } |
uci1 | 8:95a325df1f6b | 339 | bool IsPoweredFor(const EPowerModeBit p) const { |
uci1 | 8:95a325df1f6b | 340 | return ((fPowerMode & p)!=0); |
uci1 | 8:95a325df1f6b | 341 | } |
uci1 | 8:95a325df1f6b | 342 | |
uci1 | 8:95a325df1f6b | 343 | void EnablePowerFor(const EPowerModeBit p) { fPowerMode |= p; } |
uci1 | 8:95a325df1f6b | 344 | void DisablePowerFor(const EPowerModeBit p) { fPowerMode &= ~p; } |
uci1 | 8:95a325df1f6b | 345 | |
uci1 | 8:95a325df1f6b | 346 | void ChangeToLowPower(); |
uci1 | 8:95a325df1f6b | 347 | void ChangeToNormPower(); |
uci1 | 3:24c5f0f50bf1 | 348 | |
uci1 | 3:24c5f0f50bf1 | 349 | const char* GetOutFileName(const char* dir) const; |
uci1 | 3:24c5f0f50bf1 | 350 | |
uci1 | 21:ce51bb0ba4a5 | 351 | uint32_t GetTimeoutTime(const uint32_t startTime, |
uci1 | 21:ce51bb0ba4a5 | 352 | const uint32_t delta) const; |
uci1 | 21:ce51bb0ba4a5 | 353 | |
uci1 | 21:ce51bb0ba4a5 | 354 | |
uci1 | 3:24c5f0f50bf1 | 355 | // waveform packing info |
uci1 | 3:24c5f0f50bf1 | 356 | uint16_t GetWvBaseline() const { return fWvBaseline; } |
uci1 | 3:24c5f0f50bf1 | 357 | uint8_t GetWvLoseLSB() const { return fWvLoseLSB; } |
uci1 | 3:24c5f0f50bf1 | 358 | uint8_t GetWvLoseMSB() const { return fWvLoseMSB; } |
uci1 | 3:24c5f0f50bf1 | 359 | bool IsDatPackedFor(const EDatPackBit d) const { return (fDatPackType & d)!=0; } |
uci1 | 3:24c5f0f50bf1 | 360 | void GetPackParsFor(const EDatPackBit d, |
uci1 | 3:24c5f0f50bf1 | 361 | uint8_t& loseLSB, uint8_t& loseMSB, |
uci1 | 3:24c5f0f50bf1 | 362 | uint16_t& wvBase) const; |
uci1 | 3:24c5f0f50bf1 | 363 | |
uci1 | 3:24c5f0f50bf1 | 364 | // i/o |
uci1 | 40:1324da35afd4 | 365 | static |
uci1 | 40:1324da35afd4 | 366 | bool IsIOversionOk(const uint8_t rv) { |
uci1 | 40:1324da35afd4 | 367 | return (kIOVers == rv); |
uci1 | 40:1324da35afd4 | 368 | } |
uci1 | 40:1324da35afd4 | 369 | |
uci1 | 40:1324da35afd4 | 370 | template<class T> |
uci1 | 40:1324da35afd4 | 371 | static |
uci1 | 40:1324da35afd4 | 372 | uint8_t PeekIOversion(T& b) { |
uci1 | 40:1324da35afd4 | 373 | // the buffer/file/whatever 'b' must be at the start of the config frame |
uci1 | 40:1324da35afd4 | 374 | uint8_t Rv=0; |
uci1 | 40:1324da35afd4 | 375 | SnBitUtils::ReadFrom(b, Rv); |
uci1 | 40:1324da35afd4 | 376 | return Rv; |
uci1 | 40:1324da35afd4 | 377 | } |
uci1 | 40:1324da35afd4 | 378 | |
uci1 | 3:24c5f0f50bf1 | 379 | template<class T> |
uci1 | 3:24c5f0f50bf1 | 380 | void ReadFrom(T& b) { |
uci1 | 3:24c5f0f50bf1 | 381 | // no check on the length of buf is done here |
uci1 | 3:24c5f0f50bf1 | 382 | // that should be been done already |
uci1 | 3:24c5f0f50bf1 | 383 | // |
uci1 | 3:24c5f0f50bf1 | 384 | // must match WriteTo |
uci1 | 3:24c5f0f50bf1 | 385 | |
uci1 | 3:24c5f0f50bf1 | 386 | uint8_t Rv=0; |
uci1 | 3:24c5f0f50bf1 | 387 | b = SnBitUtils::ReadFrom(b, Rv); // i/o version |
uci1 | 12:d472f9811262 | 388 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 389 | printf("Rv=%hhu\r\n",Rv); |
uci1 | 12:d472f9811262 | 390 | #endif |
uci1 | 3:24c5f0f50bf1 | 391 | if (Rv>0) { |
uci1 | 56:0bba0ef15697 | 392 | |
uci1 | 56:0bba0ef15697 | 393 | if (IsLowPowerMode()) { |
uci1 | 56:0bba0ef15697 | 394 | // the low power bit is not streamed, so we need to |
uci1 | 56:0bba0ef15697 | 395 | // reset it explicitly |
uci1 | 56:0bba0ef15697 | 396 | ChangeToNormPower(); |
uci1 | 56:0bba0ef15697 | 397 | } |
uci1 | 56:0bba0ef15697 | 398 | |
uci1 | 3:24c5f0f50bf1 | 399 | uint32_t llen=kConfLblLen; |
uci1 | 3:24c5f0f50bf1 | 400 | b = SnBitUtils::ReadFrom(b, llen); |
uci1 | 12:d472f9811262 | 401 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 402 | printf("llen=%u\r\n",llen); |
uci1 | 12:d472f9811262 | 403 | #endif |
uci1 | 3:24c5f0f50bf1 | 404 | b = SnBitUtils::ReadFrom(b, fLabel, llen); |
uci1 | 12:d472f9811262 | 405 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 406 | printf("lbl=%s\r\n",fLabel); |
uci1 | 12:d472f9811262 | 407 | #endif |
uci1 | 3:24c5f0f50bf1 | 408 | b = SnBitUtils::ReadFrom(b, fConfTime); |
uci1 | 12:d472f9811262 | 409 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 410 | printf("ct=%u\r\n",fConfTime); |
uci1 | 12:d472f9811262 | 411 | #endif |
uci1 | 3:24c5f0f50bf1 | 412 | b = SnBitUtils::ReadFrom(b, fRun); |
uci1 | 12:d472f9811262 | 413 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 414 | printf("run=%u\r\n",fRun); |
uci1 | 12:d472f9811262 | 415 | #endif |
uci1 | 40:1324da35afd4 | 416 | if (Rv>7) { |
uci1 | 40:1324da35afd4 | 417 | b = SnBitUtils::ReadFrom(b, fFirstSeq); |
uci1 | 40:1324da35afd4 | 418 | } else { |
uci1 | 40:1324da35afd4 | 419 | uint32_t fe(0); |
uci1 | 40:1324da35afd4 | 420 | fFirstSeq = 0; |
uci1 | 40:1324da35afd4 | 421 | b = SnBitUtils::ReadFrom(b, fe); |
uci1 | 40:1324da35afd4 | 422 | } |
uci1 | 12:d472f9811262 | 423 | #ifdef DEBUG |
uci1 | 40:1324da35afd4 | 424 | printf("firstseq=%hu\r\n",fFirstSeq); |
uci1 | 12:d472f9811262 | 425 | #endif |
uci1 | 3:24c5f0f50bf1 | 426 | if (Rv>1) { |
uci1 | 3:24c5f0f50bf1 | 427 | b = SnBitUtils::ReadFrom(b, fEvtsPerSeq); |
uci1 | 40:1324da35afd4 | 428 | b = SnBitUtils::ReadFrom(b, fRunMode); |
uci1 | 40:1324da35afd4 | 429 | } else { |
uci1 | 40:1324da35afd4 | 430 | fEvtsPerSeq = 1000; |
uci1 | 40:1324da35afd4 | 431 | fRunMode = 0; |
uci1 | 40:1324da35afd4 | 432 | } |
uci1 | 12:d472f9811262 | 433 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 434 | printf("eps=%u\r\n",fEvtsPerSeq); |
uci1 | 3:24c5f0f50bf1 | 435 | printf("rm=%hhu\r\n",fRunMode); |
uci1 | 12:d472f9811262 | 436 | #endif |
uci1 | 56:0bba0ef15697 | 437 | #if CHIPBOARD==ATWD4CH |
uci1 | 56:0bba0ef15697 | 438 | if (Rv<9) { |
uci1 | 56:0bba0ef15697 | 439 | b = SnBitUtils::ReadFrom(b, fStreamHiLoPlas); |
uci1 | 12:d472f9811262 | 440 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 441 | printf("shilo=%d\r\n",(int)fStreamHiLoPlas); |
uci1 | 12:d472f9811262 | 442 | #endif |
uci1 | 56:0bba0ef15697 | 443 | } |
uci1 | 56:0bba0ef15697 | 444 | #endif // ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 445 | b = SnBitUtils::ReadFrom(b, fWvLoseLSB); |
uci1 | 12:d472f9811262 | 446 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 447 | printf("lsb=%hhu\r\n",fWvLoseLSB); |
uci1 | 12:d472f9811262 | 448 | #endif |
uci1 | 3:24c5f0f50bf1 | 449 | b = SnBitUtils::ReadFrom(b, fWvLoseMSB); |
uci1 | 12:d472f9811262 | 450 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 451 | printf("msb=%hhu\r\n",fWvLoseMSB); |
uci1 | 12:d472f9811262 | 452 | #endif |
uci1 | 3:24c5f0f50bf1 | 453 | b = SnBitUtils::ReadFrom(b, fWvBaseline); |
uci1 | 12:d472f9811262 | 454 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 455 | printf("bl=%hu\r\n",fWvBaseline); |
uci1 | 12:d472f9811262 | 456 | #endif |
uci1 | 3:24c5f0f50bf1 | 457 | b = SnBitUtils::ReadFrom(b, fDatPackType); |
uci1 | 12:d472f9811262 | 458 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 459 | printf("dp=%hhu\r\n",fDatPackType); |
uci1 | 12:d472f9811262 | 460 | #endif |
uci1 | 3:24c5f0f50bf1 | 461 | uint16_t* dc = &(fDAC[0][0]); |
uci1 | 56:0bba0ef15697 | 462 | const uint8_t ntotdacs = GetTotDacsForIOVers(Rv); |
uci1 | 56:0bba0ef15697 | 463 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 464 | printf("ntotdacs=%hhu\r\n",ntotdacs); |
uci1 | 56:0bba0ef15697 | 465 | #endif |
uci1 | 56:0bba0ef15697 | 466 | for (uint16_t i=0; i<ntotdacs; i++, dc++) { |
uci1 | 3:24c5f0f50bf1 | 467 | b = SnBitUtils::ReadFrom(b, *dc); |
uci1 | 12:d472f9811262 | 468 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 469 | printf("dac[%hu]=%hu\r\n",i,*dc); |
uci1 | 12:d472f9811262 | 470 | #endif |
uci1 | 3:24c5f0f50bf1 | 471 | } |
uci1 | 56:0bba0ef15697 | 472 | #if CHIPBOARD==ATWD4CH |
uci1 | 56:0bba0ef15697 | 473 | if (Rv<9) { |
uci1 | 56:0bba0ef15697 | 474 | b = SnBitUtils::ReadFrom(b, fNumPlas); |
uci1 | 12:d472f9811262 | 475 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 476 | printf("npla=%hhu\r\n",fNumPlas); |
uci1 | 12:d472f9811262 | 477 | #endif |
uci1 | 56:0bba0ef15697 | 478 | uint16_t* pl = &(fPLA[0]); |
uci1 | 56:0bba0ef15697 | 479 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 56:0bba0ef15697 | 480 | b = SnBitUtils::ReadFrom(b, *pl); |
uci1 | 12:d472f9811262 | 481 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 482 | printf("pla[%hhu]=%hu\r\n",j,*pl); |
uci1 | 12:d472f9811262 | 483 | #endif |
uci1 | 56:0bba0ef15697 | 484 | } |
uci1 | 3:24c5f0f50bf1 | 485 | } |
uci1 | 56:0bba0ef15697 | 486 | #endif // ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 487 | b = SnBitUtils::ReadFrom(b, fNumCardsMajLog); |
uci1 | 12:d472f9811262 | 488 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 489 | printf("mj=%hhu\r\n",fNumCardsMajLog); |
uci1 | 12:d472f9811262 | 490 | #endif |
uci1 | 3:24c5f0f50bf1 | 491 | b = SnBitUtils::ReadFrom(b, fEnableThermTrig); |
uci1 | 12:d472f9811262 | 492 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 493 | printf("thm=%d\r\n",(int)fEnableThermTrig); |
uci1 | 12:d472f9811262 | 494 | #endif |
uci1 | 18:55f1581f2ee4 | 495 | if (Rv>3) { |
uci1 | 18:55f1581f2ee4 | 496 | b = SnBitUtils::ReadFrom(b, fForceTrigPeriod); |
uci1 | 18:55f1581f2ee4 | 497 | } else { |
uci1 | 18:55f1581f2ee4 | 498 | uint16_t ftrg(0); |
uci1 | 18:55f1581f2ee4 | 499 | b = SnBitUtils::ReadFrom(b, ftrg); |
uci1 | 18:55f1581f2ee4 | 500 | fForceTrigPeriod = ftrg; |
uci1 | 18:55f1581f2ee4 | 501 | } |
uci1 | 12:d472f9811262 | 502 | #ifdef DEBUG |
uci1 | 18:55f1581f2ee4 | 503 | printf("force=%g\r\n",fForceTrigPeriod); |
uci1 | 12:d472f9811262 | 504 | #endif |
uci1 | 3:24c5f0f50bf1 | 505 | b = SnBitUtils::ReadFrom(b, fHeartBeatPeriod); |
uci1 | 12:d472f9811262 | 506 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 507 | printf("heart=%hu\r\n",fHeartBeatPeriod); |
uci1 | 12:d472f9811262 | 508 | #endif |
uci1 | 3:24c5f0f50bf1 | 509 | b = SnBitUtils::ReadFrom(b, fAmpsOn); |
uci1 | 12:d472f9811262 | 510 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 511 | printf("amps=%hhu\r\n",fAmpsOn); |
uci1 | 12:d472f9811262 | 512 | #endif |
uci1 | 3:24c5f0f50bf1 | 513 | b = SnBitUtils::ReadFrom(b, fEvtThrtlPeriodMs); |
uci1 | 12:d472f9811262 | 514 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 515 | printf("throt=%hu\r\n",fEvtThrtlPeriodMs); |
uci1 | 12:d472f9811262 | 516 | #endif |
uci1 | 3:24c5f0f50bf1 | 517 | b = SnBitUtils::ReadFrom(b, fPowerMode); |
uci1 | 12:d472f9811262 | 518 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 519 | printf("pow=%hhu\r\n",fPowerMode); |
uci1 | 12:d472f9811262 | 520 | #endif |
uci1 | 39:2f17131d22a5 | 521 | if (Rv<6) { |
uci1 | 39:2f17131d22a5 | 522 | b = SnBitUtils::ReadFrom(b, fBatVoltToLowPwr); |
uci1 | 40:1324da35afd4 | 523 | fBatVoltFromLowPwr = 1.1*fBatVoltToLowPwr; |
uci1 | 39:2f17131d22a5 | 524 | } else { |
uci1 | 39:2f17131d22a5 | 525 | b = SnBitUtils::ReadFrom(b, fBatVoltToLowPwr); |
uci1 | 39:2f17131d22a5 | 526 | b = SnBitUtils::ReadFrom(b, fBatVoltFromLowPwr); |
uci1 | 39:2f17131d22a5 | 527 | } |
uci1 | 39:2f17131d22a5 | 528 | #ifdef DEBUG |
uci1 | 40:1324da35afd4 | 529 | printf("batlow(to,from)=(%hu,%hu)\r\n",fBatVoltToLowPwr,fBatVoltFromLowPwr); |
uci1 | 12:d472f9811262 | 530 | #endif |
uci1 | 8:95a325df1f6b | 531 | if (Rv>2) { |
uci1 | 8:95a325df1f6b | 532 | b = SnBitUtils::ReadFrom(b, fVoltCheckPeriod); |
uci1 | 40:1324da35afd4 | 533 | } else { |
uci1 | 40:1324da35afd4 | 534 | fVoltCheckPeriod = 600u; |
uci1 | 40:1324da35afd4 | 535 | } |
uci1 | 12:d472f9811262 | 536 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 537 | printf("vltchk=%hu\r\n",fVoltCheckPeriod); |
uci1 | 12:d472f9811262 | 538 | #endif |
uci1 | 3:24c5f0f50bf1 | 539 | b = SnBitUtils::ReadFrom(b, fCommWinPeriod); |
uci1 | 12:d472f9811262 | 540 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 541 | printf("cmper=%u\r\n",fCommWinPeriod); |
uci1 | 12:d472f9811262 | 542 | #endif |
uci1 | 3:24c5f0f50bf1 | 543 | b = SnBitUtils::ReadFrom(b, fCommWinDuration); |
uci1 | 12:d472f9811262 | 544 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 545 | printf("cmdur=%u\r\n",fCommWinDuration); |
uci1 | 12:d472f9811262 | 546 | #endif |
uci1 | 3:24c5f0f50bf1 | 547 | b = SnBitUtils::ReadFrom(b, fCommSendData); |
uci1 | 12:d472f9811262 | 548 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 549 | printf("send=%d\r\n",fCommSendData); |
uci1 | 12:d472f9811262 | 550 | #endif |
uci1 | 3:24c5f0f50bf1 | 551 | b = SnBitUtils::ReadFrom(b, fCommWinPrdLowPwr); |
uci1 | 12:d472f9811262 | 552 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 553 | printf("cmperlp=%u\r\n",fCommWinPrdLowPwr); |
uci1 | 12:d472f9811262 | 554 | #endif |
uci1 | 3:24c5f0f50bf1 | 555 | b = SnBitUtils::ReadFrom(b, fCommWinDurLowPwr); |
uci1 | 12:d472f9811262 | 556 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 557 | printf("cmdurlp=%u\r\n",fCommWinDurLowPwr); |
uci1 | 12:d472f9811262 | 558 | #endif |
uci1 | 40:1324da35afd4 | 559 | if (Rv>6) { |
uci1 | 40:1324da35afd4 | 560 | b = SnBitUtils::ReadFrom(b, fCommWinConnectTOMin); |
uci1 | 40:1324da35afd4 | 561 | b = SnBitUtils::ReadFrom(b, fCommWinListenTOMin); |
uci1 | 40:1324da35afd4 | 562 | } else { |
uci1 | 40:1324da35afd4 | 563 | fCommWinConnectTOMin = fCommWinListenTOMin = 3u; |
uci1 | 40:1324da35afd4 | 564 | } |
uci1 | 40:1324da35afd4 | 565 | #ifdef DEBUG |
uci1 | 40:1324da35afd4 | 566 | printf("connectTO=%hhu, listenTO=%hhu\r\n", |
uci1 | 40:1324da35afd4 | 567 | fCommWinConnectTOMin, fCommWinListenTOMin); |
uci1 | 40:1324da35afd4 | 568 | #endif |
uci1 | 8:95a325df1f6b | 569 | if (Rv>2) { |
uci1 | 8:95a325df1f6b | 570 | b = SnBitUtils::ReadFrom(b, fRemoteServer, kIPLen); |
uci1 | 28:484943132bb0 | 571 | if (strncmp(fRemoteServer, kDefIPflag,kIPLen)==0) { |
uci1 | 28:484943132bb0 | 572 | SetDefaultRemoteServ(); |
uci1 | 28:484943132bb0 | 573 | } |
uci1 | 12:d472f9811262 | 574 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 575 | printf("rserv=%s\r\n",fRemoteServer); |
uci1 | 12:d472f9811262 | 576 | #endif |
uci1 | 8:95a325df1f6b | 577 | b = SnBitUtils::ReadFrom(b, fRemotePort); |
uci1 | 28:484943132bb0 | 578 | if (fRemotePort==0) { |
uci1 | 28:484943132bb0 | 579 | SetDefaultRemotePort(); |
uci1 | 28:484943132bb0 | 580 | } |
uci1 | 12:d472f9811262 | 581 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 582 | printf("rport=%hu\r\n",fRemotePort); |
uci1 | 12:d472f9811262 | 583 | #endif |
uci1 | 8:95a325df1f6b | 584 | b = SnBitUtils::ReadFrom(b, fMbedIP, kIPLen); |
uci1 | 28:484943132bb0 | 585 | if (strncmp(fMbedIP, kDefIPflag,kIPLen)==0) { |
uci1 | 28:484943132bb0 | 586 | SetDefaultMbedIP(); |
uci1 | 28:484943132bb0 | 587 | } |
uci1 | 12:d472f9811262 | 588 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 589 | printf("mbedip=%s\r\n",fMbedIP); |
uci1 | 12:d472f9811262 | 590 | #endif |
uci1 | 8:95a325df1f6b | 591 | b = SnBitUtils::ReadFrom(b, fMbedMask, kIPLen); |
uci1 | 28:484943132bb0 | 592 | if (strncmp(fMbedMask, kDefIPflag,kIPLen)==0) { |
uci1 | 28:484943132bb0 | 593 | SetDefaultMaskIP(); |
uci1 | 28:484943132bb0 | 594 | } |
uci1 | 12:d472f9811262 | 595 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 596 | printf("mbedmask=%s\r\n",fMbedMask); |
uci1 | 12:d472f9811262 | 597 | #endif |
uci1 | 8:95a325df1f6b | 598 | b = SnBitUtils::ReadFrom(b, fMbedGate, kIPLen); |
uci1 | 28:484943132bb0 | 599 | if (strncmp(fMbedGate, kDefIPflag,kIPLen)==0) { |
uci1 | 28:484943132bb0 | 600 | SetDefaultGateIP(); |
uci1 | 28:484943132bb0 | 601 | } |
uci1 | 12:d472f9811262 | 602 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 603 | printf("mbedgate=%s\r\n",fMbedGate); |
uci1 | 12:d472f9811262 | 604 | #endif |
uci1 | 40:1324da35afd4 | 605 | } else { |
uci1 | 40:1324da35afd4 | 606 | SetDefaultIPs(); |
uci1 | 8:95a325df1f6b | 607 | } |
uci1 | 3:24c5f0f50bf1 | 608 | b = SnBitUtils::ReadFrom(b, fWatchDogPeriod); |
uci1 | 12:d472f9811262 | 609 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 610 | printf("watch=%u\r\n",fWatchDogPeriod); |
uci1 | 12:d472f9811262 | 611 | #endif |
uci1 | 56:0bba0ef15697 | 612 | if (Rv>9) { |
uci1 | 56:0bba0ef15697 | 613 | b = SnBitUtils::ReadFrom(b, fTempCheckPeriod); |
uci1 | 56:0bba0ef15697 | 614 | } |
uci1 | 12:d472f9811262 | 615 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 616 | printf("temp check period=%hhd\r\n", fTempCheckPeriod); |
uci1 | 12:d472f9811262 | 617 | #endif |
uci1 | 56:0bba0ef15697 | 618 | #if CHIPBOARD==ATWD4CH |
uci1 | 56:0bba0ef15697 | 619 | if (Rv<9) { |
uci1 | 56:0bba0ef15697 | 620 | if (fStreamHiLoPlas!=0) { |
uci1 | 56:0bba0ef15697 | 621 | uint16_t hi, lo; |
uci1 | 56:0bba0ef15697 | 622 | for (uint8_t j=0; j<fNumPlas; j++) { |
uci1 | 56:0bba0ef15697 | 623 | b = SnBitUtils::ReadFrom(b, hi); |
uci1 | 12:d472f9811262 | 624 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 625 | printf("hi=%hu\r\n",hi); |
uci1 | 56:0bba0ef15697 | 626 | #endif |
uci1 | 56:0bba0ef15697 | 627 | b = SnBitUtils::ReadFrom(b, lo); |
uci1 | 56:0bba0ef15697 | 628 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 629 | printf("lo=%hu\r\n",lo); |
uci1 | 12:d472f9811262 | 630 | #endif |
uci1 | 3:24c5f0f50bf1 | 631 | // don't save these |
uci1 | 56:0bba0ef15697 | 632 | } |
uci1 | 3:24c5f0f50bf1 | 633 | } |
uci1 | 3:24c5f0f50bf1 | 634 | } |
uci1 | 56:0bba0ef15697 | 635 | #endif // ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 636 | } |
uci1 | 28:484943132bb0 | 637 | |
uci1 | 31:b5bd3b189150 | 638 | if (fgApplySafetyNets) { |
uci1 | 31:b5bd3b189150 | 639 | ApplySafetyNets(); |
uci1 | 31:b5bd3b189150 | 640 | } |
uci1 | 28:484943132bb0 | 641 | |
uci1 | 12:d472f9811262 | 642 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 643 | printf("read from done\r\n"); |
uci1 | 12:d472f9811262 | 644 | #endif |
uci1 | 3:24c5f0f50bf1 | 645 | } |
uci1 | 3:24c5f0f50bf1 | 646 | |
uci1 | 3:24c5f0f50bf1 | 647 | template <class T> |
uci1 | 3:24c5f0f50bf1 | 648 | void WriteTo(T& b) const { |
uci1 | 3:24c5f0f50bf1 | 649 | // no check on the length of the buf is done here |
uci1 | 3:24c5f0f50bf1 | 650 | // that should be done already |
uci1 | 3:24c5f0f50bf1 | 651 | // |
uci1 | 3:24c5f0f50bf1 | 652 | // must match ReadFromBuf |
uci1 | 3:24c5f0f50bf1 | 653 | // |
uci1 | 3:24c5f0f50bf1 | 654 | // intentionally not writing mac address here, so we don't have to read it in |
uci1 | 3:24c5f0f50bf1 | 655 | |
uci1 | 3:24c5f0f50bf1 | 656 | b = SnBitUtils::WriteTo(b, kIOVers); // i/o version |
uci1 | 40:1324da35afd4 | 657 | // account for the ending \0 |
uci1 | 40:1324da35afd4 | 658 | uint32_t llen = strlen(fLabel); |
uci1 | 40:1324da35afd4 | 659 | static const uint32_t maxllen = kConfLblLen-1; |
uci1 | 40:1324da35afd4 | 660 | if (llen > maxllen) { |
uci1 | 40:1324da35afd4 | 661 | llen = maxllen; |
uci1 | 40:1324da35afd4 | 662 | } |
uci1 | 40:1324da35afd4 | 663 | b = SnBitUtils::WriteTo(b, llen+1); // strlen + \0 |
uci1 | 3:24c5f0f50bf1 | 664 | b = SnBitUtils::WriteTo(b, fLabel, llen); |
uci1 | 39:2f17131d22a5 | 665 | b = SnBitUtils::WriteTo(b, char('\0')); |
uci1 | 3:24c5f0f50bf1 | 666 | b = SnBitUtils::WriteTo(b, fConfTime); |
uci1 | 3:24c5f0f50bf1 | 667 | b = SnBitUtils::WriteTo(b, fRun); |
uci1 | 40:1324da35afd4 | 668 | b = SnBitUtils::WriteTo(b, fFirstSeq); |
uci1 | 3:24c5f0f50bf1 | 669 | b = SnBitUtils::WriteTo(b, fEvtsPerSeq); |
uci1 | 3:24c5f0f50bf1 | 670 | b = SnBitUtils::WriteTo(b, fRunMode); |
uci1 | 56:0bba0ef15697 | 671 | #if CHIPBOARD==ATWD4CH |
uci1 | 56:0bba0ef15697 | 672 | if (kIOVers<9) { |
uci1 | 56:0bba0ef15697 | 673 | b = SnBitUtils::WriteTo(b, fStreamHiLoPlas); |
uci1 | 56:0bba0ef15697 | 674 | } |
uci1 | 56:0bba0ef15697 | 675 | #endif |
uci1 | 3:24c5f0f50bf1 | 676 | b = SnBitUtils::WriteTo(b, fWvLoseLSB); |
uci1 | 3:24c5f0f50bf1 | 677 | b = SnBitUtils::WriteTo(b, fWvLoseMSB); |
uci1 | 3:24c5f0f50bf1 | 678 | b = SnBitUtils::WriteTo(b, fWvBaseline); |
uci1 | 3:24c5f0f50bf1 | 679 | b = SnBitUtils::WriteTo(b, fDatPackType); |
uci1 | 3:24c5f0f50bf1 | 680 | const uint16_t* dc = &(fDAC[0][0]); |
uci1 | 56:0bba0ef15697 | 681 | const uint8_t ntotdacs = GetTotDacsForIOVers(kIOVers); |
uci1 | 56:0bba0ef15697 | 682 | for (uint16_t i=0; i<ntotdacs; i++, dc++) { |
uci1 | 3:24c5f0f50bf1 | 683 | b = SnBitUtils::WriteTo(b, *dc); |
uci1 | 3:24c5f0f50bf1 | 684 | } |
uci1 | 56:0bba0ef15697 | 685 | #if CHIPBOARD==ATWD4CH |
uci1 | 56:0bba0ef15697 | 686 | if (kIOVers<9) { |
uci1 | 56:0bba0ef15697 | 687 | b = SnBitUtils::WriteTo(b, fNumPlas); |
uci1 | 56:0bba0ef15697 | 688 | const uint16_t* pl = &(fPLA[0]); |
uci1 | 56:0bba0ef15697 | 689 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 56:0bba0ef15697 | 690 | b = SnBitUtils::WriteTo(b, *pl); |
uci1 | 56:0bba0ef15697 | 691 | } |
uci1 | 3:24c5f0f50bf1 | 692 | } |
uci1 | 56:0bba0ef15697 | 693 | #endif |
uci1 | 3:24c5f0f50bf1 | 694 | b = SnBitUtils::WriteTo(b, fNumCardsMajLog); |
uci1 | 3:24c5f0f50bf1 | 695 | b = SnBitUtils::WriteTo(b, fEnableThermTrig); |
uci1 | 3:24c5f0f50bf1 | 696 | b = SnBitUtils::WriteTo(b, fForceTrigPeriod); |
uci1 | 3:24c5f0f50bf1 | 697 | b = SnBitUtils::WriteTo(b, fHeartBeatPeriod); |
uci1 | 3:24c5f0f50bf1 | 698 | b = SnBitUtils::WriteTo(b, fAmpsOn); |
uci1 | 3:24c5f0f50bf1 | 699 | b = SnBitUtils::WriteTo(b, fEvtThrtlPeriodMs); |
uci1 | 3:24c5f0f50bf1 | 700 | b = SnBitUtils::WriteTo(b, fPowerMode); |
uci1 | 39:2f17131d22a5 | 701 | b = SnBitUtils::WriteTo(b, fBatVoltToLowPwr); |
uci1 | 39:2f17131d22a5 | 702 | b = SnBitUtils::WriteTo(b, fBatVoltFromLowPwr); |
uci1 | 8:95a325df1f6b | 703 | b = SnBitUtils::WriteTo(b, fVoltCheckPeriod); |
uci1 | 3:24c5f0f50bf1 | 704 | b = SnBitUtils::WriteTo(b, fCommWinPeriod); |
uci1 | 3:24c5f0f50bf1 | 705 | b = SnBitUtils::WriteTo(b, fCommWinDuration); |
uci1 | 3:24c5f0f50bf1 | 706 | b = SnBitUtils::WriteTo(b, fCommSendData); |
uci1 | 3:24c5f0f50bf1 | 707 | b = SnBitUtils::WriteTo(b, fCommWinPrdLowPwr); |
uci1 | 3:24c5f0f50bf1 | 708 | b = SnBitUtils::WriteTo(b, fCommWinDurLowPwr); |
uci1 | 40:1324da35afd4 | 709 | b = SnBitUtils::WriteTo(b, fCommWinConnectTOMin); |
uci1 | 40:1324da35afd4 | 710 | b = SnBitUtils::WriteTo(b, fCommWinListenTOMin); |
uci1 | 8:95a325df1f6b | 711 | b = SnBitUtils::WriteTo(b, fRemoteServer, kIPLen); |
uci1 | 8:95a325df1f6b | 712 | b = SnBitUtils::WriteTo(b, fRemotePort); |
uci1 | 8:95a325df1f6b | 713 | b = SnBitUtils::WriteTo(b, fMbedIP, kIPLen); |
uci1 | 8:95a325df1f6b | 714 | b = SnBitUtils::WriteTo(b, fMbedMask, kIPLen); |
uci1 | 8:95a325df1f6b | 715 | b = SnBitUtils::WriteTo(b, fMbedGate, kIPLen); |
uci1 | 3:24c5f0f50bf1 | 716 | b = SnBitUtils::WriteTo(b, fWatchDogPeriod); |
uci1 | 56:0bba0ef15697 | 717 | b = SnBitUtils::WriteTo(b, fTempCheckPeriod); |
uci1 | 56:0bba0ef15697 | 718 | #if CHIPBOARD==ATWD4CH |
uci1 | 56:0bba0ef15697 | 719 | if (kIOVers<9) { |
uci1 | 56:0bba0ef15697 | 720 | if (fStreamHiLoPlas!=0) { |
uci1 | 56:0bba0ef15697 | 721 | const uint16_t* pl = &(fPLA[0]); |
uci1 | 56:0bba0ef15697 | 722 | uint16_t hi, lo; |
uci1 | 56:0bba0ef15697 | 723 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 56:0bba0ef15697 | 724 | GetHiLoPlas(*pl, hi, lo); |
uci1 | 56:0bba0ef15697 | 725 | b = SnBitUtils::WriteTo(b, hi); |
uci1 | 56:0bba0ef15697 | 726 | b = SnBitUtils::WriteTo(b, lo); |
uci1 | 56:0bba0ef15697 | 727 | } |
uci1 | 3:24c5f0f50bf1 | 728 | } |
uci1 | 3:24c5f0f50bf1 | 729 | } |
uci1 | 56:0bba0ef15697 | 730 | #endif |
uci1 | 3:24c5f0f50bf1 | 731 | } |
uci1 | 3:24c5f0f50bf1 | 732 | |
uci1 | 3:24c5f0f50bf1 | 733 | bool ReadFromFile(const char* cfile); |
uci1 | 3:24c5f0f50bf1 | 734 | bool WriteToFile(const char* cfile) const; |
uci1 | 3:24c5f0f50bf1 | 735 | |
uci1 | 3:24c5f0f50bf1 | 736 | void Reset() { |
uci1 | 3:24c5f0f50bf1 | 737 | memset(fLabel, 0, sizeof(char)*kConfLblLen); |
uci1 | 40:1324da35afd4 | 738 | SetHardDefaults(); |
uci1 | 3:24c5f0f50bf1 | 739 | if (ReadFromFile(kDefConfFile)==false) { |
uci1 | 3:24c5f0f50bf1 | 740 | // couldn't get default. use hardcoded version. |
uci1 | 3:24c5f0f50bf1 | 741 | SetHardDefaults(); |
uci1 | 3:24c5f0f50bf1 | 742 | } |
uci1 | 16:744ce85aede2 | 743 | #ifdef DEBUG |
uci1 | 16:744ce85aede2 | 744 | printf("config reset to %s\r\n",fLabel); |
uci1 | 16:744ce85aede2 | 745 | #endif |
uci1 | 3:24c5f0f50bf1 | 746 | } |
uci1 | 40:1324da35afd4 | 747 | |
uci1 | 8:95a325df1f6b | 748 | uint32_t SizeOf(const uint8_t rv) const { |
uci1 | 3:24c5f0f50bf1 | 749 | // returns the num of bytes needed to stream this object |
uci1 | 3:24c5f0f50bf1 | 750 | // = size of member vars + 1 for i/o version + extra PLA strings (maybe) |
uci1 | 3:24c5f0f50bf1 | 751 | // + length of label string |
uci1 | 56:0bba0ef15697 | 752 | #if CHIPBOARD==ATWD4CH |
uci1 | 8:95a325df1f6b | 753 | return SizeOf(rv, fStreamHiLoPlas!=0, fNumPlas, strlen(fLabel)); |
uci1 | 56:0bba0ef15697 | 754 | #else // SST |
uci1 | 56:0bba0ef15697 | 755 | return SizeOf(rv, false, 0, strlen(fLabel)); |
uci1 | 56:0bba0ef15697 | 756 | #endif |
uci1 | 3:24c5f0f50bf1 | 757 | } |
uci1 | 40:1324da35afd4 | 758 | |
uci1 | 3:24c5f0f50bf1 | 759 | static void SetMacAddress(); |
uci1 | 3:24c5f0f50bf1 | 760 | static uint64_t GetMacAddress() { |
uci1 | 3:24c5f0f50bf1 | 761 | if (fgMacAdr==0) { |
uci1 | 3:24c5f0f50bf1 | 762 | SetMacAddress(); |
uci1 | 3:24c5f0f50bf1 | 763 | } |
uci1 | 3:24c5f0f50bf1 | 764 | return fgMacAdr; |
uci1 | 3:24c5f0f50bf1 | 765 | } |
uci1 | 3:24c5f0f50bf1 | 766 | |
uci1 | 3:24c5f0f50bf1 | 767 | static uint32_t GetLabelMaxLen() { return kConfLblLen; } |
uci1 | 3:24c5f0f50bf1 | 768 | |
uci1 | 3:24c5f0f50bf1 | 769 | static void GetHiLoPlas(const uint16_t pla, |
uci1 | 3:24c5f0f50bf1 | 770 | uint16_t& hiPla, |
uci1 | 3:24c5f0f50bf1 | 771 | uint16_t& loPla, |
uci1 | 3:24c5f0f50bf1 | 772 | const bool r2l=false); |
uci1 | 3:24c5f0f50bf1 | 773 | }; |
uci1 | 3:24c5f0f50bf1 | 774 | |
uci1 | 3:24c5f0f50bf1 | 775 | #endif // SN_SnConfigFrame |