From faaf91971a9ed272159ea0cbea122206d924c617 Mon Sep 17 00:00:00 2001 From: barry-ha Date: Mon, 11 Mar 2024 20:44:11 -0700 Subject: [PATCH] fixed commands sent by Arduino IDE --- commands.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/commands.cpp b/commands.cpp index e067818..91c29ec 100644 --- a/commands.cpp +++ b/commands.cpp @@ -211,12 +211,25 @@ void run_unittest() { runUnitTest(); // see "unit_test.cpp" } +void removeCRLF(char *pBuffer) { + // remove 0x0d and 0x0a from character arrays, shortening the array in-place + const char key[] = "\r\n"; + char *pch = strpbrk(pBuffer, key); + while (pch != NULL) { + strcpy(pch, pch + 1); + pch = strpbrk(pBuffer, key); + } +} + // do the thing void processCommand(char *cmd) { for (char *p = cmd; *p != '\0'; ++p) { // convert to lower case *p = tolower(*p); } + + removeCRLF(cmd); // Arduino IDE can optionally add \r\n + Serial.print(cmd); Serial.print(": ");