IOL_CALL
(FB)
FUNCTION_BLOCK IOL_CALL
Example
PROGRAM PLC_PRG
VAR
al_read : ProfinetCommon.IOL_CALL;
err : ProfinetCommon.IOL_Error;
productText : STRING(64);
END_VAR
//start the execution by setting REQ = TRUE !
al_read.ID := al1100.GetID(0, 1, 3); // ID of IO-Link Device (in Port 2)
al_read.CAP := 16#B400; // Fix for Ed. 2 devices. For legacy devices get value from vendor's documentation or use CommFB.RDREC for reading out IOL-M directory data (RDREC.Index = 0xB063)
al_read.Port := 1; // IO-Link device is plugged in Port 1
al_read.RD_WR := FALSE; // Read data
al_read.IOL_Index := 20; // IOL-Index = 20 means 'Product Text', this will result in something like 'Laser Sensor'
al_read.IOL_Subindex := 0; // 0 = read complete data-item
al_read.LEN := TO_INT(SIZEOF(productText) - 1);
al_read.IOL_Data := ADR(productText); // an ARRAY[] OF BYTE will be returned
al_read();
IF(al_read.ERROR) THEN
IF(al_read.STATUS <> 0) THEN
// Profinet Communication-Error
// e.g. DF80A100 (= PNIORW, application: write error) will be returned if a wrong 'ID' / submodule identifier is used as target
ELSE
// get IO-Link related error:
err := ProfinetCommon.DECODE_IOL_STATUS(al_read.IOL_STATUS);
END_IF
ELSIF(al_read.DONE_VALID) THEN
;// --> the variable 'productText' will contain some text
END_IF
al_read.REQ := al_read.BUSY; //reset REQ, we need just one execution
- InOut:
Scope
Name
Type
Initial
Comment
Input
REQ
BOOL
Request function
ID
DWORD
Addresses the IO-Link proxy Submodule i.e. IO-Link Master or IO-Link Device
CAP
INT
ANY_TO_INT(16#B400)
fix 0xB400 for Ed. 2 devices, vendor specific for legacy devices
PORT
INT
Port address the function shall be performed at. Supported range: 0 to 255
RD_WR
BOOL
Indicates whether the On-request Data (OD) shall be read (RD = FALSE) or written (WR = TRUE)
IOL_INDEX
INT
Index of the On-request Data or Port Function Indicator respectively
IOL_SUBINDEX
INT
Subindex of the On-request Data or Port Function Command Code
LEN
INT
Actual data length of an IOL data record (read or write) specified in input IOL_DATA
IOL_DATA
POINTER TO BYTE
On-request Data to be written to, or to be read from the Device
Output
DONE_VALID
BOOL
Flag indicating the successful completion of the function (and in case of a read function the validity of received data);
BUSY
BOOL
Flag indicating the function is still performing its task. The function block is not ready to perform a new task.
ERROR
BOOL
Flag indicating the abortion of the function with an error
STATUS
DWORD
Completion or bus error code. Busy =0xFFFFFFFF
IOL_STATUS
DWORD
Completion or IOL-M and IOL-D error code. See function TO_IOL_Error
RD_LEN
INT
Actual Length of data that has been read.