From 316b27b19f833775f26fc9101b0ead56d57c6ad9 Mon Sep 17 00:00:00 2001 From: Charl Wentzel Date: Wed, 22 May 2019 15:35:27 +0200 Subject: [PATCH] Important Update: - DeviceCore: - Allow adjustable reply timeout with SetWaitForReply() --- DeviceCore.cpp | 4 +++- DeviceCore.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/DeviceCore.cpp b/DeviceCore.cpp index 056ec7a..961a72d 100644 --- a/DeviceCore.cpp +++ b/DeviceCore.cpp @@ -432,6 +432,7 @@ bool CDeviceCore::SetPollParam( int pPollInterval ) bool CDeviceCore::SetReplyParam( int pReplyTimeout, int pMaxRetries ) { + DefReplyTimeout = pReplyTimeout; ReplyTimeout = pReplyTimeout; MaxRetries = pMaxRetries; return true; @@ -456,12 +457,13 @@ bool CDeviceCore::DeviceOnline( TDevice * Device, bool Online ) } //--------------------------------------------------------------------------- -void CDeviceCore::SetWaitForReply() +void CDeviceCore::SetWaitForReply( int CustomTimeout ) { // Start timer SetStartTime( &PollWait ); // Set flag + ReplyTimeout = (CustomTimeout >= 0)? CustomTimeout : DefReplyTimeout; WaitingForReply = true; InvalidReply = false; } diff --git a/DeviceCore.h b/DeviceCore.h index 427243a..71b3ffb 100644 --- a/DeviceCore.h +++ b/DeviceCore.h @@ -145,6 +145,7 @@ protected: // Reply bool WaitingForReply; // Command sent, waiting for reply bool InvalidReply; // Invalid reply received + long DefReplyTimeout; // Default Max waiting time for reply long ReplyTimeout; // Max waiting time for reply // Retry @@ -306,7 +307,7 @@ protected: virtual bool DeviceOnline( TDevice * Device, bool Online ); // Handle Reply Timing - virtual void SetWaitForReply(); + virtual void SetWaitForReply( int CustomTimeout = -1 ); virtual void ValidReplyReceived(); virtual bool CheckReplyTimeout();