From ac649bf4fbfe93ee957ccc0362f4ca6c2bd3c2fe Mon Sep 17 00:00:00 2001 From: Charl Wentzel Date: Tue, 28 May 2019 09:22:28 +0200 Subject: [PATCH] Minor Update: - DeviceCore: - Initialise params in header file - JSONparseCore: - Increase Read buffer to handle large queries - UtilCore: - Bug fix: handle NULL seperator in Hex conversions --- DeviceCore.cpp | 13 +------------ DeviceCore.h | 34 +++++++++++++++++----------------- JSONparseCore.cpp | 2 +- UtilCore.cpp | 4 ++-- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/DeviceCore.cpp b/DeviceCore.cpp index 961a72d..167b93c 100644 --- a/DeviceCore.cpp +++ b/DeviceCore.cpp @@ -18,7 +18,7 @@ // Global Vars extern char * ProcessName; -extern CApplication * Application; +//extern CApplication * Application; //--------------------------------------------------------------------------- @@ -30,20 +30,9 @@ extern CApplication * Application; CDeviceCore::CDeviceCore( const char * pName, const char * pType ) : CFunctionCore( pName, pType ) { // Polling - PollCycle = 0; - PollStep = 0; - PollInterval = 250; SetStartTime( &PollWait ); - WaitingForReply = false; - ReplyTimeout = 200; - InvalidReply = false; - - PollRetry = 0; - MaxRetries = 3; - // Data Structures - DeviceInit = true; ConfigTypes = new CDataMember(); ValueTree = new CDataMember(); JSONparse = new CJSONparse(); diff --git a/DeviceCore.h b/DeviceCore.h index 71b3ffb..7d601d5 100644 --- a/DeviceCore.h +++ b/DeviceCore.h @@ -121,10 +121,10 @@ class CDeviceCore : public CFunctionCore { protected: // Configuration - CDataMember * ConfigTypes = NULL; - CDataMember * ValueTree = NULL; - CJSONparse * JSONparse = NULL; - bool DeviceInit = false; + CDataMember * ConfigTypes = NULL; + CDataMember * ValueTree = NULL; + CJSONparse * JSONparse = NULL; + bool DeviceInit = false; // Initialise device on start // Devices & Type TDevice * FirstDeviceType = NULL; @@ -132,25 +132,25 @@ protected: TDevice * ActiveDevice = NULL; // Standard channels - TChannel * DeviceChannel = NULL; - TChannel * CmdChannel = NULL; - TChannel * EventChannel = NULL; + TChannel * DeviceChannel = NULL; + TChannel * CmdChannel = NULL; + TChannel * EventChannel = NULL; // Poll - int PollCycle; // Device Polling state, e.g. Init, Connect, Run, Disonnect, Shutdown - int PollStep; // Position in polling sequence - timeval PollWait; // Time at which last poll was done - long PollInterval; // Minimum delay between polls + int PollCycle = 0; // Device Polling state, e.g. Init, Connect, Run, Disonnect, Shutdown + int PollStep = 0; // Position in polling sequence + timeval PollWait = {0,0}; // Time at which last poll was done + long PollInterval = 250; // Minimum delay between polls // 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 + bool WaitingForReply = false; // Command sent, waiting for reply + bool InvalidReply = false; // Invalid reply received + long DefReplyTimeout = 500; // Default Max waiting time for reply + long ReplyTimeout = 500; // Max waiting time for reply // Retry - int PollRetry; // No of polling retries that has timed out - int MaxRetries; // Max allowed retries + int PollRetry = 0; // No of polling retries that has timed out + int MaxRetries = 3; // Max allowed retries // Manage Devices bool DestroyDevice( TDevice ** Device ); diff --git a/JSONparseCore.cpp b/JSONparseCore.cpp index 557e3c6..1cb53a1 100644 --- a/JSONparseCore.cpp +++ b/JSONparseCore.cpp @@ -272,7 +272,7 @@ bool CJSONparse::ReadFromHandle( const char * BasePath, int Handle, bool pRefill InputHandle = Handle; // Load Buffer - CreateBuffer( 500 ); + CreateBuffer( 1000 ); if (!FillBuffer()) { Error = true; sprintf( ErrorText, "Could not read from file" ); diff --git a/UtilCore.cpp b/UtilCore.cpp index 660897c..0f079d1 100644 --- a/UtilCore.cpp +++ b/UtilCore.cpp @@ -75,7 +75,7 @@ char * BytesToHexStr( const char * Bytes, const int Len, const char * Separator, // Print Hex values of individual bytes for (int i=0; i