Skip to content

Commit d2aae00

Browse files
committed
[bench-dma] Add TF information in case of misalignment error
1 parent 46e07b7 commit d2aae00

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/CommandLineUtilities/ProgramDmaBench.cxx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ class ProgramDmaBench : public Program
304304
getLogger() << "Fast check enabled" << endm;
305305
}
306306
mMaxRdhPacketCounter = mOptions.maxRdhPacketCounter;
307-
getLogger() << "Maximum RDH packet counter" << mMaxRdhPacketCounter << endm;
307+
getLogger() << "Maximum RDH packet counter " << mMaxRdhPacketCounter << endm;
308+
mTimeFrameLength = mOptions.timeFrameLength;
309+
getLogger() << "TimeFrame length " << mTimeFrameLength << endm;
308310
}
309311

310312
// Get DMA channel object
@@ -835,23 +837,21 @@ class ProgramDmaBench : public Program
835837
const auto pagesCounter = DataFormat::getPagesCounter(reinterpret_cast<const char*>(pageAddress));
836838
const auto bunchCrossing = DataFormat::getBunchCrossing(reinterpret_cast<const char*>(pageAddress));
837839

838-
//std::cout << atStartOfSuperpage << " " << triggerType << " " << orbit << " " << mNextTFOrbit << " " << bunchCrossing << " " << pagesCounter << std::endl;
839-
//std::cout << atStartOfSuperpage << " " << orbit << " " << mNextTFOrbit << std::endl;
840+
//std::cout << atStartOfSuperpage << " 0x" << std::hex << orbit << " 0x" << std::hex << mNextTFOrbit << std::endl;
840841

841842
if (Utilities::getBit(triggerType, 9) == 0x1 || Utilities::getBit(triggerType, 7) == 0x1) { // If SOX, use current orbit as the first one
842-
mNextTFOrbit = (orbit + mOptions.timeFrameLength) % (0x100000000);
843-
//std::cout << mNextTFOrbit << std::endl;
844-
} else if (orbit >= mNextTFOrbit) { // next orbit should be previous orbit + time frame length
845-
if (!atStartOfSuperpage || (orbit >= (mNextTFOrbit + mOptions.timeFrameLength) % (0x100000000))) { // but not more than orbit + 2 * time frame length
843+
mNextTFOrbit = (orbit + mTimeFrameLength) % (0x100000000);
844+
} else if (orbit >= mNextTFOrbit) {
845+
// next orbit should be previous orbit + time frame length
846+
if (!atStartOfSuperpage) { // but not more than orbit + 2 * time frame length
846847
// log TF not at the beginning of the superpage error
847848
mErrorCount++;
848-
//std::cout << "ERROR" << std::endl;
849849
if (mErrorCount < MAX_RECORDED_ERRORS) {
850-
mErrorStream << b::format("[RDHERR]\tevent:%1% l:%2% payloadBytes:%3% size:%4% packet_cnt:%5% mpacket_cnt:%6% levent:%7% orbit:%8%: TF unaligned w/ start of superpage\n") % eventNumber % linkId % memBytes % pageSize % packetCounter % mPacketCounters[linkId] % mEventCounters[linkId] % orbit;
850+
mErrorStream << b::format("[RDHERR]\tevent:%1% l:%2% payloadBytes:%3% size:%4% packet_cnt:%5% orbit:%6$#x nextTForbit:%7$#x atSPStart:%8% TF unaligned w/ start of superpage\n") % eventNumber % linkId % memBytes % pageSize % packetCounter % orbit % mNextTFOrbit % atStartOfSuperpage;
851851
}
852852
}
853853
// Update next TF orbit expected
854-
mNextTFOrbit = (mNextTFOrbit + mOptions.timeFrameLength) % (0x100000000);
854+
mNextTFOrbit = (orbit / mTimeFrameLength) * (mTimeFrameLength + 1);
855855
//std::cout << mNextTFOrbit << std::endl;
856856
}
857857

@@ -1247,6 +1247,9 @@ class ProgramDmaBench : public Program
12471247

12481248
/// The orbit number that coincides with the next TimeFrame
12491249
uint32_t mNextTFOrbit = 0x0;
1250+
1251+
/// The orbit number that coincides with the next TimeFrame
1252+
uint32_t mTimeFrameLength = 0x0;
12501253
};
12511254

12521255
int main(int argc, char** argv)

0 commit comments

Comments
 (0)