ioWaitException (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All devices with RS485

Firmware version:

1.50 / 1.00.00


This function will wait for an I/O Extension exception or an optional timeout.

When an exception is raised, use ioGetStatus to get the reason for the exception.

 

The network ID is for the I/O Extension net that is found in the RTCU IDE, not the MODBUS connection ID returned by modbusOpen.

 

Note: the function will block the thread while waiting.

 

 

Input:

net_id : SINT

The network ID of the I/O Extension network.

 

timeout : INT (-1,0..32000) (default -1)

Timeout period in milliseconds to wait.

0

- Disable timeout. The function will return immediately.

-1

- Wait forever. The function will only return only when an exception is raised.

 

Returns: INT

The ID of the device that raised the exception.

0

- The I/O Extension network does not exist.

-1

- No exception raised within the specified period.

 

Declaration:

FUNCTION ioWaitException : INT;
VAR_INPUT
  net_id : SINT;
  timeout : INT := -1;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
THREAD_BLOCK modbusMonitor;
VAR
  device : INT;
  status : INT;
END_VAR;
 
  DebugMsg(message := "I/O monitor thread running");
 
WHILE TRUE DO
  device := ioWaitException(net_id := 1, timeout := -1);
  IF device > 0 THEN
    // Get status
     status := ioGetStatus(net_id := 1, dev_addr := device);
    // Show message
    CASE status OF
        0: DebugFmt(message := "Device \1 present!", v1 := device);
        2: DebugFmt(message := "Device \1 not present!", v1 := device);
        3: DebugFmt(message := "Device \1 configuration wrong!", v1 := device);
        4: DebugFmt(message := "Device \1 communication error!", v1 := device);
    ELSE
        DebugFmt(message := "Device \1 unknown exception (\2)!", v1 := device, v2 := status);
    END_CASE;
  END_IF;
END_WHILE;
END_THREAD_BLOCK;
 
PROGRAM ModbusExample;
VAR
  mbusMon : modbusMonitor;
END_VAR;
 
  mbusMon();
 
BEGIN
  ...
END;
END_PROGRAM;