diff --git a/include/serial.h b/include/serial.h index 44a257f..6ddc17f 100644 --- a/include/serial.h +++ b/include/serial.h @@ -268,6 +268,7 @@ namespace serial { auto endTime = std::chrono::system_clock::now() + std::chrono::milliseconds(timeout); ser.flushReceiver(); + std::string resp; std::string reallyCommand = std::string(command) + endChar; ser.writeString(reallyCommand.c_str()); Log("Send : " + reallyCommand); @@ -278,8 +279,10 @@ namespace serial { auto size = ser.readBytes(buffer.get(), availableSize, timeout); buffer[size] = '\0'; auto str = std::string(buffer.get()); - if (size > 0) + if (size > 0){ Log("Receive: " + str); + resp += str; + } if (((str.find(expect) != std::string::npos) && ...)) { return true; } @@ -307,7 +310,7 @@ namespace serial { resp += str; if (size > 0) Log("Receive: " + str); - if (((str.find(expect) != std::string::npos) && ...)) { + if (((resp.find(expect) != std::string::npos) && ...)) { return resp; } }