From e17c718d0bdb806515946a992ef690fb29d6b78e Mon Sep 17 00:00:00 2001 From: Christopher Herr Date: Fri, 19 May 2023 17:57:46 +0200 Subject: [PATCH] Update 'src/pubsub/pubsub/pubsub_library_v4.py' Changed the order so that the time is not overflowing while checking --- src/pubsub/pubsub/pubsub_library_v4.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pubsub/pubsub/pubsub_library_v4.py b/src/pubsub/pubsub/pubsub_library_v4.py index 98c14db..e13fff8 100644 --- a/src/pubsub/pubsub/pubsub_library_v4.py +++ b/src/pubsub/pubsub/pubsub_library_v4.py @@ -130,17 +130,17 @@ class MinimalSubscriber(Node): false = no timer_overflow >> no error""" self.overflow = False if time_limit > 0 and self.has_msg(): + if time.time() <= self.last_msg_time + time_limit: + if self.watchdog > 0: + self.trust += 1 + if self.trust > number_of_timer_overflows * trust_factor: + self.watchdog = 0 if time.time() > self.last_msg_time + time_limit: self.watchdog += 1 self.trust = 0 self.get_logger().warn(f"Message-Watchdog triggered {self.watchdog} times") if self.watchdog > number_of_timer_overflows: self.overflow = True - if self.watchdog > 0: - if time.time() < self.last_msg_time + time_limit: - self.trust += 1 - if self.trust > number_of_timer_overflows * trust_factor: - self.watchdog = 0 return self.overflow