netSetLANParam (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

4.34 / 1.00.00


Sets TCP/IP-specific parameters for establishing connections over the LAN network interface. It has the same effect as setting the parameters via Device: Network: Network Settings.

 

The LAN network interface must be closed and opened again before the changes can take effect if already opened (see also netClose / netOpen).

 

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

 

Input:

iface : SINT (default 2)

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

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

 

DHCP : BOOL (default TRUE)

Use DHCP to obtain TCP/IP parameters automatically.

 

IP : DINT (default 0)

The IP address of the device.

 

SubnetMask : DINT (default 0)

The Subnet mask of the device.

 

Gateway : DINT (default 0)

The TCP/IP gateway the device must use.

 

AutoDNS : BOOL (default TRUE)

Obtain the DNS parameters automatically. Can only be used in combination with DHCP.

 

DNS1 : DINT (default 0)

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

 

DNS2 : DINT (default 0)

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

 

 

Returns: INT

0

- Success.

2

- AutoDNS enabled without DHCP.

 

 

Declaration:

FUNCTION netSetLANParam : INT;
VAR_INPUT
  iface          : SINT := 2;
  DHCP           : BOOL := TRUE;
  IP             : DINT := 0;
  SubnetMask     : DINT := 0;
  Gateway        : DINT := 0;
  AutoDNS        : BOOL := TRUE;
  DNS1           : DINT := 0;
  DNS2           : DINT := 0;
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;