adding support for changing prompt on the fly

This commit is contained in:
Данила Горнушко 2023-11-24 09:37:27 +03:00
parent 823cb8d711
commit 49a969708c

View file

@ -55,8 +55,13 @@ void console_task_tx(void* arg) {
if (msg_to_print != NULL) { if (msg_to_print != NULL) {
xSemaphoreTake(stdout_taken_sem, portMAX_DELAY); xSemaphoreTake(stdout_taken_sem, portMAX_DELAY);
linenoiseHide(&ls); linenoiseHide(&ls);
write(fd, msg_to_print, msg_to_print_size); // if zero-length string - just refresh prompt. used for updating prompt
flushWrite(); if(msg_to_print[0] != '\0') {
write(fd, msg_to_print, msg_to_print_size);
flushWrite();
} else {
ls.prompt = "new prompt > ";
}
linenoiseShow(&ls); linenoiseShow(&ls);
xSemaphoreGive(stdout_taken_sem); xSemaphoreGive(stdout_taken_sem);
vRingbufferReturnItem(can_messages, (void *) msg_to_print); vRingbufferReturnItem(can_messages, (void *) msg_to_print);