From b2e4b02806d2f10f2bc7c33ecb6492967f31f09b Mon Sep 17 00:00:00 2001 From: Egor00f Date: Sun, 8 Mar 2026 18:40:07 +0500 Subject: [PATCH] libshell: update `shell_ping()` make it faster --- .../ktcc/trunk/lib/libshell/shell_ping.c | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/programs/develop/ktcc/trunk/lib/libshell/shell_ping.c b/programs/develop/ktcc/trunk/lib/libshell/shell_ping.c index 0e0aeec0d..d3bd99a49 100644 --- a/programs/develop/ktcc/trunk/lib/libshell/shell_ping.c +++ b/programs/develop/ktcc/trunk/lib/libshell/shell_ping.c @@ -1,12 +1,24 @@ #include #include +#include + +#define SHELL_PING_TIMEOUT 10 // 0.1 sec +#define SHELL_PING_MIN_DELAY 1 int shell_ping() { *__shell_shm = SHELL_PING; - _ksys_thread_yield(); - _ksys_delay(40); + _ksys_thread_yield(); // hope shell is fast enough - return *__shell_shm == SHELL_OK; -} \ No newline at end of file + size_t i = 0; + while (*__shell_shm != SHELL_OK){ + if (i > (SHELL_PING_TIMEOUT / SHELL_PING_MIN_DELAY)) { + return 0; + } + i++; + _ksys_delay(SHELL_PING_MIN_DELAY); + } + + return 1; +}