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
This commit is contained in:
@@ -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();
|
||||
|
||||
34
DeviceCore.h
34
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 );
|
||||
|
||||
@@ -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" );
|
||||
|
||||
@@ -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<Len; i++) {
|
||||
sprintf( BufPos, "%s%02X", ((First)? "" : Separator), (unsigned char)Bytes[i] );
|
||||
sprintf( BufPos, "%s%02X", ((First || !Separator)? "" : Separator), (unsigned char)Bytes[i] );
|
||||
BufPos += (First)? 2 : 2+SepLen;
|
||||
First = false;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ char * BytesToBinStr( const char * Bytes, const int Len, const char * Separator,
|
||||
|
||||
// Print each byte as 8-bit binary
|
||||
for (int i=0; i<Len; i++) {
|
||||
sprintf( BufPos, "%s%c%c%c%c%c%c%c%c", ((First)? "" : Separator),
|
||||
sprintf( BufPos, "%s%c%c%c%c%c%c%c%c", ((First || !Separator)? "" : Separator),
|
||||
(Bytes[i] & 0x80)?'1':'0', (Bytes[i] & 0x40)?'1':'0', (Bytes[i] & 0x20)?'1':'0', (Bytes[i] & 0x10)?'1':'0',
|
||||
(Bytes[i] & 0x08)?'1':'0', (Bytes[i] & 0x04)?'1':'0', (Bytes[i] & 0x02)?'1':'0', (Bytes[i] & 0x01)?'1':'0' );
|
||||
BufPos += (First)? 8 : 8+SepLen;
|
||||
|
||||
Reference in New Issue
Block a user