This function will return the status code of an I/O Extension exception that has been raised by an I/O device.
While it is possible to use ioGetStatus to continuously poll the device for changes to its status, it is recommended to only poll the device after ioWaitException has detected an exception from the device.
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.
Input:
net_id : SINT
The network ID of the I/O Extension network.
dev_addr : INT
The address of the device.
Returns: INT
0
|
- The device is present.
|
1
|
- The modbus net is not open.
|
2
|
- The device is not present (no response from device).
|
3
|
- The I/O configuration is wrong (MODBUS exception received).
|
4
|
- Communication error (illegal/corrupted package received).
|
Declaration:
FUNCTION ioGetStatus : INT;
VAR_INPUT
net_id : SINT;
dev_addr : INT;
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
status := ioGetStatus(net_id := 1, dev_addr := device);
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;
|