From be9a8bd4596a13286667541f1daf174a51ea3285 Mon Sep 17 00:00:00 2001 From: richterm Date: Fri, 10 Oct 2008 06:53:09 +0000 Subject: [PATCH] correcting some bugs, partly introduced in rev 29090 - last bunch of last channel was likely to be always skipped due to wrong size check - putting back the function documentation which somehow got lost - doing check for minimal buffer size right in decoder initialization - making GetRCUTrailerSize working if decoder was not initialized or failed --- RAW/AliAltroData.cxx | 9 ++++++++- RAW/AliAltroDecoder.cxx | 27 ++++++++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/RAW/AliAltroData.cxx b/RAW/AliAltroData.cxx index 91580fad1cd..a94e1f8f0c7 100644 --- a/RAW/AliAltroData.cxx +++ b/RAW/AliAltroData.cxx @@ -121,8 +121,15 @@ int AliAltroData::NextBunch(AliAltroBunch *altroBunch) fBunchData --; altroBunch->SetEndTimeBin( *fBunchData ); + // Matthias Oct 10 2008: those checks are certainly a bug, first the + // bunch size is subtracted from fBufferLeft ... and than once again + // I can understand that it should not be negative but the check as + // committed in revision 29090 is wrong. + // Effectively, this is always skipping the last bunch of the last + // channel. // if( (fBufferLeft <= 7 ) || ( fBufferLeft - tmpsize) <= 7) - if( fBufferLeft - tmpsize <= 7) + //if( fBufferLeft - tmpsize <= 7) + if( fBufferLeft < 0) { // printf("%s:%d, ERROR, attempt too access buffer outside allowed range\n", __FILE__ , __LINE__ ); return kFALSE; diff --git a/RAW/AliAltroDecoder.cxx b/RAW/AliAltroDecoder.cxx index 9a52267f9a8..b867f8b881c 100644 --- a/RAW/AliAltroDecoder.cxx +++ b/RAW/AliAltroDecoder.cxx @@ -92,6 +92,11 @@ Bool_t AliAltroDecoder::CheckPayloadTrailer() const Bool_t AliAltroDecoder::Decode() { + // Decodes the RCU payload (all altro channels in one go) from the DDL/Altro + // format to PC readable format. + // The 10 bit words of the 40/10 bit Altro format are transformed to separated + // integers. + if( fIsFatalCorruptedTrailer == kTRUE) { // printf("\n AliAltroDecoder::Decode(), WARNING, attempt to decode badly corrupted data\n"); @@ -157,6 +162,11 @@ Bool_t AliAltroDecoder::Decode() Bool_t AliAltroDecoder::NextChannel(AliAltroData *altroDataPtr) { + // Reads the next altro channel in the RCU payload after the RCU payload + // has been decoded. The channels are read starting from the end (backlinked list) + // Returns kTRUE as long as ther are unread channels in the payload + // Returns kFALSE when all the channels have been read. + if(fIsFatalCorruptedTrailer == kTRUE) { return kFALSE; @@ -170,6 +180,10 @@ Bool_t AliAltroDecoder::NextChannel(AliAltroData *altroDataPtr) Decode(); } + // an altro block must constist of at least 2 40bit words: + // - 40bit Altro trailer + // - at least 3 10bit words (bunch length, time bin, signal) padded to 40 bit + // we are reading backwards, so the index is already 1 inside the block if(fOutBufferIndex >= 7) { if((fOutBuffer[fOutBufferIndex] << 4 ) | ((fOutBuffer[fOutBufferIndex-1] & 0x3c0) >> 6) == 0x2aaa) @@ -202,7 +216,7 @@ Bool_t AliAltroDecoder::NextChannel(AliAltroData *altroDataPtr) if(fOutBufferIndex >= 0) { altroDataPtr->SetData( &fOutBuffer[fOutBufferIndex] ); - if(fOutBufferIndex > 0) fOutBufferIndex --; + fOutBufferIndex --; altroDataPtr->SetDataSize( fNAltro10bitWords ); return kTRUE; } @@ -292,6 +306,8 @@ int AliAltroDecoder::SetMemory(UChar_t *dtaPtr, UInt_t size) // Returns a negative value if an inconsistency in the data is detected // fIsFirstChannelOfPayload = kTRUE; + int iRet = 0; + fIsDecoded = kFALSE; if(dtaPtr == 0) { @@ -300,17 +316,14 @@ int AliAltroDecoder::SetMemory(UChar_t *dtaPtr, UInt_t size) return -99; } - if (size(f8PayloadSize+fkN32HeaderWords*sizeof(UInt_t))); return fSize-(f8PayloadSize+fkN32HeaderWords*sizeof(UInt_t)); } -- 2.43.0