@@ -641,7 +641,12 @@ class ProgramDmaBench: public Program
641641 bool hasError = true ;
642642 switch (mCardType ) {
643643 case CardType::Crorc: // TODO: Implement fast error checking for CRORC
644- hasError = checkErrorsCrorc (pageAddress, pageSize, readoutCount, linkId, mOptions .loopbackModeString );
644+ mEventCounters [linkId] = (mEventCounters [linkId] + 1 ) % EVENT_COUNTER_INITIAL_VALUE;
645+ if (mEventCounters [linkId] % mErrorCheckFrequency == 0 ) {
646+ hasError = checkErrorsCrorc (pageAddress, pageSize, readoutCount, linkId, mOptions .loopbackModeString );
647+ } else {
648+ hasError = false ;
649+ }
645650 break ;
646651 case CardType::Cru:
647652 mEventCounters [linkId] = (mEventCounters [linkId] + 1 ) % EVENT_COUNTER_INITIAL_VALUE;
@@ -834,8 +839,7 @@ class ProgramDmaBench: public Program
834839
835840 bool checkErrorsCrorcExternal (uintptr_t pageAddress, size_t pageSize, int64_t eventNumber, int linkId)
836841 {
837- // TODO: Clean this up
838- // DataFormat is the same as the CRU
842+ // TODO: Clean this up; DataFormat is common with the CRU
839843 const auto memBytes = Cru::DataFormat::getEventSize (reinterpret_cast <const char *>(pageAddress));
840844 if (memBytes < 40 || memBytes > pageSize) {
841845 mErrorCount ++;
@@ -854,7 +858,7 @@ class ProgramDmaBench: public Program
854858 b::format (" resync packet counter for e%d l:%d packet_cnt:%x mpacket_cnt:%x, le:%d \n " ) % eventNumber % linkId % packetCounter %
855859 mPacketCounters [linkId] % mEventCounters [linkId];
856860 mPacketCounters [linkId] = packetCounter;
857- } else if (((mPacketCounters [linkId] + 1 ) % (mMaxRdhPacketCounter + 1 )) != packetCounter) {
861+ } else if (((mPacketCounters [linkId] + mErrorCheckFrequency ) % (mMaxRdhPacketCounter + 1 )) != packetCounter) {
858862 mErrorCount ++;
859863 if (mErrorCount < MAX_RECORDED_ERRORS) {
860864 mErrorStream <<
@@ -866,12 +870,9 @@ class ProgramDmaBench: public Program
866870 mPacketCounters [linkId] = packetCounter;
867871 }
868872
869- // TODO: fast check
870- /*
871- if (mFastCheckEnabled) {
872- return false;
873- }
874- */
873+ if (mFastCheckEnabled ) {
874+ return false ;
875+ }
875876
876877 // Every page starts from a clean slate
877878 uint32_t dataCounter = 0 ;
@@ -888,10 +889,10 @@ class ProgramDmaBench: public Program
888889 };
889890
890891 uint32_t offset = dataCounter;
891- size_t pageSize32 = (memBytes - Cru::DataFormat::getHeaderSize ())/sizeof (uint32_t ); // Addressable size of dma page (after RDH)
892+ size_t pageSize32 = (memBytes - Cru::DataFormat::getHeaderSize ())/sizeof (uint32_t ); // Addressable size of dma page (after RDH)
892893
893- for (size_t i=0 ; i < pageSize32; i++) { // iterate through dmaPage
894- if (i == (pageSize32 - 1 )) { // skip the DTSW at the end of the page
894+ for (size_t i=0 ; i < pageSize32; i++) { // iterate through dmaPage
895+ if (i == (pageSize32 - 1 )) { // skip the DTSW at the end of the page
895896 continue ;
896897 }
897898 checkValue (i, offset, page[i]);
@@ -904,7 +905,16 @@ class ProgramDmaBench: public Program
904905 bool checkErrorsCrorcInternal (uintptr_t pageAddress, size_t pageSize, int64_t eventNumber, int linkId)
905906 {
906907 uint32_t dataCounter = 0 ; // always start at 0 for CRUs Internal loopbacks
907- uint32_t packetCounter = mPacketCounters [linkId] + 1 ;
908+
909+ uint32_t packetCounter;
910+ if (mPacketCounters [linkId] == PACKET_COUNTER_INITIAL_VALUE) {
911+ mErrorStream <<
912+ b::format (" resync packet counter for e%d l:%d packet_cnt:%x mpacket_cnt:%x, le:%d \n " ) % eventNumber % linkId % packetCounter %
913+ mPacketCounters [linkId] % mEventCounters [linkId];
914+ packetCounter = 0 ;
915+ } else {
916+ packetCounter = (mPacketCounters [linkId] + mErrorCheckFrequency ) % (0x100000000 );
917+ }
908918
909919 auto page = reinterpret_cast <const volatile uint32_t *>(pageAddress);
910920
@@ -933,7 +943,7 @@ class ProgramDmaBench: public Program
933943 offset = (offset+1 ) % (0x100000000 );
934944 }
935945
936- mPacketCounters [linkId] = ( mPacketCounters [linkId] + 1 ) % ( 0x100000000 ) ;
946+ mPacketCounters [linkId] = packetCounter ;
937947
938948 return foundError;
939949 }
0 commit comments