fix for back-to-back issue
This commit is contained in:
+15
-2
@@ -282,11 +282,24 @@ class Meshcore {
|
||||
*/
|
||||
public function sendBinaryRequest(string $request): mixed {
|
||||
CoreProtocol::writeFrame($this->serial, chr(CoreProtocol::CMD_SEND_BINARY_REQ) . $request);
|
||||
$response = CoreProtocol::readFrame($this->serial);
|
||||
|
||||
do {
|
||||
$response = CoreProtocol::readFrame($this->serial);
|
||||
|
||||
}
|
||||
while(
|
||||
ord($response) != CoreProtocol::RESP_CODE_SENT &&
|
||||
ord($response) != CoreProtocol::ERR_CODE_NOT_FOUND &&
|
||||
ord($response) != CoreProtocol::ERR_CODE_NOT_FOUND
|
||||
);
|
||||
|
||||
return CoreParser::parseResponse($response);
|
||||
}
|
||||
|
||||
public function readFrame(): mixed {
|
||||
return CoreProtocol::readFrame($this->serial);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $tag
|
||||
@@ -305,7 +318,7 @@ class Meshcore {
|
||||
|
||||
usleep(500000);
|
||||
}
|
||||
while( (time() - $mark) < $timeout_ms );
|
||||
while( ((time() - $mark) * 1000) < $timeout_ms );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user