Skip to content

Commit 0eba92e

Browse files
committed
dpl: insepect the o2 protocol validity on the output channel
1 parent 346042a commit 0eba92e

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

script/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ Make sure that only a single instance of the proxy is started.
5353
- `DATADIST_FEE_MASK=0xffff` Apply the mask if StfBuilder is configured to use the FeeID field as a O2::Subspecification (O2::Subspec = (RDH::FeeID & DATADIST_FEE_MASK))
5454

5555
- `DATADIST_FILE_READ_COUNT=N` Terminate after injecting set number of TF files. Data set will be repeated if necessary. Number of TimeFrames will be `DATADIST_FILE_READ_COUNT x Number of TFs per file`.
56+
57+
- `DATADIST_DEBUG_DPL_CHAN` When defined, data sent to DPL will be checked for consistency with the O2 data model. Note: will be slow with larger TimeFrames.

src/common/SubTimeFrameBuilder.cxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ void SubTimeFrameReadoutBuilder::addHbFrames(
199199

200200
lHdrMsg = mMemRes.newHeaderMessage(reinterpret_cast<char*>(lStack.data()), lStack.size());
201201
} else {
202-
auto lHdrMsgStack = Stack(lDataHdr);
203-
204-
lHdrMsg = mMemRes.newHeaderMessage(reinterpret_cast<char*>(lHdrMsgStack.data()), lHdrMsgStack.size());
202+
lHdrMsg = mMemRes.newHeaderMessage(reinterpret_cast<char*>(&lDataHdr), sizeof(lDataHdr));
205203
}
206204

207205
if (!lHdrMsg) {
@@ -213,7 +211,6 @@ void SubTimeFrameReadoutBuilder::addHbFrames(
213211
SubTimeFrame::StfData{ std::move(lHdrMsg), std::move(pHbFramesBegin[i]) }
214212
);
215213
}
216-
217214
}
218215

219216

src/common/SubTimeFrameDPL.cxx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,30 +89,9 @@ void StfToDplAdapter::visit(SubTimeFrame& pStf)
8989
}
9090
}
9191

92-
void StfToDplAdapter::sendToDpl(std::unique_ptr<SubTimeFrame>&& pStf)
92+
void StfToDplAdapter::inspect() const
9393
{
94-
if (!mRunning) {
95-
return;
96-
}
97-
98-
mMessages.clear();
99-
pStf->accept(*this);
100-
101-
#if 0
102-
DDDLOG("Content of the Stf:");
103-
uint64_t lMsgIdx = 0;
104-
for (auto lM = mMessages.cbegin(); lM != mMessages.cend(); ) {
105-
DDDLOG(" o2: message #{}", lMsgIdx++);
106-
o2::header::hexDump("o2 header", (*lM)->GetData(), (*lM)->GetSize());
107-
lM++;
108-
o2::header::hexDump("o2 payload", (*lM)->GetData(), std::clamp((*lM)->GetSize(), std::size_t(0), std::size_t(256)) );
109-
lM++;
110-
}
111-
#endif
112-
113-
#if !defined(NDEBUG)
11494
// check validity of the TF message sequence
115-
11695
const auto cMsgSize = mMessages.size() / 2;
11796

11897
DataHeader::TForbitType lFirstTForbit = ~ DataHeader::TForbitType{0};
@@ -207,9 +186,33 @@ void StfToDplAdapter::sendToDpl(std::unique_ptr<SubTimeFrame>&& pStf)
207186
// TODO: record the origin
208187
lIdx += lDh->splitPayloadParts;
209188
}
189+
}
210190

191+
void StfToDplAdapter::sendToDpl(std::unique_ptr<SubTimeFrame>&& pStf)
192+
{
193+
if (!mRunning) {
194+
return;
195+
}
196+
197+
mMessages.clear();
198+
pStf->accept(*this);
199+
200+
#if 0
201+
DDDLOG("Content of the Stf:");
202+
uint64_t lMsgIdx = 0;
203+
for (auto lM = mMessages.cbegin(); lM != mMessages.cend(); ) {
204+
DDDLOG(" o2: message #{}", lMsgIdx++);
205+
o2::header::hexDump("o2 header", (*lM)->GetData(), (*lM)->GetSize());
206+
lM++;
207+
o2::header::hexDump("o2 payload", (*lM)->GetData(), std::clamp((*lM)->GetSize(), std::size_t(0), std::size_t(256)) );
208+
lM++;
209+
}
211210
#endif
212211

212+
if (mInspectChannel) {
213+
inspect();
214+
}
215+
213216
mChan.Send(mMessages);
214217

215218
// make sure headers and chunk pointers don't linger

src/common/SubTimeFrameDPL.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class StfToDplAdapter : public ISubTimeFrameVisitor
3434
: mChan(pDplBridgeChan)
3535
{
3636
mMessages.reserve(1024);
37+
if (getenv("DATADIST_DEBUG_DPL_CHAN")) {
38+
mInspectChannel = true;
39+
}
3740
}
3841

3942
virtual ~StfToDplAdapter() = default;
@@ -45,8 +48,12 @@ class StfToDplAdapter : public ISubTimeFrameVisitor
4548
protected:
4649
void visit(SubTimeFrame& pStf) override;
4750

51+
void inspect() const;
52+
4853
private:
4954
std::atomic_bool mRunning = true;
55+
bool mInspectChannel = false;
56+
5057
std::vector<FairMQMessagePtr> mMessages;
5158
FairMQChannel& mChan;
5259
};

0 commit comments

Comments
 (0)