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
|
// Global Vars
|
||||||
extern char * ProcessName;
|
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 )
|
CDeviceCore::CDeviceCore( const char * pName, const char * pType ) : CFunctionCore( pName, pType )
|
||||||
{
|
{
|
||||||
// Polling
|
// Polling
|
||||||
PollCycle = 0;
|
|
||||||
PollStep = 0;
|
|
||||||
PollInterval = 250;
|
|
||||||
SetStartTime( &PollWait );
|
SetStartTime( &PollWait );
|
||||||
|
|
||||||
WaitingForReply = false;
|
|
||||||
ReplyTimeout = 200;
|
|
||||||
InvalidReply = false;
|
|
||||||
|
|
||||||
PollRetry = 0;
|
|
||||||
MaxRetries = 3;
|
|
||||||
|
|
||||||
// Data Structures
|
// Data Structures
|
||||||
DeviceInit = true;
|
|
||||||
ConfigTypes = new CDataMember();
|
ConfigTypes = new CDataMember();
|
||||||
ValueTree = new CDataMember();
|
ValueTree = new CDataMember();
|
||||||
JSONparse = new CJSONparse();
|
JSONparse = new CJSONparse();
|
||||||
|
|||||||
34
DeviceCore.h
34
DeviceCore.h
@@ -121,10 +121,10 @@ class CDeviceCore : public CFunctionCore
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// Configuration
|
// Configuration
|
||||||
CDataMember * ConfigTypes = NULL;
|
CDataMember * ConfigTypes = NULL;
|
||||||
CDataMember * ValueTree = NULL;
|
CDataMember * ValueTree = NULL;
|
||||||
CJSONparse * JSONparse = NULL;
|
CJSONparse * JSONparse = NULL;
|
||||||
bool DeviceInit = false;
|
bool DeviceInit = false; // Initialise device on start
|
||||||
|
|
||||||
// Devices & Type
|
// Devices & Type
|
||||||
TDevice * FirstDeviceType = NULL;
|
TDevice * FirstDeviceType = NULL;
|
||||||
@@ -132,25 +132,25 @@ protected:
|
|||||||
TDevice * ActiveDevice = NULL;
|
TDevice * ActiveDevice = NULL;
|
||||||
|
|
||||||
// Standard channels
|
// Standard channels
|
||||||
TChannel * DeviceChannel = NULL;
|
TChannel * DeviceChannel = NULL;
|
||||||
TChannel * CmdChannel = NULL;
|
TChannel * CmdChannel = NULL;
|
||||||
TChannel * EventChannel = NULL;
|
TChannel * EventChannel = NULL;
|
||||||
|
|
||||||
// Poll
|
// Poll
|
||||||
int PollCycle; // Device Polling state, e.g. Init, Connect, Run, Disonnect, Shutdown
|
int PollCycle = 0; // Device Polling state, e.g. Init, Connect, Run, Disonnect, Shutdown
|
||||||
int PollStep; // Position in polling sequence
|
int PollStep = 0; // Position in polling sequence
|
||||||
timeval PollWait; // Time at which last poll was done
|
timeval PollWait = {0,0}; // Time at which last poll was done
|
||||||
long PollInterval; // Minimum delay between polls
|
long PollInterval = 250; // Minimum delay between polls
|
||||||
|
|
||||||
// Reply
|
// Reply
|
||||||
bool WaitingForReply; // Command sent, waiting for reply
|
bool WaitingForReply = false; // Command sent, waiting for reply
|
||||||
bool InvalidReply; // Invalid reply received
|
bool InvalidReply = false; // Invalid reply received
|
||||||
long DefReplyTimeout; // Default Max waiting time for reply
|
long DefReplyTimeout = 500; // Default Max waiting time for reply
|
||||||
long ReplyTimeout; // Max waiting time for reply
|
long ReplyTimeout = 500; // Max waiting time for reply
|
||||||
|
|
||||||
// Retry
|
// Retry
|
||||||
int PollRetry; // No of polling retries that has timed out
|
int PollRetry = 0; // No of polling retries that has timed out
|
||||||
int MaxRetries; // Max allowed retries
|
int MaxRetries = 3; // Max allowed retries
|
||||||
|
|
||||||
// Manage Devices
|
// Manage Devices
|
||||||
bool DestroyDevice( TDevice ** Device );
|
bool DestroyDevice( TDevice ** Device );
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ bool CJSONparse::ReadFromHandle( const char * BasePath, int Handle, bool pRefill
|
|||||||
InputHandle = Handle;
|
InputHandle = Handle;
|
||||||
|
|
||||||
// Load Buffer
|
// Load Buffer
|
||||||
CreateBuffer( 500 );
|
CreateBuffer( 1000 );
|
||||||
if (!FillBuffer()) {
|
if (!FillBuffer()) {
|
||||||
Error = true;
|
Error = true;
|
||||||
sprintf( ErrorText, "Could not read from file" );
|
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
|
// Print Hex values of individual bytes
|
||||||
for (int i=0; i<Len; i++) {
|
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;
|
BufPos += (First)? 2 : 2+SepLen;
|
||||||
First = false;
|
First = false;
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ char * BytesToBinStr( const char * Bytes, const int Len, const char * Separator,
|
|||||||
|
|
||||||
// Print each byte as 8-bit binary
|
// Print each byte as 8-bit binary
|
||||||
for (int i=0; i<Len; i++) {
|
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] & 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' );
|
(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;
|
BufPos += (First)? 8 : 8+SepLen;
|
||||||
|
|||||||
Reference in New Issue
Block a user