From 49a969708c560524cf6f8559719dd44040eb069e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB=D0=B0=20=D0=93=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D1=83=D1=88=D0=BA=D0=BE?= Date: Fri, 24 Nov 2023 09:37:27 +0300 Subject: [PATCH] adding support for changing prompt on the fly --- main/console.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/console.c b/main/console.c index 73fc45d..2f19371 100644 --- a/main/console.c +++ b/main/console.c @@ -55,8 +55,13 @@ void console_task_tx(void* arg) { if (msg_to_print != NULL) { xSemaphoreTake(stdout_taken_sem, portMAX_DELAY); linenoiseHide(&ls); - write(fd, msg_to_print, msg_to_print_size); - flushWrite(); + // if zero-length string - just refresh prompt. used for updating prompt + if(msg_to_print[0] != '\0') { + write(fd, msg_to_print, msg_to_print_size); + flushWrite(); + } else { + ls.prompt = "new prompt > "; + } linenoiseShow(&ls); xSemaphoreGive(stdout_taken_sem); vRingbufferReturnItem(can_messages, (void *) msg_to_print);