@@ -508,13 +508,13 @@ class ProgramDmaBench : public Program
508508 size_t readoutBytes = 0 ;
509509 auto superpageAddress = mBufferBaseAddress + superpageInfo.bufferOffset ;
510510
511- fetchAddSuperpagesReadOut ();
511+ auto superpageCount = fetchAddSuperpagesReadOut ();
512512
513513 bool atStartOfSuperpage = true ;
514514 while ((readoutBytes < superpageInfo.effectiveSize ) && !isStopDma ()) {
515515 auto pageAddress = superpageAddress + readoutBytes;
516516 auto readoutCount = fetchAddDmaPagesReadOut ();
517- size_t pageSize = readoutPage (pageAddress, readoutCount, atStartOfSuperpage);
517+ size_t pageSize = readoutPage (pageAddress, readoutCount, superpageCount, atStartOfSuperpage);
518518
519519 atStartOfSuperpage = false ; // Update the boolean value as soon as we move...
520520
@@ -558,15 +558,15 @@ class ProgramDmaBench : public Program
558558 auto size = mChannel ->getReadyQueueSize ();
559559 for (int i = 0 ; i < size; ++i) {
560560 auto superpage = mChannel ->popSuperpage ();
561- fetchAddSuperpagesReadOut ();
561+ auto superpageCount = fetchAddSuperpagesReadOut ();
562562 if ((mDataSource == DataSource::Fee) || (mDataSource == DataSource::Ddg)) {
563563 auto superpageAddress = mBufferBaseAddress + superpage.getOffset ();
564564 size_t readoutBytes = 0 ;
565565 bool atStartOfSuperpage = true ;
566566 while ((readoutBytes < superpage.getReceived ())) { // At least one more dma page fits in the superpage
567567 auto pageAddress = superpageAddress + readoutBytes;
568568 auto readoutCount = fetchAddDmaPagesReadOut ();
569- size_t pageSize = readoutPage (pageAddress, readoutCount, atStartOfSuperpage);
569+ size_t pageSize = readoutPage (pageAddress, readoutCount, superpageCount, atStartOfSuperpage);
570570 atStartOfSuperpage = false ; // Update the boolean value as soon as we move...
571571 readoutBytes += pageSize;
572572 }
@@ -588,12 +588,23 @@ class ProgramDmaBench : public Program
588588 return payload[0 ];
589589 };
590590
591- size_t readoutPage (uintptr_t pageAddress, int64_t readoutCount, bool atStartOfSuperpage)
591+ size_t readoutPage (uintptr_t pageAddress, int64_t readoutCount, int64_t superpageCount, bool atStartOfSuperpage)
592592 {
593593 size_t pageSize = (mDataSource == DataSource::Internal) ? mPageSize : DataFormat::getOffset (reinterpret_cast <const char *>(pageAddress));
594594
595+ bool isEmpty = false ;
596+ if (pageSize != mPageSize ) {
597+ pageSize = mPageSize ;
598+ isEmpty = true ;
599+ // write to file
600+ uint32_t emptySP = 0x0badf00d ;
601+ for (int i = 0 ; i < 4 ; i++) { // Marker is 128bits long
602+ mReadoutStream .write (reinterpret_cast <const char *>(&emptySP), sizeof (emptySP));
603+ }
604+ }
605+
595606 // Read out to file
596- printToFile (pageAddress, pageSize, readoutCount, atStartOfSuperpage);
607+ printToFile (pageAddress, pageSize, readoutCount, superpageCount, atStartOfSuperpage, isEmpty );
597608
598609 // Data error checking
599610 if (!mOptions .noErrorCheck ) {
@@ -848,7 +859,7 @@ class ProgramDmaBench : public Program
848859 mPacketCounters [linkId] = packetCounter;
849860 }
850861
851- if (!checkTimeFrameAlignment (pageAddress, atStartOfSuperpage)) {
862+ if (false && !checkTimeFrameAlignment (pageAddress, atStartOfSuperpage)) {
852863 // log TF not at the beginning of the superpage error
853864 mErrorCount ++;
854865 if (mErrorCount < MAX_RECORDED_ERRORS) {
@@ -1015,26 +1026,38 @@ class ProgramDmaBench : public Program
10151026 }
10161027
10171028 // / Prints the page to a file in ASCII or binary format if such output is enabled
1018- void printToFile (uintptr_t pageAddress, size_t pageSize, int64_t pageNumber, bool atStartOfSuperpage)
1029+ void printToFile (uintptr_t pageAddress, size_t pageSize, int64_t pageNumber, int64_t superpageNumber, bool atStartOfSuperpage, bool isEmpty = false )
10191030 {
10201031 auto page = reinterpret_cast <const volatile uint32_t *>(pageAddress);
10211032 auto pageSize32 = pageSize / sizeof (uint32_t );
10221033
10231034 if (mOptions .fileOutputAscii ) {
10241035 if (atStartOfSuperpage && mOptions .printSuperpageChange ) {
1025- mReadoutStream << " New Superpage\n " ;
1036+ mReadoutStream << " Superpage # " << std::hex << " 0x " << superpageNumber << ' \n ' ;
10261037 }
1027- mReadoutStream << " Event #" << pageNumber << ' \n ' ;
1038+ // TODO: for debugging: maybe add an option here?
1039+ if (isEmpty) {
1040+ mReadoutStream << " !!EMPTY DMA PAGE!!\n " ;
1041+ }
1042+ mReadoutStream << " Event #" << std::hex << " 0x" << pageNumber << ' \n ' ;
10281043 uint32_t perLine = 8 ;
10291044
10301045 for (uint32_t i = 0 ; i < pageSize32; i += perLine) {
10311046 for (uint32_t j = 0 ; j < perLine; ++j) {
1032- mReadoutStream << page[i + j] << ' ' ;
1047+ mReadoutStream << std::hex << " 0x" << std::setw (8 ) << page[i + j] << ' ' ;
1048+ mReadoutStream << ' \t ' ;
10331049 }
10341050 mReadoutStream << ' \n ' ;
10351051 }
10361052 mReadoutStream << ' \n ' ;
10371053 } else if (mOptions .fileOutputBin ) {
1054+ // TODO: for debugging
1055+ if (isEmpty) {
1056+ uint32_t emptySP = 0xdeadbeef ;
1057+ for (int i = 0 ; i < 4 ; i++) { // Marker is 128bits long
1058+ mReadoutStream .write (reinterpret_cast <const char *>(&emptySP), sizeof (emptySP));
1059+ }
1060+ }
10381061 if (atStartOfSuperpage && mOptions .printSuperpageChange ) {
10391062 uint32_t newSP = 0x0badf00d ;
10401063 for (int i = 0 ; i < 4 ; i++) { // Marker is 128bits long
0 commit comments