From d199f200ec840eefa93d7d0120fe677ee797e9e0 Mon Sep 17 00:00:00 2001
From: Alessio Igor Bogani <alessio.bogani@elettra.eu>
Date: Thu, 18 Apr 2024 12:08:59 +0200
Subject: [PATCH] Flush extra bytes

---
 src/IPCMini.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/IPCMini.cpp b/src/IPCMini.cpp
index be55b34..2b1582d 100644
--- a/src/IPCMini.cpp
+++ b/src/IPCMini.cpp
@@ -1450,6 +1450,11 @@ void IPCMini::receive_message(vector<unsigned char> &payload)
 	Serial2Client::read_until(ETX, message);
 	Serial2Client::read(CRC_LENGTH, crc);
 	assert(Serial2Client::input_length() == 0);
+	int ilen = Serial2Client::input_length();
+	if (ilen > 0) {
+		vector<unsigned char> discard;
+		Serial2Client::read(ilen, discard);
+	}
 
 	message.insert(message.end(), crc.begin(), crc.end());
 
-- 
GitLab