Skip to content

Commit

Permalink
Merge pull request #181 from slaclab/ESCRYODET-476
Browse files Browse the repository at this point in the history
Bug fix: emulator was using wrong number of channel variable
  • Loading branch information
jesusvasquez333 authored Nov 14, 2019
2 parents 93a74d0 + 97b6602 commit 60aed5f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/smurf/core/emulators/StreamDataEmulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,16 @@ void sce::StreamDataEmulator::genSinWave(ris::FramePtr &frame) {

SmurfHeaderROPtr<ris::FrameIterator> header = SmurfHeaderRO<ris::FrameIterator>::create(frame);

if ( sinChannel_ >= header->getNumberRows() ) {
uint32_t numChannels { header->getNumberChannels() };

if ( sinChannel_ >= numChannels ) {
eLog_->error("Configured sinChannel exceeds number of rows defined in the header.");
return;
}

if ( header->SmurfHeaderSize + (header->getNumberRows() * 2) != frame->getPayload() ) {
if ( header->SmurfHeaderSize + (numChannels * 2) != frame->getPayload() ) {
eLog_->error("Received frame does not match expected size. Size=%i, header=%i, payload=%i",
frame->getPayload(), header->SmurfHeaderSize, header->getNumberRows()*2);
frame->getPayload(), header->SmurfHeaderSize, numChannels*2);
return;
}

Expand All @@ -160,9 +162,9 @@ void sce::StreamDataEmulator::genSinWave(ris::FramePtr &frame) {
fPtr += header->SmurfHeaderSize;

// Create uint16 accessor to the data
ris::FrameAccessor<uint16_t> dPtr(fPtr,header->getNumberRows());
ris::FrameAccessor<uint16_t> dPtr(fPtr, numChannels);

dPtr[sinChannel_] = int((float)sinBaseline_ +
dPtr[sinChannel_] = int((float)sinBaseline_ +
(float)sinAmplitude_ * sin((float)sinCount_/(float)sinPeriod_));

if ( ++sinCount_ == sinPeriod_ ) sinCount_ = 0;
Expand Down

0 comments on commit 60aed5f

Please sign in to comment.