Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnEventFrame.h
- Revision:
- 116:8099b754fbb4
- Parent:
- 114:554fa3a956b4
- Child:
- 119:b3d7699d0eb0
--- a/SnEventFrame.h Fri Dec 04 02:57:12 2015 +0000 +++ b/SnEventFrame.h Tue May 03 02:01:35 2016 +0000 @@ -15,10 +15,16 @@ ((sizeof(uint32_t)*4u)+sizeof(int32_t)+sizeof(uint16_t) +(kTotSampsAtwd4ch*sizeof(uint16_t))+1u); static const uint32_t kMaxSizeOfV2 = kMaxSizeOfV1 - - (kTotSampsAtwd4ch*sizeof(uint16_t)) + (kTotSampsSst4ch*sizeof(uint16_t)) + - (kTotSampsAtwd4ch*sizeof(uint16_t)) + + (kTotSampsSst4ch*sizeof(uint16_t)) + (kNstopBytesSst4ch*sizeof(uint8_t)); - static const uint32_t kMaxSizeOfV3 = kMaxSizeOfV2; // same as V2 - static const uint32_t kMaxSizeOf = kMaxSizeOfV3; // biggest one + static const uint32_t kMaxSizeOfV3 = kMaxSizeOfV2; // same as V2 (just 1GHz clock) + static const uint32_t kMaxSizeOfV4 = kMaxSizeOfV1 + - (kTotSampsAtwd4ch*sizeof(uint16_t)) + + (kTotSampsSst4ch512*sizeof(uint16_t)) + + (kNstopBytesSst4ch512*sizeof(uint8_t)); + static const uint32_t kMaxSizeOfV5 = kMaxSizeOfV4; // same as V4 (just 1GHz clock) + static const uint32_t kMaxSizeOf = kMaxSizeOfV5; // biggest one private: // !! @@ -112,6 +118,7 @@ } void SetTrgBit(const ETrgBit_t t) { fTrgBits |= t; } + void DisableTrgBit(const ETrgBit_t b) { fTrgBits &= ~b; } void SetTrgNum(const uint32_t t) { fTrgNum = t; } void SetEvtNum(const uint32_t n) { fEvtNum = n; } void SetDTms(const int32_t dtms) { fDTms = dtms; } @@ -231,8 +238,10 @@ uint16_t GetTotSamplesForIOVers(const uint8_t rv) { if (rv<2) { return kTotSampsAtwd4ch; + } else if ((rv==2)||(rv==3)) { + return kTotSampsSst4ch; } else { - return kTotSampsSst4ch; + return kTotSampsSst4ch512; } } @@ -240,14 +249,26 @@ uint16_t GetStopBytesForIOVers(const uint8_t rv) { if (rv<2) { return 0; - } else { + } else if ((rv==2)||(rv==3)) { return kNstopBytesSst4ch; + } else { + return kNstopBytesSst4ch512; } } + + static + uint16_t GetStopBytesForIOVersBufferSafe(const uint8_t rv) { + // get the max number of stop bytes that will fit in an fStop buffer + const uint16_t nsb = GetStopBytesForIOVers(rv); + return (nsb>kNstopBytes) ? kNstopBytes : nsb; // prevent buffer overflow + } static uint32_t SizeOf(const uint8_t rv, const uint8_t loseLSB, const uint8_t loseMSB) { // size of member vars + size of packed waveform + 1 for i/o version +#ifdef EVDEBUG + printf("event: rv=%hhu, loseLBS=%hhu, loseMSB=%hhu\r\n", rv, loseLSB, loseMSB); +#endif uint32_t sz(0); const uint16_t ntotsamps = GetTotSamplesForIOVers(rv); if (rv==1) { @@ -256,12 +277,24 @@ sz = kMaxSizeOfV2; } else if (rv==3) { sz = kMaxSizeOfV3; + } else if (rv==4) { + sz = kMaxSizeOfV4; + } else if (rv==5) { + sz = kMaxSizeOfV5; } else { sz = kMaxSizeOf; } +#ifdef EVDEBUG + printf("event: ntotsamps=%hu, sz=%u\r\n", ntotsamps, sz); +#endif if ((loseLSB==0) && (loseMSB==0)) { return sz; } else { +#ifdef EVDEBUG + printf("event packed size=%u\r\n", + (sz-(ntotsamps*sizeof(uint16_t)) + +SizeOfPackedWavef(loseLSB, loseMSB))); +#endif return (sz-(ntotsamps*sizeof(uint16_t)) +SizeOfPackedWavef(loseLSB, loseMSB)); }