Skip to content

Commit

Permalink
Fixed trimming of serial messages loaded from a file.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Mar 4, 2024
1 parent 69ba8c8 commit e6e0258
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions GenericTester/dataio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e6e0258

Please sign in to comment.