Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Fix console command parsing

Oleg Kalacheve53051a3490c
diff --git a/flix/util.h b/flix/util.h
index ffb57b3..cda50f3 100644
--- a/flix/util.h
+++ b/flix/util.h
@@ -36,11 +36,14 @@ float wrapAngle(float angle) {
// Trim and split string by spaces
void splitString(String& str, String& token0, String& token1, String& token2) {
str.trim();
+ if (str.isEmpty()) return;
char chars[str.length() + 1];
str.toCharArray(chars, str.length() + 1);
token0 = strtok(chars, " ");
- token1 = strtok(NULL, " "); // String(NULL) creates empty string
+ token1 = strtok(NULL, " ");
token2 = strtok(NULL, "");
+ if (token1.c_str() == NULL) token1 = "";
+ if (token2.c_str() == NULL) token2 = "";
}
// Rate limiter