From d521bafd43b2f0754c6b0fd85a3c26be5292d05b Mon Sep 17 00:00:00 2001 From: tonaerospace Date: Fri, 14 Mar 2025 04:41:53 +0700 Subject: [PATCH] update --- src/communication.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/communication.jl b/src/communication.jl index 62b672e..91af37c 100644 --- a/src/communication.jl +++ b/src/communication.jl @@ -186,11 +186,14 @@ function mqttClientInstance_v2( if clearOldMsg chnames = keys(msgReceiveChannel) for i in chnames - while isready(msgReceiveChannel[i]) - _ = take!(msgReceiveChannel[i]) + totalmsg = msgReceiveChannel[i].n_avail_items #[TESTING] + if totalmsg > 0 + while isready(msgReceiveChannel[i]) + _ = take!(msgReceiveChannel[i]) + end + println("Total $totalmsg old MQTT messages cleared", @__FILE__, ":", @__LINE__, " $(Dates.now())") end end - println("Old MQTT messages cleared") end return instance