rchConfigGet (Functionblock)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.54.00


rchConfigGet will read out the RTCU Communication Hub parameters previously set from the RTCU M2M Studio, or the rchConfigSet function.

 

 

Input:        

None

 

Output:

enabled : BOOL

Whether the parameters are valid..

 

address : STRING

The IP address or symbolic name of the server.

 

port : DINT

The IP port the device should use to connect to the server.

 

iface : SINT

The network interface the device should use to connect to the server.

 

secure : BOOL

Whether a standard or secure connection is to be used.

 

loginkey : STRING

The key (password) the device should use to connect to the server.

 

cryptkey[n] : SINT

The key used to encrypt communication on a standard connection to the server.

 

MaxConnectionAttempt : INT

Max number of connection attempts before the network media reconnects.

 

MaxSendReqAttempt : INT

Max number of send-request attempts before send fails.

 

ResponseTimeout : INT

Time waiting for response in seconds.

 

AliveFreq : DINT

Frequency for sending self-transactions in seconds.

 

 

Declaration:

FUNCTION_BLOCK rchConfigGet;
VAR_OUTPUT
   enabled              : BOOL;
   address              : STRING;
   port                 : DINT;
   iface                : SINT;
   secure               : BOOL;
   loginkey             : STRING;
   cryptkey             : ARRAY [1..16] OF SINT;
   MaxConnectionAttempt : INT;
   MaxSendReqAttempt    : INT;
   ResponseTimeout      : INT;
   AliveFreq            : DINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
   parm  : rchConfigGet;
   reset : BOOL := FALSE;
END_VAR;
 
// Check the RTCU Communication Hub settings
parm();
IF NOT rchAutoConnectGet() THEN
   rchAutoConnectSet(enable := ON);
   reset := TRUE;
END_IF;
IF NOT parm.enabled OR parm.secure OR parm.port <> 5001 OR
   parm.CryptKey[1] <> 0 OR parm.CryptKey[2] <> 0 OR
   parm.CryptKey[3] <> 0 OR parm.CryptKey[4] <> 0 OR
   parm.CryptKey[5] <> 0 OR parm.CryptKey[6] <> 0 OR
   parm.CryptKey[7] <> 0 OR parm.CryptKey[8] <> 0 OR
   parm.CryptKey[9] <> 0 OR parm.CryptKey[10] <> 0 OR
   parm.CryptKey[11] <> 0 OR parm.CryptKey[12] <> 0 OR
   parm.CryptKey[13] <> 0 OR parm.CryptKey[14] <> 0 OR
   parm.CryptKey[15] <> 0 OR parm.CryptKey[16] <> 0 OR
   parm.iface <> 2 OR strCompare(str1 := parm.addressstr2 := "gw.rtcu.dk") <> 0 OR
   strCompare(str1 := parm.loginkeystr2 := "AABBCCDD") <> 0 THEN
   // Update settings
   rchConfigSet(enable := TRUE,
                address := "gw.rtcu.dk",
                port := 5001,
                iface := 2,
                loginkey := "AABBCCDD",
                secure := FALSE);
   reset := TRUE;
END_IF;
IF reset THEN
   // Reset device before the changes are used
   boardReset();
END_IF;
 
// Start network
netOpen(iface := 2);
 
BEGIN
END;
END_PROGRAM;