mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 00:35:26 +03:00
Improve timeout optimization
This commit is contained in:
parent
5b1a70077e
commit
8500754b99
1 changed files with 12 additions and 7 deletions
|
@ -404,14 +404,16 @@ const MSP = {
|
||||||
|
|
||||||
// Send message if it has data or is a new request
|
// Send message if it has data or is a new request
|
||||||
if (data || !isDuplicateRequest) {
|
if (data || !isDuplicateRequest) {
|
||||||
// Optimize timeout for frequent requests
|
// Simple adaptive timeout - decrease on success, increase on timeout
|
||||||
if (this.timeout > this.MIN_TIMEOUT) {
|
|
||||||
this.timeout--;
|
|
||||||
}
|
|
||||||
|
|
||||||
serial.send(bufferOut, (sendInfo) => {
|
serial.send(bufferOut, (sendInfo) => {
|
||||||
if (sendInfo.bytesSent === bufferOut.byteLength && callback_sent) {
|
if (sendInfo.bytesSent === bufferOut.byteLength) {
|
||||||
callback_sent();
|
// Success: gradually decrease timeout for faster response
|
||||||
|
if (this.timeout > this.MIN_TIMEOUT) {
|
||||||
|
this.timeout = Math.max(this.MIN_TIMEOUT, this.timeout - 5);
|
||||||
|
}
|
||||||
|
if (callback_sent) {
|
||||||
|
callback_sent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -426,6 +428,9 @@ const MSP = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleTimeout(requestObj, bufferOut) {
|
_handleTimeout(requestObj, bufferOut) {
|
||||||
|
// Increase timeout on failure for better reliability
|
||||||
|
this.timeout = Math.min(this.MAX_TIMEOUT, this.timeout + 50);
|
||||||
|
|
||||||
// Increment retry attempts
|
// Increment retry attempts
|
||||||
requestObj.attempts++;
|
requestObj.attempts++;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue