From 091974e6c54795d343e4aef12d38c06f568aaf25 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 11 Dec 2024 10:00:36 +1300 Subject: [PATCH] listener: only clear screen with multiple messages (#24019) * listener: only clear screen with multiple messages * listener: fully clear before printing again Otherwise, we end up seeing artifacts from the previous print. --- src/systemcmds/topic_listener/listener_main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/systemcmds/topic_listener/listener_main.cpp b/src/systemcmds/topic_listener/listener_main.cpp index 83ca22ddd710..28244869f90f 100644 --- a/src/systemcmds/topic_listener/listener_main.cpp +++ b/src/systemcmds/topic_listener/listener_main.cpp @@ -113,9 +113,6 @@ void listener(const orb_id_t &id, unsigned num_msgs, int topic_instance, fds[1].fd = sub; fds[1].events = POLLIN; - // Clear screen - dprintf(1, "\033[2J\n"); - while (msgs_received < num_msgs) { if (poll(&fds[0], 2, int(MESSAGE_TIMEOUT_S * 1000)) > 0) { @@ -142,8 +139,13 @@ void listener(const orb_id_t &id, unsigned num_msgs, int topic_instance, if (fds[1].revents & POLLIN) { msgs_received++; - // Move cursor to home position - dprintf(1, "\033[H"); + if (num_msgs > 1) { + // Clear screen + dprintf(1, "\033[2J\n"); + // Move cursor to home position + dprintf(1, "\033[H"); + } + PX4_INFO_RAW("\nTOPIC: %s instance %d #%d\n", id->o_name, topic_instance, msgs_received); int ret = listener_print_topic(id, sub);