From 4f1d31f9b7bf018c72e7a8b6268f28cf12d5914f Mon Sep 17 00:00:00 2001 From: David Cermak Date: Mon, 6 Dec 2021 11:12:00 +0100 Subject: [PATCH] fix(esp_modem): Fix battery status parse Variable `pos` was meant to hold position of first `,` (comma) appearance in the parsed string, but due to wrong parantheses it contained the boolean representation of not equal to `string::npos` --- components/esp_modem/src/esp_modem_command_library.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_modem/src/esp_modem_command_library.cpp b/components/esp_modem/src/esp_modem_command_library.cpp index a4743c13a..77957afb2 100644 --- a/components/esp_modem/src/esp_modem_command_library.cpp +++ b/components/esp_modem/src/esp_modem_command_library.cpp @@ -167,7 +167,7 @@ command_result get_battery_status(CommandableIf *t, int &voltage, int &bcs, int // Parsing +CBC: ,, out = out.substr(pattern.size()); int pos, value, property = 0; - while ((pos = out.find(',') != std::string::npos)) { + while ((pos = out.find(',')) != std::string::npos) { if (std::from_chars(out.data(), out.data() + pos, value).ec == std::errc::invalid_argument) { return command_result::FAIL; }