Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnConfigFrame.h@84:80b15993944e, 2015-10-30 (annotated)
- Committer:
- uci1
- Date:
- Fri Oct 30 04:49:40 2015 +0000
- Revision:
- 84:80b15993944e
- Parent:
- 76:f8383f0292c2
- Child:
- 85:3ced48ef94c5
conf v11,12. ip to ints. write 64chr lbl. send status data packs. comm pwr as needed. comm each evt. conn/list TO separate afar, sbd. calc FFT, L1 trigger, L1 scaledown. pre-compl opts in own file. max comm fail 75. htbt and clock frames store vars.
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 | 84:80b15993944e | 18 | static const uint8_t kConfLblLenNoStrTerm=63; // length of configuration label char array without the terminating '\0' (must not change!! used in i/o sizes) |
uci1 | 84:80b15993944e | 19 | static const uint8_t kConfLblLen=kConfLblLenNoStrTerm+1; // length of configuration label char array (63+'\0') (must not change!! used in i/o sizes) |
uci1 | 84:80b15993944e | 20 | static const uint8_t kIPLen=16; // length of IP string (includes \0). matches MBED's Socket class (so no ipv6) (must not change!! used in i/o sizes) |
uci1 | 3:24c5f0f50bf1 | 21 | |
uci1 | 67:ec999336fcd1 | 22 | #ifdef USE_INTERFACE_CHIP |
uci1 | 3:24c5f0f50bf1 | 23 | static const char* const kDefConfFile; // default configuration file |
uci1 | 59:21128cc24b04 | 24 | static const char* const kDefRemIpFilen; |
uci1 | 59:21128cc24b04 | 25 | static const char* const kDefRemPortFilen; |
uci1 | 59:21128cc24b04 | 26 | static const char* const kDefMbedIPFilen; |
uci1 | 59:21128cc24b04 | 27 | static const char* const kDefMbedMaskFilen; |
uci1 | 59:21128cc24b04 | 28 | static const char* const kDefMbedGateFilen; |
uci1 | 67:ec999336fcd1 | 29 | #endif |
uci1 | 67:ec999336fcd1 | 30 | |
uci1 | 28:484943132bb0 | 31 | static const char* const kDefIPflag; // flag to use IP default |
uci1 | 84:80b15993944e | 32 | static const uint32_t kDefIPvalue; // value to indicate use of default IP |
uci1 | 3:24c5f0f50bf1 | 33 | |
uci1 | 56:0bba0ef15697 | 34 | // ATWD 4channel configs |
uci1 | 8:95a325df1f6b | 35 | static const uint32_t kMaxSizeOfV1 = |
uci1 | 8:95a325df1f6b | 36 | + (9u*sizeof(uint32_t)) + (6u*sizeof(uint16_t)) |
uci1 | 56:0bba0ef15697 | 37 | + (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 | 38 | + (kTotDacsAtwd4ch*sizeof(uint16_t)) |
uci1 | 3:24c5f0f50bf1 | 39 | + (kConfLblLen*sizeof(uint8_t)); |
uci1 | 8:95a325df1f6b | 40 | static const uint32_t kMaxSizeOfV2 = |
uci1 | 8:95a325df1f6b | 41 | kMaxSizeOfV1 + sizeof(uint32_t) + sizeof(uint8_t); |
uci1 | 8:95a325df1f6b | 42 | static const uint32_t kMaxSizeOfV3 = |
uci1 | 8:95a325df1f6b | 43 | kMaxSizeOfV2 + (2u*sizeof(uint16_t)) + (4u*kIPLen*sizeof(char)); |
uci1 | 40:1324da35afd4 | 44 | static const uint32_t kMaxSizeOfV4 = kMaxSizeOfV3 + (sizeof(float)-sizeof(uint16_t)); // forced trig per to float |
uci1 | 39:2f17131d22a5 | 45 | static const uint32_t kMaxSizeOfV5 = kMaxSizeOfV4; |
uci1 | 40:1324da35afd4 | 46 | static const uint32_t kMaxSizeOfV6 = kMaxSizeOfV5 + sizeof(uint16_t); // To/From Low Power |
uci1 | 40:1324da35afd4 | 47 | static const uint32_t kMaxSizeOfV7 = kMaxSizeOfV6 + (2u*sizeof(uint8_t)); // add ConnTOmins, ListenTOmins |
uci1 | 40:1324da35afd4 | 48 | static const uint32_t kMaxSizeOfV8 = kMaxSizeOfV7 - sizeof(uint32_t) + sizeof(uint16_t); // FirstEvt -> FirstSeq |
uci1 | 56:0bba0ef15697 | 49 | |
uci1 | 56:0bba0ef15697 | 50 | // SST 4channel configs |
uci1 | 56:0bba0ef15697 | 51 | static const uint32_t kMaxSizeOfV9 = kMaxSizeOfV8 |
uci1 | 56:0bba0ef15697 | 52 | - (3u*kNplasV1*sizeof(uint16_t)) // no patterns in SST |
uci1 | 56:0bba0ef15697 | 53 | - (kTotDacsAtwd4ch*sizeof(uint16_t)) |
uci1 | 56:0bba0ef15697 | 54 | + (kTotDacsSst4ch*sizeof(uint16_t)) // switch to number of SST dacs |
uci1 | 56:0bba0ef15697 | 55 | - sizeof(uint8_t) // no stream hi/lo pla flag |
uci1 | 56:0bba0ef15697 | 56 | - sizeof(uint8_t); // no num plas variable |
uci1 | 56:0bba0ef15697 | 57 | static const uint32_t kMaxSizeOfV10 = kMaxSizeOfV9 + sizeof(int8_t); // add fTempCheckPeriod |
uci1 | 84:80b15993944e | 58 | |
uci1 | 84:80b15993944e | 59 | // ATWD - expanding upon V8 (previous ATWD config) |
uci1 | 84:80b15993944e | 60 | static const uint32_t kMaxSizeOfV11 = kMaxSizeOfV8 |
uci1 | 84:80b15993944e | 61 | - sizeof(uint32_t) // label length (now always 64 bytes written) |
uci1 | 84:80b15993944e | 62 | - (sizeof(uint32_t) - sizeof(uint16_t)) // fEvtsPerSeq from uint32_t to uint16_t |
uci1 | 84:80b15993944e | 63 | - sizeof(uint8_t) // remove stream hi/lo pla's (always false now) |
uci1 | 84:80b15993944e | 64 | - sizeof(uint8_t) // remove pack data (always done for all peripherals) |
uci1 | 84:80b15993944e | 65 | - sizeof(uint8_t) // remove amps on completely |
uci1 | 84:80b15993944e | 66 | - (4u*kIPLen) + (4u*sizeof(uint32_t)) // change IP from strings to numbers |
uci1 | 84:80b15993944e | 67 | - (2u*kNplasV1*sizeof(uint16_t)) // no streaming of hi/lo patterns |
uci1 | 84:80b15993944e | 68 | + sizeof(uint8_t) // add single freq ratio L1 trig parameter |
uci1 | 84:80b15993944e | 69 | + sizeof(uint8_t) // L1 scaledown |
uci1 | 84:80b15993944e | 70 | + sizeof(uint16_t) - sizeof(uint8_t) // change fEnableTherm from 8 bit to 16 bit to match trigger bit word in event |
uci1 | 84:80b15993944e | 71 | + (2u*sizeof(uint8_t)) // connect and listen TOs for Irid & Afar |
uci1 | 84:80b15993944e | 72 | + sizeof(uint16_t) - sizeof(uint8_t); // run mode from 8 to 16 bit integer |
uci1 | 84:80b15993944e | 73 | |
uci1 | 84:80b15993944e | 74 | // SST - expanding upon V10 (previous SST config) |
uci1 | 84:80b15993944e | 75 | static const uint32_t kMaxSizeOfV12 = kMaxSizeOfV10 |
uci1 | 84:80b15993944e | 76 | - sizeof(uint32_t) // label length (now always 64 bytes written) |
uci1 | 84:80b15993944e | 77 | - (sizeof(uint32_t) - sizeof(uint16_t)) // fEvtsPerSeq from uint32_t to uint16_t |
uci1 | 84:80b15993944e | 78 | - sizeof(uint8_t) // remove pack data (always done for all peripherals) |
uci1 | 84:80b15993944e | 79 | - sizeof(uint8_t) // remove amps on completely |
uci1 | 84:80b15993944e | 80 | - (4u*kIPLen) + (4u*sizeof(uint32_t)) // change IP from strings to numbers |
uci1 | 84:80b15993944e | 81 | + sizeof(uint8_t) // add single freq ratio L1 trig parameter |
uci1 | 84:80b15993944e | 82 | + sizeof(uint8_t) // L1 scaledown |
uci1 | 84:80b15993944e | 83 | + sizeof(uint16_t) - sizeof(uint8_t) // change fEnableTherm from 8 bit to 16 bit to match trigger bit word in event |
uci1 | 84:80b15993944e | 84 | + (2u*sizeof(uint8_t)) // connect and listen TOs for Irid & Afar |
uci1 | 84:80b15993944e | 85 | + sizeof(uint16_t) - sizeof(uint8_t); // run mode from 8 to 16 bit integer |
uci1 | 56:0bba0ef15697 | 86 | |
uci1 | 56:0bba0ef15697 | 87 | static const uint32_t kMaxSizeOf = kMaxSizeOfV7; // should be the biggest one |
uci1 | 3:24c5f0f50bf1 | 88 | |
uci1 | 3:24c5f0f50bf1 | 89 | enum EDatPackBit { |
uci1 | 3:24c5f0f50bf1 | 90 | kSDcard = BIT(0), |
uci1 | 3:24c5f0f50bf1 | 91 | kIrid = BIT(1), |
uci1 | 3:24c5f0f50bf1 | 92 | kAfar = BIT(2), |
uci1 | 3:24c5f0f50bf1 | 93 | kUSB = BIT(3) |
uci1 | 3:24c5f0f50bf1 | 94 | }; |
uci1 | 84:80b15993944e | 95 | static const uint8_t kNumDatStreams = 4; // ** note: need to change manually |
uci1 | 3:24c5f0f50bf1 | 96 | |
uci1 | 3:24c5f0f50bf1 | 97 | enum ESendDataBit { |
uci1 | 3:24c5f0f50bf1 | 98 | // can't use BIT(0)! (-0 = 0 => send nothing) |
uci1 | 84:80b15993944e | 99 | kAllFiles = BIT(1), // if bit=0 => send most recent file |
uci1 | 84:80b15993944e | 100 | kTimeout = BIT(2), // if bit=0 => ignore timeout |
uci1 | 84:80b15993944e | 101 | kDelete = BIT(3), // if bit=0 => do not delete sent files |
uci1 | 84:80b15993944e | 102 | kForceSBDdata = BIT(4), // if bit=0 => do not send data over SBD |
uci1 | 84:80b15993944e | 103 | kHnShBefSendDat = BIT(5), // if bit=0 => do not wait for a handshake after GetConfig before calling SendData |
uci1 | 84:80b15993944e | 104 | kSendRunSeqList = BIT(6), // if bit=1 and kAllFiles bit=0, send all files in the run/seq list (instead of most recent file) |
uci1 | 84:80b15993944e | 105 | kStatSendConf = BIT(7), // if bit=1, send a config with the status update data |
uci1 | 84:80b15993944e | 106 | kStatSendTrgTim = BIT(8), // if bit=1, send trigger start/stop times with the status update data |
uci1 | 84:80b15993944e | 107 | kStatSendPwrDat = BIT(9), // if bit=1, send the last power frame recorded in data taking mode with the status update |
uci1 | 84:80b15993944e | 108 | kStatSendEvent = BIT(10), // if bit=1, send the last event frame recorded in data taking mode with the status update |
uci1 | 84:80b15993944e | 109 | kStatSendHtbt = BIT(11), // if bit=1, send the last heartbeat frame recorded in data taking mode with the status update |
uci1 | 84:80b15993944e | 110 | kStatSendTmpDat = BIT(12), // if bit=1, send the last temperature frame recorded in data taking mode with the status update |
uci1 | 39:2f17131d22a5 | 111 | kUseBits = static_cast<int16_t>(-BIT(14)) // useful to initialize fCommSendData as a bit word |
uci1 | 3:24c5f0f50bf1 | 112 | }; |
uci1 | 3:24c5f0f50bf1 | 113 | |
uci1 | 4:a91682e19d6b | 114 | enum EPowerModeBit { |
uci1 | 4:a91682e19d6b | 115 | kAmpsDatTak = BIT(0), |
uci1 | 4:a91682e19d6b | 116 | kCardDatTak = BIT(1), |
uci1 | 4:a91682e19d6b | 117 | kIridDatTak = BIT(2), |
uci1 | 4:a91682e19d6b | 118 | kAfarDatTak = BIT(3), |
uci1 | 4:a91682e19d6b | 119 | kAmpsComWin = BIT(4), |
uci1 | 4:a91682e19d6b | 120 | kCardComWin = BIT(5), |
uci1 | 4:a91682e19d6b | 121 | kIridComWin = BIT(6), |
uci1 | 4:a91682e19d6b | 122 | kAfarComWin = BIT(7) |
uci1 | 4:a91682e19d6b | 123 | }; |
uci1 | 4:a91682e19d6b | 124 | |
uci1 | 3:24c5f0f50bf1 | 125 | enum ERunMode { |
uci1 | 8:95a325df1f6b | 126 | kSingleSeqBit = BIT(0), // if 0, infinite sequences |
uci1 | 8:95a325df1f6b | 127 | kCountPowerBit = BIT(1), // if 0, count events |
uci1 | 56:0bba0ef15697 | 128 | kDualThreshBit = BIT(2), // if 0, single sided thresholds on SST |
uci1 | 56:0bba0ef15697 | 129 | kDiffTrigBit = BIT(3), // if 0, send result of each comparator on SST |
uci1 | 56:0bba0ef15697 | 130 | 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 | 76:f8383f0292c2 | 131 | kRSListOneCW = BIT(5), // if 0, only clear run/seq list after files sent from it |
uci1 | 84:80b15993944e | 132 | kIgnoreSDcard = BIT(6), // if 0, read/write data to SD card as normal. if 1, function as though no SD card is present |
uci1 | 84:80b15993944e | 133 | kComPwrSimple = BIT(7), // if 0, comm periphs powered as needed during comm win. if 1, power adjusted once at start/finish of comm win |
uci1 | 84:80b15993944e | 134 | kCommEachEvent = BIT(8) // if 0, comm windows only after comm period of seconds. if 1, comm winodows also after each event that qualifies for saving to SD card |
uci1 | 56:0bba0ef15697 | 135 | }; |
uci1 | 3:24c5f0f50bf1 | 136 | |
uci1 | 3:24c5f0f50bf1 | 137 | // i/o version |
uci1 | 3:24c5f0f50bf1 | 138 | static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes (==> also if kNchans, etc. change!) |
uci1 | 3:24c5f0f50bf1 | 139 | |
uci1 | 3:24c5f0f50bf1 | 140 | private: |
uci1 | 3:24c5f0f50bf1 | 141 | // !! |
uci1 | 3:24c5f0f50bf1 | 142 | // !! If any member variables change, update: SizeOf function and kIOVers value! (also if kNchans, etc. change!) |
uci1 | 3:24c5f0f50bf1 | 143 | // !! |
uci1 | 3:24c5f0f50bf1 | 144 | |
uci1 | 3:24c5f0f50bf1 | 145 | // mbed mac address |
uci1 | 3:24c5f0f50bf1 | 146 | static uint64_t fgMacAdr; // mbed mac address |
uci1 | 3:24c5f0f50bf1 | 147 | // conf header |
uci1 | 3:24c5f0f50bf1 | 148 | char fLabel[kConfLblLen]; // configuration label |
uci1 | 3:24c5f0f50bf1 | 149 | uint32_t fConfTime; // cpu config time |
uci1 | 3:24c5f0f50bf1 | 150 | uint32_t fRun; // run number |
uci1 | 40:1324da35afd4 | 151 | uint16_t fFirstSeq; // starting sequence number |
uci1 | 84:80b15993944e | 152 | uint16_t fEvtsPerSeq; // number of events per file |
uci1 | 84:80b15993944e | 153 | uint16_t fRunMode; // mode of running (see ERunMode) -- changed from uint8 to uint16 with V11+ |
uci1 | 56:0bba0ef15697 | 154 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 155 | // in newer versions (11+), this is always false |
uci1 | 3:24c5f0f50bf1 | 156 | uint8_t fStreamHiLoPlas; // (1byte bool) if true, add the separated hi/lo thresh PLA patterns to the i/o |
uci1 | 56:0bba0ef15697 | 157 | #endif |
uci1 | 3:24c5f0f50bf1 | 158 | // data packing |
uci1 | 3:24c5f0f50bf1 | 159 | uint8_t fWvLoseLSB; // number of least significant bits to lose when packing waveform data |
uci1 | 3:24c5f0f50bf1 | 160 | uint8_t fWvLoseMSB; // number of most significant bits to lose when packing waveform data |
uci1 | 3:24c5f0f50bf1 | 161 | uint16_t fWvBaseline; // global baseline to use when packing data (useful to reduce clipping on the high end) |
uci1 | 84:80b15993944e | 162 | 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). starting with IOVers 11+, this is always all 1's and is not settable |
uci1 | 3:24c5f0f50bf1 | 163 | // trigger setup |
uci1 | 56:0bba0ef15697 | 164 | uint16_t fDAC[kNchans][kNchanDacs]; //[card id][dac id] values should be 0-4095 here (not checked tho) |
uci1 | 56:0bba0ef15697 | 165 | #if CHIPBOARD==ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 166 | uint8_t fNumPlas; // number of patterns to use. must be <= kNplas. |
uci1 | 3:24c5f0f50bf1 | 167 | uint16_t fPLA[kNplas]; //[pattern id] (same for each card) |
uci1 | 56:0bba0ef15697 | 168 | #endif |
uci1 | 3:24c5f0f50bf1 | 169 | uint8_t fNumCardsMajLog; // number of cards participating in the MajLogic trigger (1 to 4) |
uci1 | 84:80b15993944e | 170 | uint16_t fEnableThermTrig; // whether or not to allow thermal triggers. as of vers 11+, now a bit word that can enable L1 triggers in addition to in-chip triggers. that means it now must be the same size as the trigger bit word in the event! |
uci1 | 18:55f1581f2ee4 | 171 | float fForceTrigPeriod; // number of seconds between force triggers (0=none) |
uci1 | 3:24c5f0f50bf1 | 172 | uint16_t fHeartBeatPeriod; // number of seconds between heartbeats (0=none) |
uci1 | 84:80b15993944e | 173 | //uint8_t fAmpsOn; // which amps are on (bit word. uint8_t => 8 amps max). removed vers 11+, as it cannot be implemented. |
uci1 | 3:24c5f0f50bf1 | 174 | uint16_t fEvtThrtlPeriodMs; // throttle period to write events (ms) |
uci1 | 3:24c5f0f50bf1 | 175 | // power |
uci1 | 4:a91682e19d6b | 176 | uint8_t fPowerMode; // power mode bit word: see EPowerModeBit |
uci1 | 40:1324da35afd4 | 177 | uint16_t fBatVoltToLowPwr; // battery level at which to switch to low power (not used?) |
uci1 | 40:1324da35afd4 | 178 | uint16_t fBatVoltFromLowPwr; // battery level at which to switch back from low power (not used?) |
uci1 | 8:95a325df1f6b | 179 | uint16_t fVoltCheckPeriod; // how often to check the voltages (s) |
uci1 | 3:24c5f0f50bf1 | 180 | // communication |
uci1 | 3:24c5f0f50bf1 | 181 | uint32_t fCommWinPeriod; // seconds between communication window startup (0=always on) |
uci1 | 3:24c5f0f50bf1 | 182 | uint32_t fCommWinDuration; // seconds that communication window stays open (0=always open) |
uci1 | 3:24c5f0f50bf1 | 183 | 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 | 184 | uint32_t fCommWinPrdLowPwr; // low power communication window period (seconds) (range enforced) |
uci1 | 3:24c5f0f50bf1 | 185 | uint32_t fCommWinDurLowPwr; // low power communication window duration (seconds) (range enforced) |
uci1 | 84:80b15993944e | 186 | uint8_t fCommWinConnTOMins[kNumDatStreams]; // comm win connection timeout (minutes) for each data stream (range enforced) |
uci1 | 84:80b15993944e | 187 | uint8_t fCommWinListTOMins[kNumDatStreams]; // comm win listening timeout (minutes) for each data stream (range enforced) |
uci1 | 8:95a325df1f6b | 188 | char fRemoteServer[kIPLen]; // IP address of remote server (for afar) |
uci1 | 8:95a325df1f6b | 189 | uint16_t fRemotePort; // port number of remote server (for afar) |
uci1 | 8:95a325df1f6b | 190 | char fMbedIP[kIPLen]; // IP address of this mbed |
uci1 | 8:95a325df1f6b | 191 | char fMbedMask[kIPLen]; // IP address of this mbed mask |
uci1 | 8:95a325df1f6b | 192 | char fMbedGate[kIPLen]; // IP address of this mbed gateway |
uci1 | 3:24c5f0f50bf1 | 193 | // watchdog |
uci1 | 3:24c5f0f50bf1 | 194 | uint32_t fWatchDogPeriod; // number of seconds of inactivity for watchdog to issue a reset |
uci1 | 84:80b15993944e | 195 | #if CHIPBOARD==SST4CH |
uci1 | 56:0bba0ef15697 | 196 | // temp |
uci1 | 56:0bba0ef15697 | 197 | int8_t fTempCheckPeriod; // number of minutes between temperature checks. if negative, uses parasite power. if 0, never check. |
uci1 | 84:80b15993944e | 198 | #endif |
uci1 | 84:80b15993944e | 199 | // vers 11+ below |
uci1 | 84:80b15993944e | 200 | uint8_t fSnglFreqRatio; // single frequency L1 trigger parameter = max / (tot - max). [0,255] => [0.0, 1.0] |
uci1 | 84:80b15993944e | 201 | uint8_t fL1Scaledown; // save an L1 fail event every fL1Scaledown |
uci1 | 3:24c5f0f50bf1 | 202 | |
uci1 | 8:95a325df1f6b | 203 | // in case of low power, store regular settings |
uci1 | 8:95a325df1f6b | 204 | // these are not sent over i/o or stored in the file |
uci1 | 8:95a325df1f6b | 205 | // so they are not included in SizeOf |
uci1 | 8:95a325df1f6b | 206 | bool fIsLowPower; |
uci1 | 8:95a325df1f6b | 207 | char fNormLabel[kConfLblLen]; |
uci1 | 8:95a325df1f6b | 208 | uint8_t fNormPowerMode; |
uci1 | 8:95a325df1f6b | 209 | |
uci1 | 3:24c5f0f50bf1 | 210 | void SetHardDefaults(); |
uci1 | 76:f8383f0292c2 | 211 | |
uci1 | 76:f8383f0292c2 | 212 | static |
uci1 | 76:f8383f0292c2 | 213 | void SetSDNeedToInitFlag(); |
uci1 | 76:f8383f0292c2 | 214 | |
uci1 | 3:24c5f0f50bf1 | 215 | static |
uci1 | 84:80b15993944e | 216 | bool IsIOversForATWD(const uint8_t rv) { |
uci1 | 84:80b15993944e | 217 | return ( (rv<9) || (rv==11) ); |
uci1 | 84:80b15993944e | 218 | } |
uci1 | 84:80b15993944e | 219 | |
uci1 | 84:80b15993944e | 220 | static |
uci1 | 56:0bba0ef15697 | 221 | uint16_t GetTotDacsForIOVers(const uint8_t rv) { |
uci1 | 84:80b15993944e | 222 | if ( IsIOversForATWD(rv) ) { |
uci1 | 56:0bba0ef15697 | 223 | return kTotDacsAtwd4ch; |
uci1 | 56:0bba0ef15697 | 224 | } else { |
uci1 | 56:0bba0ef15697 | 225 | return kTotDacsSst4ch; |
uci1 | 56:0bba0ef15697 | 226 | } |
uci1 | 56:0bba0ef15697 | 227 | } |
uci1 | 56:0bba0ef15697 | 228 | |
uci1 | 56:0bba0ef15697 | 229 | static |
uci1 | 56:0bba0ef15697 | 230 | uint16_t GetMaxPlasForIOVers(const uint8_t rv) { |
uci1 | 84:80b15993944e | 231 | if ( IsIOversForATWD(rv) ) { |
uci1 | 56:0bba0ef15697 | 232 | return kNplasV1; |
uci1 | 56:0bba0ef15697 | 233 | } else { |
uci1 | 56:0bba0ef15697 | 234 | return 0; |
uci1 | 56:0bba0ef15697 | 235 | } |
uci1 | 56:0bba0ef15697 | 236 | } |
uci1 | 84:80b15993944e | 237 | |
uci1 | 84:80b15993944e | 238 | |
uci1 | 56:0bba0ef15697 | 239 | static |
uci1 | 8:95a325df1f6b | 240 | uint32_t SizeOf(const uint8_t rv, |
uci1 | 8:95a325df1f6b | 241 | const bool streamHiLoPlas, |
uci1 | 3:24c5f0f50bf1 | 242 | const uint8_t nplas, |
uci1 | 3:24c5f0f50bf1 | 243 | const uint8_t lblLen) { |
uci1 | 3:24c5f0f50bf1 | 244 | // private because it cannot be used to read from a buffer |
uci1 | 3:24c5f0f50bf1 | 245 | // (the label length and fStreamHiLoPlas are not known a priori) |
uci1 | 3:24c5f0f50bf1 | 246 | // returns the num of bytes needed to stream this object |
uci1 | 3:24c5f0f50bf1 | 247 | // = size of member vars + 1 for i/o version + extra PLA strings (maybe) |
uci1 | 8:95a325df1f6b | 248 | uint32_t maxsize = kMaxSizeOf; |
uci1 | 8:95a325df1f6b | 249 | if (rv==1) { |
uci1 | 8:95a325df1f6b | 250 | maxsize = kMaxSizeOfV1; |
uci1 | 8:95a325df1f6b | 251 | } else if (rv==2) { |
uci1 | 8:95a325df1f6b | 252 | maxsize = kMaxSizeOfV2; |
uci1 | 19:74155d652c37 | 253 | } else if (rv==3) { |
uci1 | 19:74155d652c37 | 254 | maxsize = kMaxSizeOfV3; |
uci1 | 39:2f17131d22a5 | 255 | } else if (rv==4) { |
uci1 | 39:2f17131d22a5 | 256 | maxsize = kMaxSizeOfV4; |
uci1 | 39:2f17131d22a5 | 257 | } else if (rv==5) { |
uci1 | 39:2f17131d22a5 | 258 | maxsize = kMaxSizeOfV5; |
uci1 | 39:2f17131d22a5 | 259 | } else if (rv==6) { |
uci1 | 40:1324da35afd4 | 260 | maxsize = kMaxSizeOfV6; |
uci1 | 40:1324da35afd4 | 261 | } else if (rv==7) { |
uci1 | 40:1324da35afd4 | 262 | maxsize = kMaxSizeOfV7; |
uci1 | 40:1324da35afd4 | 263 | } else if (rv==8) { |
uci1 | 40:1324da35afd4 | 264 | maxsize = kMaxSizeOfV8; |
uci1 | 56:0bba0ef15697 | 265 | } else if (rv==9) { |
uci1 | 56:0bba0ef15697 | 266 | maxsize = kMaxSizeOfV9; |
uci1 | 56:0bba0ef15697 | 267 | } else if (rv==10) { |
uci1 | 56:0bba0ef15697 | 268 | maxsize = kMaxSizeOfV10; |
uci1 | 84:80b15993944e | 269 | } else if (rv==11) { |
uci1 | 84:80b15993944e | 270 | maxsize = kMaxSizeOfV11; |
uci1 | 84:80b15993944e | 271 | } else if (rv==12) { |
uci1 | 84:80b15993944e | 272 | maxsize = kMaxSizeOfV12; |
uci1 | 8:95a325df1f6b | 273 | } |
uci1 | 84:80b15993944e | 274 | uint32_t sz = maxsize; |
uci1 | 84:80b15993944e | 275 | if (rv<11) { |
uci1 | 84:80b15993944e | 276 | const int32_t lbldiff = kConfLblLen - lblLen; |
uci1 | 84:80b15993944e | 277 | sz = maxsize - lbldiff; |
uci1 | 84:80b15993944e | 278 | if ((lbldiff!=0) && (rv>=4)) { |
uci1 | 84:80b15993944e | 279 | sz += 1; // the \0 at the end of the string |
uci1 | 84:80b15993944e | 280 | } |
uci1 | 39:2f17131d22a5 | 281 | } |
uci1 | 84:80b15993944e | 282 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 283 | if ( IsIOversForATWD(rv) ) { |
uci1 | 84:80b15993944e | 284 | // streaming hi/lo plas separately? |
uci1 | 84:80b15993944e | 285 | const uint8_t fac = (streamHiLoPlas && (rv<11)) ? 3u : 1u; |
uci1 | 84:80b15993944e | 286 | const int32_t nplasNotSent = GetMaxPlasForIOVers(rv) - nplas; |
uci1 | 84:80b15993944e | 287 | sz -= (fac*nplasNotSent); |
uci1 | 56:0bba0ef15697 | 288 | |
uci1 | 84:80b15993944e | 289 | /* |
uci1 | 56:0bba0ef15697 | 290 | const uint32_t mhlp = 2u*GetMaxPlasForIOVers(rv)*sizeof(uint16_t); |
uci1 | 56:0bba0ef15697 | 291 | const int32_t dp = (nplas-GetMaxPlasForIOVers(rv))*sizeof(uint16_t); |
uci1 | 84:80b15993944e | 292 | const uint8_t fac = (streamHiLoPlas && (rv<11)) ? 3u : 1u; |
uci1 | 56:0bba0ef15697 | 293 | sz += (fac*dp); |
uci1 | 84:80b15993944e | 294 | if ((streamHiLoPlas==false) || (rv>=11)) { |
uci1 | 84:80b15993944e | 295 | sz -= mhlp; // should be * (maxPlas - nplas), right? |
uci1 | 56:0bba0ef15697 | 296 | } |
uci1 | 84:80b15993944e | 297 | */ |
uci1 | 3:24c5f0f50bf1 | 298 | } |
uci1 | 56:0bba0ef15697 | 299 | #endif |
uci1 | 3:24c5f0f50bf1 | 300 | return sz; |
uci1 | 3:24c5f0f50bf1 | 301 | } |
uci1 | 28:484943132bb0 | 302 | |
uci1 | 67:ec999336fcd1 | 303 | #ifdef USE_INTERFACE_CHIP |
uci1 | 59:21128cc24b04 | 304 | bool ReadOneIPFrom(const char* ipfname, char* ipstr); |
uci1 | 67:ec999336fcd1 | 305 | #endif |
uci1 | 59:21128cc24b04 | 306 | bool ReadDefaultRemoteServer(); |
uci1 | 59:21128cc24b04 | 307 | bool ReadDefaultRemotePort(); |
uci1 | 59:21128cc24b04 | 308 | bool ReadDefaultMbedIP(); |
uci1 | 59:21128cc24b04 | 309 | bool ReadDefaultMbedMask(); |
uci1 | 59:21128cc24b04 | 310 | bool ReadDefaultMbedGate(); |
uci1 | 28:484943132bb0 | 311 | void SetDefaultIPs(); |
uci1 | 28:484943132bb0 | 312 | void SetDefaultRemoteServ(); |
uci1 | 28:484943132bb0 | 313 | void SetDefaultRemotePort(); |
uci1 | 28:484943132bb0 | 314 | void SetDefaultMbedIP(); |
uci1 | 28:484943132bb0 | 315 | void SetDefaultMaskIP(); |
uci1 | 28:484943132bb0 | 316 | void SetDefaultGateIP(); |
uci1 | 28:484943132bb0 | 317 | void ApplySafetyNets(); |
uci1 | 84:80b15993944e | 318 | void ApplyConnectListenSafetyNets(const uint8_t dataStreamIdx); |
uci1 | 28:484943132bb0 | 319 | |
uci1 | 3:24c5f0f50bf1 | 320 | public: |
uci1 | 31:b5bd3b189150 | 321 | SnConfigFrame(const bool applySafety=true) : fIsLowPower(false) { |
uci1 | 84:80b15993944e | 322 | memset(fLabel, 0, kConfLblLen); |
uci1 | 31:b5bd3b189150 | 323 | fgApplySafetyNets = applySafety; |
uci1 | 31:b5bd3b189150 | 324 | Reset(); |
uci1 | 31:b5bd3b189150 | 325 | } |
uci1 | 3:24c5f0f50bf1 | 326 | virtual ~SnConfigFrame() {} |
uci1 | 40:1324da35afd4 | 327 | |
uci1 | 40:1324da35afd4 | 328 | void ApplyConnectListenSafetyNets(); |
uci1 | 3:24c5f0f50bf1 | 329 | |
uci1 | 8:95a325df1f6b | 330 | bool IsCountingPowerReadings() const { return ((fRunMode & kCountPowerBit)!=0); } |
uci1 | 8:95a325df1f6b | 331 | bool IsSingleSeqRunMode() const { return ((fRunMode & kSingleSeqBit)!=0); } |
uci1 | 56:0bba0ef15697 | 332 | bool IsDualThresholdMode() const { return ((fRunMode & kDualThreshBit)!=0); } |
uci1 | 56:0bba0ef15697 | 333 | bool IsDifferentialTrigMode() const { return ((fRunMode & kDiffTrigBit)!=0); } |
uci1 | 56:0bba0ef15697 | 334 | bool IsSBDonlyLowPwrMode() const { return ((fRunMode & kLowPwrSBDonly)!=0); } |
uci1 | 56:0bba0ef15697 | 335 | bool IsRunSeqListOneCommWinOnly() const { return ((fRunMode & kRSListOneCW)!=0); } |
uci1 | 76:f8383f0292c2 | 336 | bool IsIgnoringSDcard() const { return ((fRunMode & kIgnoreSDcard)!=0); } |
uci1 | 84:80b15993944e | 337 | bool IsCommPowerSimple() const { return ((fRunMode & kComPwrSimple)!=0); } |
uci1 | 84:80b15993944e | 338 | bool IsCommWindowEachEvent() const { return ((fRunMode & kCommEachEvent)!=0); } |
uci1 | 8:95a325df1f6b | 339 | bool IsLowPowerMode() const { return fIsLowPower; } |
uci1 | 3:24c5f0f50bf1 | 340 | const char* GetLabel() const { return fLabel; } |
uci1 | 3:24c5f0f50bf1 | 341 | uint32_t GetLabelStrLen() const { return strlen(fLabel); } |
uci1 | 3:24c5f0f50bf1 | 342 | uint32_t GetRun() const { return fRun; } |
uci1 | 40:1324da35afd4 | 343 | uint16_t GetFirstSeq() const { return fFirstSeq; } |
uci1 | 84:80b15993944e | 344 | uint16_t GetEvtsPerFile() const { return fEvtsPerSeq; } |
uci1 | 56:0bba0ef15697 | 345 | inline |
uci1 | 3:24c5f0f50bf1 | 346 | uint16_t GetEvtThrtlPeriodMs() const { return fEvtThrtlPeriodMs; } |
uci1 | 18:55f1581f2ee4 | 347 | float GetForceTrigPeriod() const { return fForceTrigPeriod; } |
uci1 | 3:24c5f0f50bf1 | 348 | uint16_t GetHeartbeatPeriod() const { return fHeartBeatPeriod; } |
uci1 | 39:2f17131d22a5 | 349 | uint16_t GetBatVoltToLowPwr() const { return fBatVoltToLowPwr; } |
uci1 | 39:2f17131d22a5 | 350 | uint16_t GetBatVoltFromLowPwr() const { return fBatVoltFromLowPwr; } |
uci1 | 8:95a325df1f6b | 351 | uint16_t GetVoltCheckPeriod() const { return fVoltCheckPeriod; } |
uci1 | 3:24c5f0f50bf1 | 352 | uint32_t GetWatchdogPeriod() const { return fWatchDogPeriod; } |
uci1 | 84:80b15993944e | 353 | #if CHIPBOARD==SST4CH |
uci1 | 56:0bba0ef15697 | 354 | uint16_t GetTempCheckPeriod() const { |
uci1 | 56:0bba0ef15697 | 355 | const uint16_t t = (fTempCheckPeriod<0) ? (-fTempCheckPeriod) : fTempCheckPeriod; |
uci1 | 56:0bba0ef15697 | 356 | return t*60; |
uci1 | 56:0bba0ef15697 | 357 | } |
uci1 | 56:0bba0ef15697 | 358 | bool IsTempUsingParasitePower() const { return (fTempCheckPeriod<0); } |
uci1 | 84:80b15993944e | 359 | #else |
uci1 | 84:80b15993944e | 360 | uint16_t GetTempCheckPeriod() const { return 0; } |
uci1 | 84:80b15993944e | 361 | #endif |
uci1 | 84:80b15993944e | 362 | uint8_t GetSingleFreqSuppRatioRaw() const { return fSnglFreqRatio; } |
uci1 | 84:80b15993944e | 363 | inline |
uci1 | 84:80b15993944e | 364 | float GetSingleFreqSuppRatio() const { return static_cast<float>(fSnglFreqRatio) / 255.0f; } |
uci1 | 3:24c5f0f50bf1 | 365 | uint16_t GetDac(const uint8_t ch, const uint8_t dn) const { return fDAC[ch][dn]; } |
uci1 | 56:0bba0ef15697 | 366 | #if CHIPBOARD==ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 367 | uint8_t GetNumPlas() const { return fNumPlas; } |
uci1 | 3:24c5f0f50bf1 | 368 | uint16_t GetPla(const uint8_t pn) const { return fPLA[pn]; } |
uci1 | 56:0bba0ef15697 | 369 | #endif |
uci1 | 3:24c5f0f50bf1 | 370 | uint8_t GetNumCardsMajLog() const { return fNumCardsMajLog; } |
uci1 | 84:80b15993944e | 371 | // bool IsThermTrigEnabled() const { return fEnableThermTrig!=0; } |
uci1 | 84:80b15993944e | 372 | uint8_t GetL1Scaledown() const { return fL1Scaledown; } |
uci1 | 84:80b15993944e | 373 | bool IsThermTrigEnabled() const |
uci1 | 84:80b15993944e | 374 | { return (fEnableThermTrig & kThermal)!=0; } |
uci1 | 84:80b15993944e | 375 | bool IsSingleFreqSuppEnabled() const |
uci1 | 84:80b15993944e | 376 | { return (fEnableThermTrig & kSingleFreqSupp)!=0; } |
uci1 | 84:80b15993944e | 377 | bool IsL1TrigApplied() const |
uci1 | 84:80b15993944e | 378 | { return (fEnableThermTrig & kL1TrgApplied)!=0; } |
uci1 | 84:80b15993944e | 379 | /* |
uci1 | 3:24c5f0f50bf1 | 380 | bool IsEachAmpOn() const { |
uci1 | 3:24c5f0f50bf1 | 381 | bool allon=true; |
uci1 | 3:24c5f0f50bf1 | 382 | for (uint8_t i=0; (i<kNchans) && allon; i++) { |
uci1 | 3:24c5f0f50bf1 | 383 | allon = (fAmpsOn & BIT(i))!=0; |
uci1 | 3:24c5f0f50bf1 | 384 | } |
uci1 | 3:24c5f0f50bf1 | 385 | return allon; |
uci1 | 3:24c5f0f50bf1 | 386 | } |
uci1 | 3:24c5f0f50bf1 | 387 | // TODO: allow check for individual amps, when they can be turned on individually |
uci1 | 84:80b15993944e | 388 | */ |
uci1 | 8:95a325df1f6b | 389 | const char* GetRemoteServer() const { return fRemoteServer; } |
uci1 | 8:95a325df1f6b | 390 | uint16_t GetRemotePort() const { return fRemotePort; } |
uci1 | 8:95a325df1f6b | 391 | const char* GetMbedIP() const { return fMbedIP; } |
uci1 | 8:95a325df1f6b | 392 | const char* GetMbedMask() const { return fMbedMask; } |
uci1 | 8:95a325df1f6b | 393 | const char* GetMbedGate() const { return fMbedGate; } |
uci1 | 8:95a325df1f6b | 394 | uint32_t GetCommWinPeriod() const { return fIsLowPower ? fCommWinPrdLowPwr : fCommWinPeriod; } |
uci1 | 8:95a325df1f6b | 395 | uint32_t GetCommWinDuration() const { return fIsLowPower ? fCommWinDurLowPwr : fCommWinDuration; } |
uci1 | 84:80b15993944e | 396 | uint32_t GetCommWinConnectTOofIdx(const uint8_t idx) const { |
uci1 | 84:80b15993944e | 397 | return (static_cast<uint32_t>( fCommWinConnTOMins[idx] ) * 60u); |
uci1 | 84:80b15993944e | 398 | } |
uci1 | 84:80b15993944e | 399 | uint32_t GetCommWinConnectTO(const SnConfigFrame::EDatPackBit b) const { |
uci1 | 84:80b15993944e | 400 | return GetCommWinConnectTOofIdx(IndexOfDataStream(b)); |
uci1 | 84:80b15993944e | 401 | } |
uci1 | 84:80b15993944e | 402 | uint32_t GetCommWinListenTOofIdx(const uint8_t idx) const { |
uci1 | 84:80b15993944e | 403 | return (static_cast<uint32_t>( fCommWinListTOMins[idx] ) * 60u); |
uci1 | 84:80b15993944e | 404 | } |
uci1 | 84:80b15993944e | 405 | uint32_t GetCommWinListenTO(const SnConfigFrame::EDatPackBit b) const { |
uci1 | 84:80b15993944e | 406 | return GetCommWinListenTOofIdx(IndexOfDataStream(b)); |
uci1 | 84:80b15993944e | 407 | } |
uci1 | 3:24c5f0f50bf1 | 408 | int16_t GetCommSendData() const { return fCommSendData; } |
uci1 | 3:24c5f0f50bf1 | 409 | |
uci1 | 3:24c5f0f50bf1 | 410 | bool IsSendingAllFiles() const |
uci1 | 3:24c5f0f50bf1 | 411 | { return (fCommSendData<0) && ((fCommSendData & kAllFiles)!=0); } |
uci1 | 3:24c5f0f50bf1 | 412 | bool IsObeyingTimeout() const |
uci1 | 3:24c5f0f50bf1 | 413 | { return (fCommSendData<0) && ((fCommSendData & kTimeout)!=0); } |
uci1 | 3:24c5f0f50bf1 | 414 | bool IsDeletingFiles() const |
uci1 | 3:24c5f0f50bf1 | 415 | { return (fCommSendData<0) && ((fCommSendData & kDelete)!=0); } |
uci1 | 15:f2569d8e4176 | 416 | bool IsForcingSBDdata() const |
uci1 | 15:f2569d8e4176 | 417 | { return (fCommSendData<0) && ((fCommSendData & kForceSBDdata)!=0); } |
uci1 | 40:1324da35afd4 | 418 | bool IsWaitingHndShkBeforeSendData() const |
uci1 | 40:1324da35afd4 | 419 | { return (fCommSendData<0) && ((fCommSendData & kHnShBefSendDat)!=0); } |
uci1 | 56:0bba0ef15697 | 420 | bool IsSendingFilesRunSeqList() const |
uci1 | 56:0bba0ef15697 | 421 | { return (fCommSendData<0) && ((fCommSendData & kSendRunSeqList)!=0); } |
uci1 | 84:80b15993944e | 422 | bool IsStatusSendingConfig() const |
uci1 | 84:80b15993944e | 423 | { return (fCommSendData<0) && ((fCommSendData & kStatSendConf)!=0); } |
uci1 | 84:80b15993944e | 424 | bool IsStatusSendingTrigTimes() const |
uci1 | 84:80b15993944e | 425 | { return (fCommSendData<0) && ((fCommSendData & kStatSendTrgTim)!=0); } |
uci1 | 84:80b15993944e | 426 | bool IsStatusSendingPowerReading() const |
uci1 | 84:80b15993944e | 427 | { return (fCommSendData<0) && ((fCommSendData & kStatSendPwrDat)!=0); } |
uci1 | 84:80b15993944e | 428 | bool IsStatusSendingEvent() const |
uci1 | 84:80b15993944e | 429 | { return (fCommSendData<0) && ((fCommSendData & kStatSendEvent)!=0); } |
uci1 | 84:80b15993944e | 430 | bool IsStatusSendingHeartbeat() const |
uci1 | 84:80b15993944e | 431 | { return (fCommSendData<0) && ((fCommSendData & kStatSendHtbt)!=0); } |
uci1 | 84:80b15993944e | 432 | bool IsStatusSendingTemperature() const |
uci1 | 84:80b15993944e | 433 | { return (fCommSendData<0) && ((fCommSendData & kStatSendTmpDat)!=0); } |
uci1 | 3:24c5f0f50bf1 | 434 | |
uci1 | 4:a91682e19d6b | 435 | uint8_t GetPowerMode() const { return fPowerMode; } |
uci1 | 30:f869ed4bcc08 | 436 | int GetPowPinSetting(const EPowerModeBit p, const bool isOn) const { |
uci1 | 56:0bba0ef15697 | 437 | #if CHIPBOARD==ATWD4CH |
uci1 | 5:9cea89700c66 | 438 | if (p==kCardDatTak || p==kCardComWin || |
uci1 | 5:9cea89700c66 | 439 | p==kAmpsDatTak || p==kAmpsComWin) { |
uci1 | 30:f869ed4bcc08 | 440 | return isOn ? 0 : 1; |
uci1 | 5:9cea89700c66 | 441 | } else { |
uci1 | 30:f869ed4bcc08 | 442 | return isOn ? 1 : 0; |
uci1 | 5:9cea89700c66 | 443 | } |
uci1 | 56:0bba0ef15697 | 444 | #else |
uci1 | 56:0bba0ef15697 | 445 | return isOn ? 1 : 0; |
uci1 | 56:0bba0ef15697 | 446 | #endif |
uci1 | 5:9cea89700c66 | 447 | } |
uci1 | 30:f869ed4bcc08 | 448 | int GetPowPinSetting(const EPowerModeBit p) const { |
uci1 | 30:f869ed4bcc08 | 449 | // return int to correspond to what DigitalOut::operator= expects |
uci1 | 30:f869ed4bcc08 | 450 | return GetPowPinSetting(p, IsPoweredFor(p)); |
uci1 | 30:f869ed4bcc08 | 451 | } |
uci1 | 8:95a325df1f6b | 452 | bool IsPoweredFor(const EPowerModeBit p) const { |
uci1 | 8:95a325df1f6b | 453 | return ((fPowerMode & p)!=0); |
uci1 | 8:95a325df1f6b | 454 | } |
uci1 | 8:95a325df1f6b | 455 | |
uci1 | 8:95a325df1f6b | 456 | void EnablePowerFor(const EPowerModeBit p) { fPowerMode |= p; } |
uci1 | 8:95a325df1f6b | 457 | void DisablePowerFor(const EPowerModeBit p) { fPowerMode &= ~p; } |
uci1 | 8:95a325df1f6b | 458 | |
uci1 | 8:95a325df1f6b | 459 | void ChangeToLowPower(); |
uci1 | 8:95a325df1f6b | 460 | void ChangeToNormPower(); |
uci1 | 3:24c5f0f50bf1 | 461 | |
uci1 | 3:24c5f0f50bf1 | 462 | const char* GetOutFileName(const char* dir) const; |
uci1 | 3:24c5f0f50bf1 | 463 | |
uci1 | 21:ce51bb0ba4a5 | 464 | uint32_t GetTimeoutTime(const uint32_t startTime, |
uci1 | 21:ce51bb0ba4a5 | 465 | const uint32_t delta) const; |
uci1 | 21:ce51bb0ba4a5 | 466 | |
uci1 | 21:ce51bb0ba4a5 | 467 | |
uci1 | 3:24c5f0f50bf1 | 468 | // waveform packing info |
uci1 | 3:24c5f0f50bf1 | 469 | uint16_t GetWvBaseline() const { return fWvBaseline; } |
uci1 | 3:24c5f0f50bf1 | 470 | uint8_t GetWvLoseLSB() const { return fWvLoseLSB; } |
uci1 | 3:24c5f0f50bf1 | 471 | uint8_t GetWvLoseMSB() const { return fWvLoseMSB; } |
uci1 | 3:24c5f0f50bf1 | 472 | bool IsDatPackedFor(const EDatPackBit d) const { return (fDatPackType & d)!=0; } |
uci1 | 3:24c5f0f50bf1 | 473 | void GetPackParsFor(const EDatPackBit d, |
uci1 | 3:24c5f0f50bf1 | 474 | uint8_t& loseLSB, uint8_t& loseMSB, |
uci1 | 3:24c5f0f50bf1 | 475 | uint16_t& wvBase) const; |
uci1 | 3:24c5f0f50bf1 | 476 | |
uci1 | 3:24c5f0f50bf1 | 477 | // i/o |
uci1 | 40:1324da35afd4 | 478 | static |
uci1 | 40:1324da35afd4 | 479 | bool IsIOversionOk(const uint8_t rv) { |
uci1 | 40:1324da35afd4 | 480 | return (kIOVers == rv); |
uci1 | 40:1324da35afd4 | 481 | } |
uci1 | 40:1324da35afd4 | 482 | |
uci1 | 40:1324da35afd4 | 483 | template<class T> |
uci1 | 40:1324da35afd4 | 484 | static |
uci1 | 40:1324da35afd4 | 485 | uint8_t PeekIOversion(T& b) { |
uci1 | 40:1324da35afd4 | 486 | // the buffer/file/whatever 'b' must be at the start of the config frame |
uci1 | 40:1324da35afd4 | 487 | uint8_t Rv=0; |
uci1 | 40:1324da35afd4 | 488 | SnBitUtils::ReadFrom(b, Rv); |
uci1 | 40:1324da35afd4 | 489 | return Rv; |
uci1 | 40:1324da35afd4 | 490 | } |
uci1 | 40:1324da35afd4 | 491 | |
uci1 | 3:24c5f0f50bf1 | 492 | template<class T> |
uci1 | 3:24c5f0f50bf1 | 493 | void ReadFrom(T& b) { |
uci1 | 3:24c5f0f50bf1 | 494 | // no check on the length of buf is done here |
uci1 | 3:24c5f0f50bf1 | 495 | // that should be been done already |
uci1 | 3:24c5f0f50bf1 | 496 | // |
uci1 | 3:24c5f0f50bf1 | 497 | // must match WriteTo |
uci1 | 3:24c5f0f50bf1 | 498 | |
uci1 | 3:24c5f0f50bf1 | 499 | uint8_t Rv=0; |
uci1 | 3:24c5f0f50bf1 | 500 | b = SnBitUtils::ReadFrom(b, Rv); // i/o version |
uci1 | 12:d472f9811262 | 501 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 502 | printf("Rv=%hhu\r\n",Rv); |
uci1 | 12:d472f9811262 | 503 | #endif |
uci1 | 84:80b15993944e | 504 | if ( IsIOversionOk(Rv) ) { |
uci1 | 56:0bba0ef15697 | 505 | |
uci1 | 56:0bba0ef15697 | 506 | if (IsLowPowerMode()) { |
uci1 | 56:0bba0ef15697 | 507 | // the low power bit is not streamed, so we need to |
uci1 | 56:0bba0ef15697 | 508 | // reset it explicitly |
uci1 | 56:0bba0ef15697 | 509 | ChangeToNormPower(); |
uci1 | 56:0bba0ef15697 | 510 | } |
uci1 | 56:0bba0ef15697 | 511 | |
uci1 | 84:80b15993944e | 512 | if (Rv<11) { |
uci1 | 84:80b15993944e | 513 | uint32_t llen=kConfLblLen; |
uci1 | 84:80b15993944e | 514 | b = SnBitUtils::ReadFrom(b, llen); |
uci1 | 12:d472f9811262 | 515 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 516 | printf("llen=%u\r\n",llen); |
uci1 | 12:d472f9811262 | 517 | #endif |
uci1 | 84:80b15993944e | 518 | b = SnBitUtils::ReadFrom(b, fLabel, llen); |
uci1 | 84:80b15993944e | 519 | } else { |
uci1 | 84:80b15993944e | 520 | b = SnBitUtils::ReadFrom(b, fLabel, kConfLblLen); |
uci1 | 84:80b15993944e | 521 | } |
uci1 | 12:d472f9811262 | 522 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 523 | printf("lbl=%s\r\n",fLabel); |
uci1 | 12:d472f9811262 | 524 | #endif |
uci1 | 3:24c5f0f50bf1 | 525 | b = SnBitUtils::ReadFrom(b, fConfTime); |
uci1 | 12:d472f9811262 | 526 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 527 | printf("ct=%u\r\n",fConfTime); |
uci1 | 12:d472f9811262 | 528 | #endif |
uci1 | 3:24c5f0f50bf1 | 529 | b = SnBitUtils::ReadFrom(b, fRun); |
uci1 | 12:d472f9811262 | 530 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 531 | printf("run=%u\r\n",fRun); |
uci1 | 12:d472f9811262 | 532 | #endif |
uci1 | 40:1324da35afd4 | 533 | if (Rv>7) { |
uci1 | 40:1324da35afd4 | 534 | b = SnBitUtils::ReadFrom(b, fFirstSeq); |
uci1 | 40:1324da35afd4 | 535 | } else { |
uci1 | 40:1324da35afd4 | 536 | uint32_t fe(0); |
uci1 | 40:1324da35afd4 | 537 | fFirstSeq = 0; |
uci1 | 40:1324da35afd4 | 538 | b = SnBitUtils::ReadFrom(b, fe); |
uci1 | 40:1324da35afd4 | 539 | } |
uci1 | 12:d472f9811262 | 540 | #ifdef DEBUG |
uci1 | 40:1324da35afd4 | 541 | printf("firstseq=%hu\r\n",fFirstSeq); |
uci1 | 12:d472f9811262 | 542 | #endif |
uci1 | 3:24c5f0f50bf1 | 543 | if (Rv>1) { |
uci1 | 84:80b15993944e | 544 | if (Rv<11) { |
uci1 | 84:80b15993944e | 545 | uint32_t eps(0); |
uci1 | 84:80b15993944e | 546 | b = SnBitUtils::ReadFrom(b, eps); |
uci1 | 84:80b15993944e | 547 | fEvtsPerSeq = (1<<sizeof(fEvtsPerSeq))-1; // biggest value |
uci1 | 84:80b15993944e | 548 | if ( eps < fEvtsPerSeq ) { |
uci1 | 84:80b15993944e | 549 | fEvtsPerSeq = eps; |
uci1 | 84:80b15993944e | 550 | } |
uci1 | 84:80b15993944e | 551 | } else { |
uci1 | 84:80b15993944e | 552 | b = SnBitUtils::ReadFrom(b, fEvtsPerSeq); |
uci1 | 84:80b15993944e | 553 | } |
uci1 | 84:80b15993944e | 554 | if (Rv<11) { |
uci1 | 84:80b15993944e | 555 | uint8_t rm(0); |
uci1 | 84:80b15993944e | 556 | b = SnBitUtils::ReadFrom(b, rm); |
uci1 | 84:80b15993944e | 557 | fRunMode = rm; |
uci1 | 84:80b15993944e | 558 | } else { |
uci1 | 84:80b15993944e | 559 | b = SnBitUtils::ReadFrom(b, fRunMode); |
uci1 | 84:80b15993944e | 560 | } |
uci1 | 40:1324da35afd4 | 561 | } else { |
uci1 | 40:1324da35afd4 | 562 | fEvtsPerSeq = 1000; |
uci1 | 40:1324da35afd4 | 563 | fRunMode = 0; |
uci1 | 40:1324da35afd4 | 564 | } |
uci1 | 12:d472f9811262 | 565 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 566 | printf("eps=%hu\r\n",fEvtsPerSeq); |
uci1 | 84:80b15993944e | 567 | printf("rm=%hu\r\n",fRunMode); |
uci1 | 12:d472f9811262 | 568 | #endif |
uci1 | 56:0bba0ef15697 | 569 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 570 | if ( IsIOversForATWD(Rv) && Rv<11 ) { |
uci1 | 56:0bba0ef15697 | 571 | b = SnBitUtils::ReadFrom(b, fStreamHiLoPlas); |
uci1 | 12:d472f9811262 | 572 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 573 | printf("shilo=%d\r\n",(int)fStreamHiLoPlas); |
uci1 | 12:d472f9811262 | 574 | #endif |
uci1 | 56:0bba0ef15697 | 575 | } |
uci1 | 56:0bba0ef15697 | 576 | #endif // ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 577 | b = SnBitUtils::ReadFrom(b, fWvLoseLSB); |
uci1 | 12:d472f9811262 | 578 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 579 | printf("lsb=%hhu\r\n",fWvLoseLSB); |
uci1 | 12:d472f9811262 | 580 | #endif |
uci1 | 3:24c5f0f50bf1 | 581 | b = SnBitUtils::ReadFrom(b, fWvLoseMSB); |
uci1 | 12:d472f9811262 | 582 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 583 | printf("msb=%hhu\r\n",fWvLoseMSB); |
uci1 | 12:d472f9811262 | 584 | #endif |
uci1 | 3:24c5f0f50bf1 | 585 | b = SnBitUtils::ReadFrom(b, fWvBaseline); |
uci1 | 12:d472f9811262 | 586 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 587 | printf("bl=%hu\r\n",fWvBaseline); |
uci1 | 12:d472f9811262 | 588 | #endif |
uci1 | 84:80b15993944e | 589 | if (Rv<11) { |
uci1 | 84:80b15993944e | 590 | b = SnBitUtils::ReadFrom(b, fDatPackType); |
uci1 | 12:d472f9811262 | 591 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 592 | printf("dp=%hhu\r\n",fDatPackType); |
uci1 | 12:d472f9811262 | 593 | #endif |
uci1 | 84:80b15993944e | 594 | } |
uci1 | 3:24c5f0f50bf1 | 595 | uint16_t* dc = &(fDAC[0][0]); |
uci1 | 56:0bba0ef15697 | 596 | const uint8_t ntotdacs = GetTotDacsForIOVers(Rv); |
uci1 | 56:0bba0ef15697 | 597 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 598 | printf("ntotdacs=%hhu\r\n",ntotdacs); |
uci1 | 56:0bba0ef15697 | 599 | #endif |
uci1 | 56:0bba0ef15697 | 600 | for (uint16_t i=0; i<ntotdacs; i++, dc++) { |
uci1 | 3:24c5f0f50bf1 | 601 | b = SnBitUtils::ReadFrom(b, *dc); |
uci1 | 12:d472f9811262 | 602 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 603 | printf("dac[%hu]=%hu\r\n",i,*dc); |
uci1 | 12:d472f9811262 | 604 | #endif |
uci1 | 3:24c5f0f50bf1 | 605 | } |
uci1 | 56:0bba0ef15697 | 606 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 607 | if ( IsIOversForATWD(Rv) ) { |
uci1 | 56:0bba0ef15697 | 608 | b = SnBitUtils::ReadFrom(b, fNumPlas); |
uci1 | 12:d472f9811262 | 609 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 610 | printf("npla=%hhu\r\n",fNumPlas); |
uci1 | 12:d472f9811262 | 611 | #endif |
uci1 | 56:0bba0ef15697 | 612 | uint16_t* pl = &(fPLA[0]); |
uci1 | 56:0bba0ef15697 | 613 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 56:0bba0ef15697 | 614 | b = SnBitUtils::ReadFrom(b, *pl); |
uci1 | 12:d472f9811262 | 615 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 616 | printf("pla[%hhu]=%hu\r\n",j,*pl); |
uci1 | 12:d472f9811262 | 617 | #endif |
uci1 | 56:0bba0ef15697 | 618 | } |
uci1 | 3:24c5f0f50bf1 | 619 | } |
uci1 | 56:0bba0ef15697 | 620 | #endif // ATWD4CH |
uci1 | 3:24c5f0f50bf1 | 621 | b = SnBitUtils::ReadFrom(b, fNumCardsMajLog); |
uci1 | 12:d472f9811262 | 622 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 623 | printf("mj=%hhu\r\n",fNumCardsMajLog); |
uci1 | 12:d472f9811262 | 624 | #endif |
uci1 | 84:80b15993944e | 625 | if (Rv<11) { |
uci1 | 84:80b15993944e | 626 | uint8_t e(0); |
uci1 | 84:80b15993944e | 627 | b = SnBitUtils::ReadFrom(b, e); |
uci1 | 84:80b15993944e | 628 | fEnableThermTrig = e; |
uci1 | 84:80b15993944e | 629 | } else { |
uci1 | 84:80b15993944e | 630 | b = SnBitUtils::ReadFrom(b, fEnableThermTrig); |
uci1 | 84:80b15993944e | 631 | } |
uci1 | 12:d472f9811262 | 632 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 633 | printf("thm=%d\r\n",(int)fEnableThermTrig); |
uci1 | 12:d472f9811262 | 634 | #endif |
uci1 | 18:55f1581f2ee4 | 635 | if (Rv>3) { |
uci1 | 18:55f1581f2ee4 | 636 | b = SnBitUtils::ReadFrom(b, fForceTrigPeriod); |
uci1 | 18:55f1581f2ee4 | 637 | } else { |
uci1 | 18:55f1581f2ee4 | 638 | uint16_t ftrg(0); |
uci1 | 18:55f1581f2ee4 | 639 | b = SnBitUtils::ReadFrom(b, ftrg); |
uci1 | 18:55f1581f2ee4 | 640 | fForceTrigPeriod = ftrg; |
uci1 | 18:55f1581f2ee4 | 641 | } |
uci1 | 12:d472f9811262 | 642 | #ifdef DEBUG |
uci1 | 18:55f1581f2ee4 | 643 | printf("force=%g\r\n",fForceTrigPeriod); |
uci1 | 12:d472f9811262 | 644 | #endif |
uci1 | 3:24c5f0f50bf1 | 645 | b = SnBitUtils::ReadFrom(b, fHeartBeatPeriod); |
uci1 | 12:d472f9811262 | 646 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 647 | printf("heart=%hu\r\n",fHeartBeatPeriod); |
uci1 | 12:d472f9811262 | 648 | #endif |
uci1 | 84:80b15993944e | 649 | if (Rv<11) { |
uci1 | 84:80b15993944e | 650 | uint8_t ampson(0); |
uci1 | 84:80b15993944e | 651 | b = SnBitUtils::ReadFrom(b, ampson); |
uci1 | 12:d472f9811262 | 652 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 653 | printf("amps=%hhu (IGNORED)\r\n",ampson); |
uci1 | 12:d472f9811262 | 654 | #endif |
uci1 | 84:80b15993944e | 655 | } |
uci1 | 3:24c5f0f50bf1 | 656 | b = SnBitUtils::ReadFrom(b, fEvtThrtlPeriodMs); |
uci1 | 12:d472f9811262 | 657 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 658 | printf("throt=%hu\r\n",fEvtThrtlPeriodMs); |
uci1 | 12:d472f9811262 | 659 | #endif |
uci1 | 3:24c5f0f50bf1 | 660 | b = SnBitUtils::ReadFrom(b, fPowerMode); |
uci1 | 12:d472f9811262 | 661 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 662 | printf("pow=%hhu\r\n",fPowerMode); |
uci1 | 12:d472f9811262 | 663 | #endif |
uci1 | 39:2f17131d22a5 | 664 | if (Rv<6) { |
uci1 | 39:2f17131d22a5 | 665 | b = SnBitUtils::ReadFrom(b, fBatVoltToLowPwr); |
uci1 | 40:1324da35afd4 | 666 | fBatVoltFromLowPwr = 1.1*fBatVoltToLowPwr; |
uci1 | 39:2f17131d22a5 | 667 | } else { |
uci1 | 39:2f17131d22a5 | 668 | b = SnBitUtils::ReadFrom(b, fBatVoltToLowPwr); |
uci1 | 39:2f17131d22a5 | 669 | b = SnBitUtils::ReadFrom(b, fBatVoltFromLowPwr); |
uci1 | 39:2f17131d22a5 | 670 | } |
uci1 | 39:2f17131d22a5 | 671 | #ifdef DEBUG |
uci1 | 40:1324da35afd4 | 672 | printf("batlow(to,from)=(%hu,%hu)\r\n",fBatVoltToLowPwr,fBatVoltFromLowPwr); |
uci1 | 12:d472f9811262 | 673 | #endif |
uci1 | 8:95a325df1f6b | 674 | if (Rv>2) { |
uci1 | 8:95a325df1f6b | 675 | b = SnBitUtils::ReadFrom(b, fVoltCheckPeriod); |
uci1 | 40:1324da35afd4 | 676 | } else { |
uci1 | 40:1324da35afd4 | 677 | fVoltCheckPeriod = 600u; |
uci1 | 40:1324da35afd4 | 678 | } |
uci1 | 12:d472f9811262 | 679 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 680 | printf("vltchk=%hu\r\n",fVoltCheckPeriod); |
uci1 | 12:d472f9811262 | 681 | #endif |
uci1 | 3:24c5f0f50bf1 | 682 | b = SnBitUtils::ReadFrom(b, fCommWinPeriod); |
uci1 | 12:d472f9811262 | 683 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 684 | printf("cmper=%u\r\n",fCommWinPeriod); |
uci1 | 12:d472f9811262 | 685 | #endif |
uci1 | 3:24c5f0f50bf1 | 686 | b = SnBitUtils::ReadFrom(b, fCommWinDuration); |
uci1 | 12:d472f9811262 | 687 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 688 | printf("cmdur=%u\r\n",fCommWinDuration); |
uci1 | 12:d472f9811262 | 689 | #endif |
uci1 | 3:24c5f0f50bf1 | 690 | b = SnBitUtils::ReadFrom(b, fCommSendData); |
uci1 | 12:d472f9811262 | 691 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 692 | printf("send=%hd\r\n",fCommSendData); |
uci1 | 12:d472f9811262 | 693 | #endif |
uci1 | 3:24c5f0f50bf1 | 694 | b = SnBitUtils::ReadFrom(b, fCommWinPrdLowPwr); |
uci1 | 12:d472f9811262 | 695 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 696 | printf("cmperlp=%u\r\n",fCommWinPrdLowPwr); |
uci1 | 12:d472f9811262 | 697 | #endif |
uci1 | 3:24c5f0f50bf1 | 698 | b = SnBitUtils::ReadFrom(b, fCommWinDurLowPwr); |
uci1 | 12:d472f9811262 | 699 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 700 | printf("cmdurlp=%u\r\n",fCommWinDurLowPwr); |
uci1 | 12:d472f9811262 | 701 | #endif |
uci1 | 40:1324da35afd4 | 702 | if (Rv>6) { |
uci1 | 84:80b15993944e | 703 | if (Rv>10) { |
uci1 | 84:80b15993944e | 704 | // Irid first |
uci1 | 84:80b15993944e | 705 | b = SnBitUtils::ReadFrom(b, fCommWinConnTOMins[IndexOfDataStream(kIrid)]); |
uci1 | 84:80b15993944e | 706 | b = SnBitUtils::ReadFrom(b, fCommWinListTOMins[IndexOfDataStream(kIrid)]); |
uci1 | 84:80b15993944e | 707 | // Afar next |
uci1 | 84:80b15993944e | 708 | b = SnBitUtils::ReadFrom(b, fCommWinConnTOMins[IndexOfDataStream(kAfar)]); |
uci1 | 84:80b15993944e | 709 | b = SnBitUtils::ReadFrom(b, fCommWinListTOMins[IndexOfDataStream(kAfar)]); |
uci1 | 84:80b15993944e | 710 | } else { |
uci1 | 84:80b15993944e | 711 | // older versions: set them all the same |
uci1 | 84:80b15993944e | 712 | uint8_t cto, lto; |
uci1 | 84:80b15993944e | 713 | b = SnBitUtils::ReadFrom(b, cto); |
uci1 | 84:80b15993944e | 714 | b = SnBitUtils::ReadFrom(b, lto); |
uci1 | 84:80b15993944e | 715 | for (uint8_t i=0; i<kNumDatStreams; ++i) { |
uci1 | 84:80b15993944e | 716 | fCommWinConnTOMins[i] = cto; |
uci1 | 84:80b15993944e | 717 | fCommWinListTOMins[i] = lto; |
uci1 | 84:80b15993944e | 718 | } |
uci1 | 84:80b15993944e | 719 | } |
uci1 | 40:1324da35afd4 | 720 | } else { |
uci1 | 84:80b15993944e | 721 | for (uint8_t i=0; i<kNumDatStreams; ++i) { |
uci1 | 84:80b15993944e | 722 | fCommWinConnTOMins[i] = GetDefaultConnTOMin(i); |
uci1 | 84:80b15993944e | 723 | fCommWinListTOMins[i] = GetDefaultListTOMin(i); |
uci1 | 84:80b15993944e | 724 | } |
uci1 | 40:1324da35afd4 | 725 | } |
uci1 | 40:1324da35afd4 | 726 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 727 | for (uint8_t i=0; i<kNumDatStreams; ++i) { |
uci1 | 84:80b15993944e | 728 | printf("data stream %hhu (%s): connectTO=%hhu, listenTO=%hhu\r\n", |
uci1 | 84:80b15993944e | 729 | i, GetDataStreamNameOfIdx(i), |
uci1 | 84:80b15993944e | 730 | fCommWinConnTOMins[i], fCommWinListTOMins[i]); |
uci1 | 84:80b15993944e | 731 | } |
uci1 | 40:1324da35afd4 | 732 | #endif |
uci1 | 8:95a325df1f6b | 733 | if (Rv>2) { |
uci1 | 84:80b15993944e | 734 | if (Rv<11) { |
uci1 | 84:80b15993944e | 735 | b = SnBitUtils::ReadFrom(b, fRemoteServer, kIPLen); |
uci1 | 84:80b15993944e | 736 | } else { |
uci1 | 84:80b15993944e | 737 | // read the numerical value and convert to string |
uci1 | 84:80b15993944e | 738 | uint32_t rip(0); |
uci1 | 84:80b15993944e | 739 | b = SnBitUtils::ReadFrom(b, rip); |
uci1 | 84:80b15993944e | 740 | GetIpStrFromVal(rip, fRemoteServer); |
uci1 | 84:80b15993944e | 741 | } |
uci1 | 28:484943132bb0 | 742 | if (strncmp(fRemoteServer, kDefIPflag,kIPLen)==0) { |
uci1 | 28:484943132bb0 | 743 | SetDefaultRemoteServ(); |
uci1 | 28:484943132bb0 | 744 | } |
uci1 | 12:d472f9811262 | 745 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 746 | printf("rserv=%s\r\n",fRemoteServer); |
uci1 | 12:d472f9811262 | 747 | #endif |
uci1 | 8:95a325df1f6b | 748 | b = SnBitUtils::ReadFrom(b, fRemotePort); |
uci1 | 28:484943132bb0 | 749 | if (fRemotePort==0) { |
uci1 | 28:484943132bb0 | 750 | SetDefaultRemotePort(); |
uci1 | 28:484943132bb0 | 751 | } |
uci1 | 12:d472f9811262 | 752 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 753 | printf("rport=%hu\r\n",fRemotePort); |
uci1 | 12:d472f9811262 | 754 | #endif |
uci1 | 84:80b15993944e | 755 | if (Rv<11) { |
uci1 | 84:80b15993944e | 756 | b = SnBitUtils::ReadFrom(b, fMbedIP, kIPLen); |
uci1 | 84:80b15993944e | 757 | } else { |
uci1 | 84:80b15993944e | 758 | // read the numerical value and convert to string |
uci1 | 84:80b15993944e | 759 | uint32_t rip(0); |
uci1 | 84:80b15993944e | 760 | b = SnBitUtils::ReadFrom(b, rip); |
uci1 | 84:80b15993944e | 761 | GetIpStrFromVal(rip, fMbedIP); |
uci1 | 84:80b15993944e | 762 | } |
uci1 | 28:484943132bb0 | 763 | if (strncmp(fMbedIP, kDefIPflag,kIPLen)==0) { |
uci1 | 28:484943132bb0 | 764 | SetDefaultMbedIP(); |
uci1 | 28:484943132bb0 | 765 | } |
uci1 | 12:d472f9811262 | 766 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 767 | printf("mbedip=%s\r\n",fMbedIP); |
uci1 | 12:d472f9811262 | 768 | #endif |
uci1 | 84:80b15993944e | 769 | if (Rv<11) { |
uci1 | 84:80b15993944e | 770 | b = SnBitUtils::ReadFrom(b, fMbedMask, kIPLen); |
uci1 | 84:80b15993944e | 771 | } else { |
uci1 | 84:80b15993944e | 772 | // read the numerical value and convert to string |
uci1 | 84:80b15993944e | 773 | uint32_t rip(0); |
uci1 | 84:80b15993944e | 774 | b = SnBitUtils::ReadFrom(b, rip); |
uci1 | 84:80b15993944e | 775 | GetIpStrFromVal(rip, fMbedMask); |
uci1 | 84:80b15993944e | 776 | } |
uci1 | 28:484943132bb0 | 777 | if (strncmp(fMbedMask, kDefIPflag,kIPLen)==0) { |
uci1 | 28:484943132bb0 | 778 | SetDefaultMaskIP(); |
uci1 | 28:484943132bb0 | 779 | } |
uci1 | 12:d472f9811262 | 780 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 781 | printf("mbedmask=%s\r\n",fMbedMask); |
uci1 | 12:d472f9811262 | 782 | #endif |
uci1 | 84:80b15993944e | 783 | if (Rv<11) { |
uci1 | 84:80b15993944e | 784 | b = SnBitUtils::ReadFrom(b, fMbedGate, kIPLen); |
uci1 | 84:80b15993944e | 785 | } else { |
uci1 | 84:80b15993944e | 786 | // read the numerical value and convert to string |
uci1 | 84:80b15993944e | 787 | uint32_t rip(0); |
uci1 | 84:80b15993944e | 788 | b = SnBitUtils::ReadFrom(b, rip); |
uci1 | 84:80b15993944e | 789 | GetIpStrFromVal(rip, fMbedGate); |
uci1 | 84:80b15993944e | 790 | } |
uci1 | 28:484943132bb0 | 791 | if (strncmp(fMbedGate, kDefIPflag,kIPLen)==0) { |
uci1 | 28:484943132bb0 | 792 | SetDefaultGateIP(); |
uci1 | 28:484943132bb0 | 793 | } |
uci1 | 12:d472f9811262 | 794 | #ifdef DEBUG |
uci1 | 8:95a325df1f6b | 795 | printf("mbedgate=%s\r\n",fMbedGate); |
uci1 | 12:d472f9811262 | 796 | #endif |
uci1 | 40:1324da35afd4 | 797 | } else { |
uci1 | 40:1324da35afd4 | 798 | SetDefaultIPs(); |
uci1 | 8:95a325df1f6b | 799 | } |
uci1 | 3:24c5f0f50bf1 | 800 | b = SnBitUtils::ReadFrom(b, fWatchDogPeriod); |
uci1 | 12:d472f9811262 | 801 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 802 | printf("watch=%u\r\n",fWatchDogPeriod); |
uci1 | 12:d472f9811262 | 803 | #endif |
uci1 | 84:80b15993944e | 804 | #if CHIPBOARD==SST4CH |
uci1 | 84:80b15993944e | 805 | if ( (IsIOversForATWD(Rv)==false) && (Rv>9) ) { |
uci1 | 56:0bba0ef15697 | 806 | b = SnBitUtils::ReadFrom(b, fTempCheckPeriod); |
uci1 | 56:0bba0ef15697 | 807 | } |
uci1 | 12:d472f9811262 | 808 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 809 | printf("temp check period=%hhd\r\n", fTempCheckPeriod); |
uci1 | 12:d472f9811262 | 810 | #endif |
uci1 | 84:80b15993944e | 811 | #endif |
uci1 | 84:80b15993944e | 812 | if (Rv>10) { |
uci1 | 84:80b15993944e | 813 | b = SnBitUtils::ReadFrom(b, fSnglFreqRatio); |
uci1 | 84:80b15993944e | 814 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 815 | printf("single freq ratio=%hhd\r\n", fSnglFreqRatio); |
uci1 | 84:80b15993944e | 816 | #endif |
uci1 | 84:80b15993944e | 817 | |
uci1 | 84:80b15993944e | 818 | b = SnBitUtils::ReadFrom(b, fL1Scaledown); |
uci1 | 84:80b15993944e | 819 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 820 | printf("L1 scaledown=%hhd\r\n", fL1Scaledown); |
uci1 | 84:80b15993944e | 821 | #endif |
uci1 | 84:80b15993944e | 822 | } |
uci1 | 56:0bba0ef15697 | 823 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 824 | if ( IsIOversForATWD(Rv) ) { |
uci1 | 56:0bba0ef15697 | 825 | if (fStreamHiLoPlas!=0) { |
uci1 | 56:0bba0ef15697 | 826 | uint16_t hi, lo; |
uci1 | 56:0bba0ef15697 | 827 | for (uint8_t j=0; j<fNumPlas; j++) { |
uci1 | 56:0bba0ef15697 | 828 | b = SnBitUtils::ReadFrom(b, hi); |
uci1 | 12:d472f9811262 | 829 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 830 | printf("hi=%hu\r\n",hi); |
uci1 | 56:0bba0ef15697 | 831 | #endif |
uci1 | 56:0bba0ef15697 | 832 | b = SnBitUtils::ReadFrom(b, lo); |
uci1 | 56:0bba0ef15697 | 833 | #ifdef DEBUG |
uci1 | 56:0bba0ef15697 | 834 | printf("lo=%hu\r\n",lo); |
uci1 | 12:d472f9811262 | 835 | #endif |
uci1 | 3:24c5f0f50bf1 | 836 | // don't save these |
uci1 | 56:0bba0ef15697 | 837 | } |
uci1 | 3:24c5f0f50bf1 | 838 | } |
uci1 | 3:24c5f0f50bf1 | 839 | } |
uci1 | 56:0bba0ef15697 | 840 | #endif // ATWD4CH |
uci1 | 84:80b15993944e | 841 | } else { |
uci1 | 84:80b15993944e | 842 | // trying to read an invalid config version |
uci1 | 84:80b15993944e | 843 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 844 | printf("Cannot accept config version [%hhu]. " |
uci1 | 84:80b15993944e | 845 | "Expect [%hhu].",Rv,SnConfigFrame::kIOVers); |
uci1 | 84:80b15993944e | 846 | #endif |
uci1 | 3:24c5f0f50bf1 | 847 | } |
uci1 | 28:484943132bb0 | 848 | |
uci1 | 31:b5bd3b189150 | 849 | if (fgApplySafetyNets) { |
uci1 | 31:b5bd3b189150 | 850 | ApplySafetyNets(); |
uci1 | 31:b5bd3b189150 | 851 | } |
uci1 | 28:484943132bb0 | 852 | |
uci1 | 76:f8383f0292c2 | 853 | // reset the SD card init cache, in case the SD ignore run mode changed |
uci1 | 76:f8383f0292c2 | 854 | SetSDNeedToInitFlag(); |
uci1 | 76:f8383f0292c2 | 855 | |
uci1 | 12:d472f9811262 | 856 | #ifdef DEBUG |
uci1 | 3:24c5f0f50bf1 | 857 | printf("read from done\r\n"); |
uci1 | 12:d472f9811262 | 858 | #endif |
uci1 | 3:24c5f0f50bf1 | 859 | } |
uci1 | 3:24c5f0f50bf1 | 860 | |
uci1 | 3:24c5f0f50bf1 | 861 | template <class T> |
uci1 | 3:24c5f0f50bf1 | 862 | void WriteTo(T& b) const { |
uci1 | 3:24c5f0f50bf1 | 863 | // no check on the length of the buf is done here |
uci1 | 3:24c5f0f50bf1 | 864 | // that should be done already |
uci1 | 3:24c5f0f50bf1 | 865 | // |
uci1 | 3:24c5f0f50bf1 | 866 | // must match ReadFromBuf |
uci1 | 3:24c5f0f50bf1 | 867 | // |
uci1 | 3:24c5f0f50bf1 | 868 | // intentionally not writing mac address here, so we don't have to read it in |
uci1 | 3:24c5f0f50bf1 | 869 | |
uci1 | 3:24c5f0f50bf1 | 870 | b = SnBitUtils::WriteTo(b, kIOVers); // i/o version |
uci1 | 84:80b15993944e | 871 | |
uci1 | 84:80b15993944e | 872 | // first write the label, then explicitly write the trailing \0 |
uci1 | 84:80b15993944e | 873 | // so it's for sure always there |
uci1 | 84:80b15993944e | 874 | /* legacy code when io vers < 11 |
uci1 | 40:1324da35afd4 | 875 | // account for the ending \0 |
uci1 | 40:1324da35afd4 | 876 | uint32_t llen = strlen(fLabel); |
uci1 | 40:1324da35afd4 | 877 | static const uint32_t maxllen = kConfLblLen-1; |
uci1 | 40:1324da35afd4 | 878 | if (llen > maxllen) { |
uci1 | 40:1324da35afd4 | 879 | llen = maxllen; |
uci1 | 40:1324da35afd4 | 880 | } |
uci1 | 40:1324da35afd4 | 881 | b = SnBitUtils::WriteTo(b, llen+1); // strlen + \0 |
uci1 | 3:24c5f0f50bf1 | 882 | b = SnBitUtils::WriteTo(b, fLabel, llen); |
uci1 | 84:80b15993944e | 883 | */ |
uci1 | 84:80b15993944e | 884 | b = SnBitUtils::WriteTo(b, fLabel, kConfLblLenNoStrTerm); |
uci1 | 39:2f17131d22a5 | 885 | b = SnBitUtils::WriteTo(b, char('\0')); |
uci1 | 3:24c5f0f50bf1 | 886 | b = SnBitUtils::WriteTo(b, fConfTime); |
uci1 | 3:24c5f0f50bf1 | 887 | b = SnBitUtils::WriteTo(b, fRun); |
uci1 | 40:1324da35afd4 | 888 | b = SnBitUtils::WriteTo(b, fFirstSeq); |
uci1 | 84:80b15993944e | 889 | b = SnBitUtils::WriteTo(b, fEvtsPerSeq); // changed to uint16 with V11+ |
uci1 | 84:80b15993944e | 890 | b = SnBitUtils::WriteTo(b, fRunMode); // changed to uint16 with V11+ |
uci1 | 84:80b15993944e | 891 | /* - the option is no longer written to the config |
uci1 | 56:0bba0ef15697 | 892 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 893 | if ( IsIOversForATWD(kIOVers) ) { |
uci1 | 56:0bba0ef15697 | 894 | b = SnBitUtils::WriteTo(b, fStreamHiLoPlas); |
uci1 | 56:0bba0ef15697 | 895 | } |
uci1 | 56:0bba0ef15697 | 896 | #endif |
uci1 | 84:80b15993944e | 897 | */ |
uci1 | 3:24c5f0f50bf1 | 898 | b = SnBitUtils::WriteTo(b, fWvLoseLSB); |
uci1 | 3:24c5f0f50bf1 | 899 | b = SnBitUtils::WriteTo(b, fWvLoseMSB); |
uci1 | 3:24c5f0f50bf1 | 900 | b = SnBitUtils::WriteTo(b, fWvBaseline); |
uci1 | 84:80b15993944e | 901 | //b = SnBitUtils::WriteTo(b, fDatPackType); // removed vers 11+ |
uci1 | 3:24c5f0f50bf1 | 902 | const uint16_t* dc = &(fDAC[0][0]); |
uci1 | 56:0bba0ef15697 | 903 | const uint8_t ntotdacs = GetTotDacsForIOVers(kIOVers); |
uci1 | 56:0bba0ef15697 | 904 | for (uint16_t i=0; i<ntotdacs; i++, dc++) { |
uci1 | 3:24c5f0f50bf1 | 905 | b = SnBitUtils::WriteTo(b, *dc); |
uci1 | 3:24c5f0f50bf1 | 906 | } |
uci1 | 56:0bba0ef15697 | 907 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 908 | if ( IsIOversForATWD(kIOVers) ) { |
uci1 | 56:0bba0ef15697 | 909 | b = SnBitUtils::WriteTo(b, fNumPlas); |
uci1 | 56:0bba0ef15697 | 910 | const uint16_t* pl = &(fPLA[0]); |
uci1 | 56:0bba0ef15697 | 911 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 56:0bba0ef15697 | 912 | b = SnBitUtils::WriteTo(b, *pl); |
uci1 | 56:0bba0ef15697 | 913 | } |
uci1 | 3:24c5f0f50bf1 | 914 | } |
uci1 | 56:0bba0ef15697 | 915 | #endif |
uci1 | 3:24c5f0f50bf1 | 916 | b = SnBitUtils::WriteTo(b, fNumCardsMajLog); |
uci1 | 84:80b15993944e | 917 | b = SnBitUtils::WriteTo(b, fEnableThermTrig); // 16 bits in vers 11+ |
uci1 | 3:24c5f0f50bf1 | 918 | b = SnBitUtils::WriteTo(b, fForceTrigPeriod); |
uci1 | 3:24c5f0f50bf1 | 919 | b = SnBitUtils::WriteTo(b, fHeartBeatPeriod); |
uci1 | 84:80b15993944e | 920 | //b = SnBitUtils::WriteTo(b, fAmpsOn); removed vers 11+ |
uci1 | 3:24c5f0f50bf1 | 921 | b = SnBitUtils::WriteTo(b, fEvtThrtlPeriodMs); |
uci1 | 3:24c5f0f50bf1 | 922 | b = SnBitUtils::WriteTo(b, fPowerMode); |
uci1 | 39:2f17131d22a5 | 923 | b = SnBitUtils::WriteTo(b, fBatVoltToLowPwr); |
uci1 | 39:2f17131d22a5 | 924 | b = SnBitUtils::WriteTo(b, fBatVoltFromLowPwr); |
uci1 | 8:95a325df1f6b | 925 | b = SnBitUtils::WriteTo(b, fVoltCheckPeriod); |
uci1 | 3:24c5f0f50bf1 | 926 | b = SnBitUtils::WriteTo(b, fCommWinPeriod); |
uci1 | 3:24c5f0f50bf1 | 927 | b = SnBitUtils::WriteTo(b, fCommWinDuration); |
uci1 | 3:24c5f0f50bf1 | 928 | b = SnBitUtils::WriteTo(b, fCommSendData); |
uci1 | 3:24c5f0f50bf1 | 929 | b = SnBitUtils::WriteTo(b, fCommWinPrdLowPwr); |
uci1 | 3:24c5f0f50bf1 | 930 | b = SnBitUtils::WriteTo(b, fCommWinDurLowPwr); |
uci1 | 84:80b15993944e | 931 | // vers 11+, separate conn/listen timeouts for Irid and Afar |
uci1 | 84:80b15993944e | 932 | b = SnBitUtils::WriteTo(b, fCommWinConnTOMins[IndexOfDataStream(kIrid)]); |
uci1 | 84:80b15993944e | 933 | b = SnBitUtils::WriteTo(b, fCommWinListTOMins[IndexOfDataStream(kIrid)]); |
uci1 | 84:80b15993944e | 934 | b = SnBitUtils::WriteTo(b, fCommWinConnTOMins[IndexOfDataStream(kAfar)]); |
uci1 | 84:80b15993944e | 935 | b = SnBitUtils::WriteTo(b, fCommWinListTOMins[IndexOfDataStream(kAfar)]); |
uci1 | 84:80b15993944e | 936 | // with vers 11+, the numerical values are stored instead of strings (saves many bytes) |
uci1 | 84:80b15993944e | 937 | b = SnBitUtils::WriteTo(b, GetIpValFromStr(fRemoteServer) ); |
uci1 | 8:95a325df1f6b | 938 | b = SnBitUtils::WriteTo(b, fRemotePort); |
uci1 | 84:80b15993944e | 939 | b = SnBitUtils::WriteTo(b, GetIpValFromStr(fMbedIP) ); |
uci1 | 84:80b15993944e | 940 | b = SnBitUtils::WriteTo(b, GetIpValFromStr(fMbedMask) ); |
uci1 | 84:80b15993944e | 941 | b = SnBitUtils::WriteTo(b, GetIpValFromStr(fMbedGate) ); |
uci1 | 3:24c5f0f50bf1 | 942 | b = SnBitUtils::WriteTo(b, fWatchDogPeriod); |
uci1 | 84:80b15993944e | 943 | #if CHIPBOARD==SST4CH |
uci1 | 84:80b15993944e | 944 | if ( (IsIOversForATWD(kIOVers)==false) && (kIOVers>9) ) { |
uci1 | 67:ec999336fcd1 | 945 | b = SnBitUtils::WriteTo(b, fTempCheckPeriod); |
uci1 | 67:ec999336fcd1 | 946 | } |
uci1 | 84:80b15993944e | 947 | #endif |
uci1 | 84:80b15993944e | 948 | b = SnBitUtils::WriteTo(b, fSnglFreqRatio); // with vers 11+ |
uci1 | 84:80b15993944e | 949 | b = SnBitUtils::WriteTo(b, fL1Scaledown); // with vers 11+ |
uci1 | 84:80b15993944e | 950 | |
uci1 | 56:0bba0ef15697 | 951 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 952 | if ( IsIOversForATWD(kIOVers) ) { |
uci1 | 56:0bba0ef15697 | 953 | if (fStreamHiLoPlas!=0) { |
uci1 | 56:0bba0ef15697 | 954 | const uint16_t* pl = &(fPLA[0]); |
uci1 | 56:0bba0ef15697 | 955 | uint16_t hi, lo; |
uci1 | 56:0bba0ef15697 | 956 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 56:0bba0ef15697 | 957 | GetHiLoPlas(*pl, hi, lo); |
uci1 | 56:0bba0ef15697 | 958 | b = SnBitUtils::WriteTo(b, hi); |
uci1 | 56:0bba0ef15697 | 959 | b = SnBitUtils::WriteTo(b, lo); |
uci1 | 56:0bba0ef15697 | 960 | } |
uci1 | 3:24c5f0f50bf1 | 961 | } |
uci1 | 3:24c5f0f50bf1 | 962 | } |
uci1 | 56:0bba0ef15697 | 963 | #endif |
uci1 | 3:24c5f0f50bf1 | 964 | } |
uci1 | 3:24c5f0f50bf1 | 965 | |
uci1 | 3:24c5f0f50bf1 | 966 | bool ReadFromFile(const char* cfile); |
uci1 | 3:24c5f0f50bf1 | 967 | bool WriteToFile(const char* cfile) const; |
uci1 | 3:24c5f0f50bf1 | 968 | |
uci1 | 3:24c5f0f50bf1 | 969 | void Reset() { |
uci1 | 3:24c5f0f50bf1 | 970 | memset(fLabel, 0, sizeof(char)*kConfLblLen); |
uci1 | 40:1324da35afd4 | 971 | SetHardDefaults(); |
uci1 | 67:ec999336fcd1 | 972 | #ifdef USE_INTERFACE_CHIP |
uci1 | 3:24c5f0f50bf1 | 973 | if (ReadFromFile(kDefConfFile)==false) { |
uci1 | 3:24c5f0f50bf1 | 974 | // couldn't get default. use hardcoded version. |
uci1 | 67:ec999336fcd1 | 975 | // (reset in case a few parameters from the file |
uci1 | 67:ec999336fcd1 | 976 | // got assigned) |
uci1 | 3:24c5f0f50bf1 | 977 | SetHardDefaults(); |
uci1 | 3:24c5f0f50bf1 | 978 | } |
uci1 | 67:ec999336fcd1 | 979 | #endif |
uci1 | 16:744ce85aede2 | 980 | #ifdef DEBUG |
uci1 | 16:744ce85aede2 | 981 | printf("config reset to %s\r\n",fLabel); |
uci1 | 16:744ce85aede2 | 982 | #endif |
uci1 | 3:24c5f0f50bf1 | 983 | } |
uci1 | 40:1324da35afd4 | 984 | |
uci1 | 84:80b15993944e | 985 | uint32_t SizeOf(const uint8_t rv=SnConfigFrame::kIOVers) const { |
uci1 | 3:24c5f0f50bf1 | 986 | // returns the num of bytes needed to stream this object |
uci1 | 3:24c5f0f50bf1 | 987 | // = size of member vars + 1 for i/o version + extra PLA strings (maybe) |
uci1 | 84:80b15993944e | 988 | // + length of label string if rv<11 |
uci1 | 84:80b15993944e | 989 | const uint8_t lbllen = (rv<11) ? strlen(fLabel) : kConfLblLen; |
uci1 | 56:0bba0ef15697 | 990 | #if CHIPBOARD==ATWD4CH |
uci1 | 84:80b15993944e | 991 | return SizeOf(rv, fStreamHiLoPlas!=0, fNumPlas, lbllen); |
uci1 | 56:0bba0ef15697 | 992 | #else // SST |
uci1 | 84:80b15993944e | 993 | return SizeOf(rv, false, 0, lbllen); |
uci1 | 56:0bba0ef15697 | 994 | #endif |
uci1 | 3:24c5f0f50bf1 | 995 | } |
uci1 | 40:1324da35afd4 | 996 | |
uci1 | 3:24c5f0f50bf1 | 997 | static void SetMacAddress(); |
uci1 | 3:24c5f0f50bf1 | 998 | static uint64_t GetMacAddress() { |
uci1 | 3:24c5f0f50bf1 | 999 | if (fgMacAdr==0) { |
uci1 | 3:24c5f0f50bf1 | 1000 | SetMacAddress(); |
uci1 | 3:24c5f0f50bf1 | 1001 | } |
uci1 | 3:24c5f0f50bf1 | 1002 | return fgMacAdr; |
uci1 | 3:24c5f0f50bf1 | 1003 | } |
uci1 | 3:24c5f0f50bf1 | 1004 | |
uci1 | 3:24c5f0f50bf1 | 1005 | static uint32_t GetLabelMaxLen() { return kConfLblLen; } |
uci1 | 3:24c5f0f50bf1 | 1006 | |
uci1 | 3:24c5f0f50bf1 | 1007 | static void GetHiLoPlas(const uint16_t pla, |
uci1 | 3:24c5f0f50bf1 | 1008 | uint16_t& hiPla, |
uci1 | 3:24c5f0f50bf1 | 1009 | uint16_t& loPla, |
uci1 | 3:24c5f0f50bf1 | 1010 | const bool r2l=false); |
uci1 | 84:80b15993944e | 1011 | |
uci1 | 84:80b15993944e | 1012 | static |
uci1 | 84:80b15993944e | 1013 | void GetIpStrFromVal(const uint32_t ip, |
uci1 | 84:80b15993944e | 1014 | char(& str)[kIPLen]); |
uci1 | 84:80b15993944e | 1015 | |
uci1 | 84:80b15993944e | 1016 | static |
uci1 | 84:80b15993944e | 1017 | uint32_t GetIpValFromStr(const char(& str)[kIPLen]); |
uci1 | 84:80b15993944e | 1018 | |
uci1 | 84:80b15993944e | 1019 | static |
uci1 | 84:80b15993944e | 1020 | uint8_t IndexOfDataStream(const SnConfigFrame::EDatPackBit b) { |
uci1 | 84:80b15993944e | 1021 | switch (b) { |
uci1 | 84:80b15993944e | 1022 | case kSDcard: return 0u; |
uci1 | 84:80b15993944e | 1023 | case kIrid: return 1u; |
uci1 | 84:80b15993944e | 1024 | case kAfar: return 2u; |
uci1 | 84:80b15993944e | 1025 | case kUSB: return 3u; |
uci1 | 84:80b15993944e | 1026 | default: |
uci1 | 84:80b15993944e | 1027 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 1028 | printf("**** unknown stream bit [%u]", static_cast<uint32_t>(b)); |
uci1 | 84:80b15993944e | 1029 | #endif |
uci1 | 84:80b15993944e | 1030 | return 0; |
uci1 | 84:80b15993944e | 1031 | }; |
uci1 | 84:80b15993944e | 1032 | } |
uci1 | 84:80b15993944e | 1033 | |
uci1 | 84:80b15993944e | 1034 | static |
uci1 | 84:80b15993944e | 1035 | uint8_t GetDefaultConnTOMin(const uint8_t dataStreamIdx) { |
uci1 | 84:80b15993944e | 1036 | switch (dataStreamIdx) { |
uci1 | 84:80b15993944e | 1037 | case kSDcard: return 1u; |
uci1 | 84:80b15993944e | 1038 | case kIrid: return 3u; |
uci1 | 84:80b15993944e | 1039 | case kAfar: return 1u; |
uci1 | 84:80b15993944e | 1040 | case kUSB: return 1u; |
uci1 | 84:80b15993944e | 1041 | default: |
uci1 | 84:80b15993944e | 1042 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 1043 | printf("**** unknown stream index [%hhu]", dataStreamIdx); |
uci1 | 84:80b15993944e | 1044 | #endif |
uci1 | 84:80b15993944e | 1045 | return 0; |
uci1 | 84:80b15993944e | 1046 | }; |
uci1 | 84:80b15993944e | 1047 | } |
uci1 | 84:80b15993944e | 1048 | |
uci1 | 84:80b15993944e | 1049 | static |
uci1 | 84:80b15993944e | 1050 | uint8_t GetDefaultListTOMin(const uint8_t dataStreamIdx) { |
uci1 | 84:80b15993944e | 1051 | return GetDefaultConnTOMin(dataStreamIdx); |
uci1 | 84:80b15993944e | 1052 | } |
uci1 | 84:80b15993944e | 1053 | |
uci1 | 84:80b15993944e | 1054 | static |
uci1 | 84:80b15993944e | 1055 | const char* GetDataStreamName(const SnConfigFrame::EDatPackBit b) { |
uci1 | 84:80b15993944e | 1056 | switch (b) { |
uci1 | 84:80b15993944e | 1057 | case kSDcard: return "SDcard"; |
uci1 | 84:80b15993944e | 1058 | case kIrid: return "Iridium"; |
uci1 | 84:80b15993944e | 1059 | case kAfar: return "Afar"; |
uci1 | 84:80b15993944e | 1060 | case kUSB: return "USB"; |
uci1 | 84:80b15993944e | 1061 | default: |
uci1 | 84:80b15993944e | 1062 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 1063 | printf("**** unknown stream bit [%u]", static_cast<uint32_t>(b)); |
uci1 | 84:80b15993944e | 1064 | #endif |
uci1 | 84:80b15993944e | 1065 | return NULL; |
uci1 | 84:80b15993944e | 1066 | }; |
uci1 | 84:80b15993944e | 1067 | } |
uci1 | 84:80b15993944e | 1068 | |
uci1 | 84:80b15993944e | 1069 | static |
uci1 | 84:80b15993944e | 1070 | const char* GetDataStreamNameOfIdx(const uint8_t idx) { |
uci1 | 84:80b15993944e | 1071 | switch (idx) { |
uci1 | 84:80b15993944e | 1072 | case 0u: return GetDataStreamName(kSDcard); |
uci1 | 84:80b15993944e | 1073 | case 1u: return GetDataStreamName(kIrid); |
uci1 | 84:80b15993944e | 1074 | case 2u: return GetDataStreamName(kAfar); |
uci1 | 84:80b15993944e | 1075 | case 3u: return GetDataStreamName(kUSB); |
uci1 | 84:80b15993944e | 1076 | default: |
uci1 | 84:80b15993944e | 1077 | #ifdef DEBUG |
uci1 | 84:80b15993944e | 1078 | printf("**** unknown stream index [%hhu]", idx); |
uci1 | 84:80b15993944e | 1079 | #endif |
uci1 | 84:80b15993944e | 1080 | return NULL; |
uci1 | 84:80b15993944e | 1081 | }; |
uci1 | 84:80b15993944e | 1082 | } |
uci1 | 84:80b15993944e | 1083 | |
uci1 | 3:24c5f0f50bf1 | 1084 | }; |
uci1 | 3:24c5f0f50bf1 | 1085 | |
uci1 | 3:24c5f0f50bf1 | 1086 | #endif // SN_SnConfigFrame |