优化Until逻辑
This commit is contained in:
parent
6605f0604a
commit
74e5d380f5
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user