@@ -123,19 +123,12 @@ void ReadoutDevice::SendingThread()
123123 // finish an STF every ~1/45 seconds
124124 static const auto cDataTakingStart = std::chrono::high_resolution_clock::now ();
125125 static constexpr auto cStfInterval = std::chrono::microseconds (22810 );
126- static uint64_t lNumberSentStfs = 0 ;
127- static uint64_t lCurrentTfId = 0 ;
126+ uint64_t lNumberSentStfs = 0 ;
127+ uint64_t lCurrentTfId = std::chrono::duration_cast<std::chrono::microseconds>(
128+ std::chrono::high_resolution_clock::now ().time_since_epoch ()).count () / cStfInterval.count ();;
128129
129130 while (IsRunningState ()) {
130131
131- auto isStfFinished =
132- (std::chrono::high_resolution_clock::now () - cDataTakingStart) - (lNumberSentStfs * cStfInterval) > cStfInterval;
133-
134- if (isStfFinished) {
135- lNumberSentStfs += 1 ;
136- lCurrentTfId = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now ().time_since_epoch ()).count () / cStfInterval.count ();
137- }
138-
139132 ReadoutLinkO2Data lCruLinkData;
140133 if (!mCruMemoryHandler ->getLinkData (lCruLinkData)) {
141134 DDLOG (fair::Severity::INFO) << " GetLinkData failed. Stopping interface thread." ;
@@ -145,15 +138,26 @@ void ReadoutDevice::SendingThread()
145138 mFreeSuperpagesSamples .Fill (mCruMemoryHandler ->free_superpages ());
146139
147140 // check no data signal
148- if (lCruLinkData.mLinkDataHeader .subSpecification ==
149- o2::header::DataHeader::SubSpecificationType (-1 )) {
141+ if (lCruLinkData.mLinkHeader .mFlags .mIsRdhFormat == 0 ) {
150142 // DDLOG(fair::Severity::WARN) << "No Superpages left! Losing data...";
151143 }
152144
153- ReadoutSubTimeframeHeader lHBFHeader;
145+ ReadoutSubTimeframeHeader lHBFHeader = lCruLinkData. mLinkHeader ;
154146 lHBFHeader.mTimeFrameId = lCurrentTfId;
155- lHBFHeader.mNumberHbf = lCruLinkData.mLinkRawData .size ();
156- lHBFHeader.mLinkId = lCruLinkData.mLinkDataHeader .subSpecification ;
147+ lHBFHeader.mTimeframeOrbitFirst = lCurrentTfId * 256 ;
148+ lHBFHeader.mTimeframeOrbitLast = (lCurrentTfId + 1 ) * 256 - 1 ;
149+ lHBFHeader.mFlags .mLastTFMessage = 0 ;
150+
151+ // last one?
152+ auto isStfFinished =
153+ (std::chrono::high_resolution_clock::now () - cDataTakingStart) - (lNumberSentStfs * cStfInterval) > cStfInterval;
154+
155+ if (isStfFinished) {
156+ lNumberSentStfs += 1 ;
157+ lCurrentTfId = std::chrono::duration_cast<std::chrono::microseconds>(
158+ std::chrono::high_resolution_clock::now ().time_since_epoch ()).count () / cStfInterval.count ();
159+ lHBFHeader.mFlags .mLastTFMessage = 1 ;
160+ }
157161
158162 assert (mDataBlockMsgs .empty ());
159163 mDataBlockMsgs .reserve (lCruLinkData.mLinkRawData .size ());
0 commit comments