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