From b52f445a52227b4da11b7ae5a3c294f697b00908 Mon Sep 17 00:00:00 2001 From: Niklas Eiling Date: Wed, 14 Aug 2024 09:49:30 +0200 Subject: [PATCH] fpga: handle receving more data than size of configured signals Signed-off-by: Niklas Eiling --- lib/nodes/fpga.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/nodes/fpga.cpp b/lib/nodes/fpga.cpp index b22030bad..ac0cac59a 100644 --- a/lib/nodes/fpga.cpp +++ b/lib/nodes/fpga.cpp @@ -270,6 +270,12 @@ int FpgaNode::fastRead(Sample *smps[], unsigned cnt) { smp->length = 0; for (unsigned i = 0; i < MIN(read / sizeof(uint32_t), smp->capacity); i++) { + if (i >= in.signals->size()) { + logger->warn( + "Received more data than expected. Maybe the descriptor cache needs " + "to be invalidated?. Ignoring the rest of the data."); + break; + } if (in.signals->getByIndex(i)->type == SignalType::INTEGER) { smp->data[i].i = static_cast((*accessorRx)[i]); } else {