From e6e0258d9930818befcf551d5b00ea8f38d69ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kruli=C5=A1?= Date: Mon, 4 Mar 2024 15:13:29 +0100 Subject: [PATCH] Fixed trimming of serial messages loaded from a file. --- GenericTester/dataio.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GenericTester/dataio.cpp b/GenericTester/dataio.cpp index 5d5cbed..e761584 100644 --- a/GenericTester/dataio.cpp +++ b/GenericTester/dataio.cpp @@ -39,6 +39,11 @@ logtime_t loadInputData(std::istream& sin, FunshieldSimulationController& funshi if (newState != '\0') { std::getline(ss, serialInput, '\0'); serialInput = newState + serialInput; + + // trim whitespace at the end (may be \r or extra trailing spaces) + serialInput.erase(std::find_if(serialInput.rbegin(), serialInput.rend(), [](unsigned char ch) { + return !std::isspace(ch); + }).base(), serialInput.end()); } funshield.getArduino().enqueueSerialInputEvent(serialInput, time);