From 89c1ada005878db1cf0056da1dd937c025a3ab78 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Fri, 28 Feb 2025 23:02:02 +0300 Subject: [PATCH] Remove command parsing to simplify the code --- flix/cli.ino | 7 +------ flix/util.h | 10 ---------- gazebo/flix.h | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/flix/cli.ino b/flix/cli.ino index 5114be5..9a5c179 100644 --- a/flix/cli.ino +++ b/flix/cli.ino @@ -33,12 +33,7 @@ const char* motd = "mfr, mfl, mrr, mrl - test motor (remove props)\n" "reset - reset drone's state\n"; -void doCommand(String str) { - // parse command - String command, arg0, arg1; - splitString(str, command, arg0, arg1); - - // execute command +void doCommand(const String& command) { if (command == "help" || command == "motd") { Serial.println(motd); } else if (command == "ps") { diff --git a/flix/util.h b/flix/util.h index d791ac7..9f61df8 100644 --- a/flix/util.h +++ b/flix/util.h @@ -42,13 +42,3 @@ void printArray(T arr[], int size) { void disableBrownOut() { REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ENA); } - -// Trim and split string by spaces -void splitString(String& str, String& token0, String& token1, String& token2) { - str.trim(); - char chars[str.length() + 1]; - str.toCharArray(chars, str.length() + 1); - token0 = strtok(chars, " "); - token1 = strtok(NULL, " "); // String(NULL) creates empty string - token2 = strtok(NULL, ""); -} diff --git a/gazebo/flix.h b/gazebo/flix.h index fa53012..ab3c015 100644 --- a/gazebo/flix.h +++ b/gazebo/flix.h @@ -34,7 +34,7 @@ void controlTorque(); void showTable(); void sendMotors(); bool motorsActive(); -void doCommand(String str); +void doCommand(const String& command); void normalizeRC(); void printRCCal(); void processMavlink();