netGetLANParam (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

4.34 / 1.00.00


netGetLANParam will read out the TCP/IP parameters previously set from the RTCU IDE or by the netSetLANParam function.

 

The format of an IP address is the same as returned by the sockGetLocalIP function.

 

Input:

iface : SINT (default 2)

The network interface to read configuration for. 2 = LAN 1 network, 3 = LAN 2 network, etc. (See Network)

Please note that the iface parameter is only supported on NX32L.

 

Output:

DHCP : BOOL

Use DHCP to obtain TCP/IP parameters automatically.

 

IP : DINT

The IP address of the device.

 

SubnetMask : DINT

The Subnet mask of the device.

 

Gateway : DINT

The TCP/IP gateway the device uses.

 

AutoDNS : BOOL

Obtain the DNS parameters automatically.

 

DNS1 : DINT

The first Domain Name Server the device uses to look up symbolic names.

 

DNS2 : DINT

The second Domain Name Server the device uses to look up symbolic names.

 

 

Declaration:

FUNCTION_BLOCK netGetLANParam;
VAR_INPUT
  iface          : SINT := 2;
END_VAR;
VAR_OUTPUT
  DHCP           : BOOL;
  IP             : DINT;
  SubnetMask     : DINT;
  Gateway        : DINT;
  AutoDNS        : BOOL;
  DNS1           : DINT;
  DNS2           : DINT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  LANParam     : netGetLANParam;
END_VAR;
 
LANParam();
 
IF LANParam.DHCP = FALSE OR LANParam.AutoDNS = FALSE THEN
  // Turn on DHCP and Automatic DNS
  netSetLANParam(DHCP := TRUE, AutoDNS := TRUE);
END_IF;
 
netOpen(iface := 2);
BEGIN
 
 // ...
 
END;
 
END_PROGRAM;