mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 04:04:31 +02:00
Merge branch 'bugfix/linenoise_probe' into 'master'
console: fix linenoiseProbe never timing out Closes IDFCI-387 See merge request espressif/esp-idf!12012
This commit is contained in:
@@ -935,13 +935,17 @@ int linenoiseProbe(void) {
|
|||||||
|
|
||||||
/* Try to read response */
|
/* Try to read response */
|
||||||
int timeout_ms = 200;
|
int timeout_ms = 200;
|
||||||
|
const int retry_ms = 10;
|
||||||
size_t read_bytes = 0;
|
size_t read_bytes = 0;
|
||||||
while (timeout_ms > 0 && read_bytes < 4) { // response is ESC[0n or ESC[3n
|
while (timeout_ms > 0 && read_bytes < 4) { // response is ESC[0n or ESC[3n
|
||||||
usleep(10000);
|
usleep(retry_ms * 1000);
|
||||||
|
timeout_ms -= retry_ms;
|
||||||
char c;
|
char c;
|
||||||
int cb = read(stdin_fileno, &c, 1);
|
int cb = read(stdin_fileno, &c, 1);
|
||||||
|
if (cb < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
read_bytes += cb;
|
read_bytes += cb;
|
||||||
timeout_ms--;
|
|
||||||
}
|
}
|
||||||
/* Restore old mode */
|
/* Restore old mode */
|
||||||
flags &= ~O_NONBLOCK;
|
flags &= ~O_NONBLOCK;
|
||||||
|
Reference in New Issue
Block a user