Skip to content
Snippets Groups Projects
Commit 48f13821 authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

StsDigi: Add more error handling against timestamp overflows.

parent cb194272
No related branches found
No related tags found
1 merge request!538StsDigi: Add more error handling against timestamp overflows.
......@@ -203,6 +203,10 @@ int32_t CbmStsAddress::PackDigiAddress(int32_t address)
| kMask[1][kStsModule] << kShift[1][kStsModule];
int32_t ret = (address & kDMask) >> kShift[1][kStsUnit];
// Check that no bits were set, that are stripped by this function.
assert(address == UnpackDigiAddress(ret));
return ret;
}
// -------------------------------------------------------------------------
......
......@@ -37,7 +37,7 @@ void CbmStsDigi::PackAddressAndTime(int32_t newAddress, uint32_t newTime)
uint32_t lowerAddr = packedAddr & ((1 << kNumLowerAddrBits) - 1);
fAddress = lowerAddr;
fTime = (highestBitAddr << kNumTimestampBits) | newTime;
fTime = (highestBitAddr << kNumTimestampBits) | (kTimestampMask & newTime);
}
int32_t CbmStsDigi::UnpackAddress() const
......
......@@ -47,8 +47,9 @@ public:
** @param time Measurement time [ns]
** @param charge Charge [ADC units]
**/
CbmStsDigi(int32_t address, int32_t channel, uint32_t time, uint16_t charge)
CbmStsDigi(int32_t address, int32_t channel, double time, uint16_t charge)
{
assert(time >= 0 && time <= kMaxTimestamp);
PackAddressAndTime(address, time);
PackChannelAndCharge(channel, charge);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment