Skip to content

Commit edfcc26

Browse files
committed
[bench-dma] Add option to print sp change to file
1 parent d2aae00 commit edfcc26

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/CommandLineUtilities/ProgramDmaBench.cxx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ class ProgramDmaBench : public Program
182182
options.add_options()("pause-read",
183183
po::value<uint64_t>(&mOptions.pauseRead)->default_value(10),
184184
"Readout thread pause time in microseconds if no work can be done");
185+
options.add_options()("print-sp-change",
186+
po::bool_switch(&mOptions.printSuperpageChange),
187+
"Print superpage change market when printing to file");
185188
options.add_options()("random-pause",
186189
po::bool_switch(&mOptions.randomPause),
187190
"Randomly pause readout");
@@ -603,7 +606,7 @@ class ProgramDmaBench : public Program
603606
size_t pageSize = (mDataSource == DataSource::Internal) ? mPageSize : DataFormat::getOffset(reinterpret_cast<const char*>(pageAddress));
604607

605608
// Read out to file
606-
printToFile(pageAddress, pageSize, readoutCount);
609+
printToFile(pageAddress, pageSize, readoutCount, atStartOfSuperpage);
607610

608611
// Data error checking
609612
if (!mOptions.noErrorCheck) {
@@ -834,16 +837,16 @@ class ProgramDmaBench : public Program
834837
// check that the TimeFrame starts at the beginning of the superpage
835838
const auto triggerType = DataFormat::getTriggerType(reinterpret_cast<const char*>(pageAddress));
836839
const auto orbit = DataFormat::getOrbit(reinterpret_cast<const char*>(pageAddress));
837-
const auto pagesCounter = DataFormat::getPagesCounter(reinterpret_cast<const char*>(pageAddress));
838-
const auto bunchCrossing = DataFormat::getBunchCrossing(reinterpret_cast<const char*>(pageAddress));
840+
//const auto pagesCounter = DataFormat::getPagesCounter(reinterpret_cast<const char*>(pageAddress));
841+
//const auto bunchCrossing = DataFormat::getBunchCrossing(reinterpret_cast<const char*>(pageAddress));
839842

840843
//std::cout << atStartOfSuperpage << " 0x" << std::hex << orbit << " 0x" << std::hex << mNextTFOrbit << std::endl;
841844

842845
if (Utilities::getBit(triggerType, 9) == 0x1 || Utilities::getBit(triggerType, 7) == 0x1) { // If SOX, use current orbit as the first one
843846
mNextTFOrbit = (orbit + mTimeFrameLength) % (0x100000000);
844847
} else if (orbit >= mNextTFOrbit) {
845848
// next orbit should be previous orbit + time frame length
846-
if (!atStartOfSuperpage) { // but not more than orbit + 2 * time frame length
849+
if (!atStartOfSuperpage) {
847850
// log TF not at the beginning of the superpage error
848851
mErrorCount++;
849852
if (mErrorCount < MAX_RECORDED_ERRORS) {
@@ -1014,12 +1017,15 @@ class ProgramDmaBench : public Program
10141017
}
10151018

10161019
/// Prints the page to a file in ASCII or binary format if such output is enabled
1017-
void printToFile(uintptr_t pageAddress, size_t pageSize, int64_t pageNumber)
1020+
void printToFile(uintptr_t pageAddress, size_t pageSize, int64_t pageNumber, bool atStartOfSuperpage)
10181021
{
10191022
auto page = reinterpret_cast<const volatile uint32_t*>(pageAddress);
10201023
auto pageSize32 = pageSize / sizeof(uint32_t);
10211024

10221025
if (mOptions.fileOutputAscii) {
1026+
if (atStartOfSuperpage && mOptions.printSuperpageChange) {
1027+
mReadoutStream << "New Superpage\n";
1028+
}
10231029
mReadoutStream << "Event #" << pageNumber << '\n';
10241030
uint32_t perLine = 8;
10251031

@@ -1031,6 +1037,12 @@ class ProgramDmaBench : public Program
10311037
}
10321038
mReadoutStream << '\n';
10331039
} else if (mOptions.fileOutputBin) {
1040+
if (atStartOfSuperpage && mOptions.printSuperpageChange) {
1041+
uint32_t newSP = 0x0badf00d;
1042+
for (int i = 0; i < 4; i++) { // Marker is 128bits long
1043+
mReadoutStream.write(reinterpret_cast<const char*>(&newSP), sizeof(newSP));
1044+
}
1045+
}
10341046
// TODO Is there a more elegant way to write from volatile memory?
10351047
mReadoutStream.write(reinterpret_cast<const char*>(pageAddress), pageSize);
10361048
}
@@ -1140,6 +1152,7 @@ class ProgramDmaBench : public Program
11401152
bool byteCountEnabled = false;
11411153
bool bypassFirmwareCheck = false;
11421154
uint32_t timeFrameLength = 256;
1155+
bool printSuperpageChange = false;
11431156
} mOptions;
11441157

11451158
/// The DMA channel

0 commit comments

Comments
 (0)