rchInterfaceGet (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.62.00


This function reads the network interface used to connect to the RTCU Communication Hub.

This function works similarly to gwGetMedia.

 

 

Output:

iface : SINT

The network interface used to connect to the server. (see Network for available interfaces)

 

Returns: INT

1

- Success

0

- Not supported

-1

- Error reading media

 

Declaration:

FUNCTION rchInterfaceGet : INT;
VAR_INPUT
  iface : ACCESS SINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
  eth : BOOL;
END_VAR;
 
VAR_OUTPUT
  LED_GPRS : BOOL;
  LED_RCH : BOOL;
END_VAR;
 
PROGRAM example;
VAR
  rch_iface : SINT;
END_VAR;
 
  // Init cellular
  gsmPower(power := ON);
  netOpen(iface := 1);
 
  // Init Ethernet
  netOpen(iface := 2);
 
  DebugMsg(message:="Program running");
 
BEGIN
  LED_GPRS := netConnected(iface := 1);
  LED_RCH := gwConnected();
 
  // Change RCH interface?
  rchInterfaceGet(iface := rch_iface);
  IF rch_iface <> 2 AND eth THEN
    // Select interface
    rchInterfaceSet(iface := 2); // Use Ethernet
  ELSIF rch_iface <> 1 AND NOT eth THEN
    // Select interface
    rchInterfaceSet(iface := 1); // Use Cellular
END_IF;
 
END;
END_PROGRAM