rchConfigSet (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.54.00


Sets the parameters for making connections to the RTCU Communication Hub. This has the same effect as setting the parameters via Device: Network: RTCU Communication Hub settings.

The changes will take effect at the next call to gwOpen or at device reset. (e.g. by using boardReset).

 

 

Input:        

enable : BOOL (Default TRUE)

TRUE to set the parameters, FALSE to clear the parameters.

 

address : STRING (Max 50 characters)

The IP address or symbolic name of the server.

 

port : DINT (default 5001)

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

 

iface : SINT (default 1)

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

 

secure : BOOL (Default TRUE)

Control if a standard connection or secure connection should be used to connect to the server.

 

port : DINT (default 5001)

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

 

loginkey : STRING  (Max 8 characters)

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

 

MaxConnectionAttempt : INT (1..60, default 3)

Max number of connection attempts before the network media reconnects.

 

MaxSendReqAttempt : INT (1..60, default 5)

Max number of send-request attempts before send fails.

 

ResponseTimeout : INT (5..60, default 45)

Time waiting for response in seconds.

 

AliveFreq : DINT (0..60000, default 300)

Frequency for sending self-transactions in seconds.

The purpose of the self-transaction is to ensure a healthy two-way communication channel over the server.

For applications that are only sending data from the device to the server, this frequency can safely be increased.

Setting the value to zero will disable the self-transactions completely.

 

cryptkey : PTR

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

If this parameter is not set (CryptKey set to 0), then the encryption key is not changed.

 

 

Returns:INT

1

- Success.

0

- Not supported.

-2

- Invalid network interface.

-3

- Invalid parameter.

 

 

Declaration:

FUNCTION rchConfigSet : INT;
VAR_INPUT
  enable               : BOOL;
  address              : STRING;
  port                 : DINT := 5001;
  iface                : SINT := 1;
  secure               : BOOL := TRUE;
  loginkey             : STRING;
  cryptkey             : PTR;
  MaxConnectionAttempt : INT := 3;
  MaxSendReqAttempt    : INT := 5;
  ResponseTimeout      : INT := 45;
  AliveFreq            : DINT := 300;
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.address, str2 := "gw.rtcu.dk") <> 0 OR
  strCompare(str1 := parm.loginkey, str2 := "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;