I have a Kunbus RevPi Core3 running a Profinet controller with various IO-Link devices attached. I can access process data without issue. The following code works fine for an acyclic call:
PROGRAMPLC_PRGVAR  al_read:ProfinetCommon.IOL_CALL;  err:ProfinetCommon.IOL_Error;  convert:U_BYTES_TO_REAL;  setpoint:REAL;    aDataIn:ARRAY[0..3]OFBYTE;END_VARIFelec.PNIOStatus=0THEN    //starttheexecutionbysettingREQ=TRUE!    al_read.REQ   :=TRUE;         al_read.ID:=elec.GetID(0,1,2);    //IDofIO-LinkMaster    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-LinkdeviceispluggedinPort1    al_read.RD_WR:=FALSE;           //Readdata    al_read.IOL_Index:=65;          //IOL-Index=20means'ProductText',thiswillresultinsomethinglike'LaserSensor'    al_read.IOL_Subindex:=0;         //0=readcompletedata-item    al_read.LEN:=4;    al_read.IOL_Data:=ADR(aDataIn);    //anARRAY[]OFBYTEwillbereturned        al_read();    IF(al_read.ERROR)THEN      IF(al_read.STATUS<>0)THEN        //ProfinetCommunication-Error        //e.g.DF80A100(=PNIORW,application:writeerror)willbereturnedifawrong'ID'/submoduleidentifierisusedastarget      ELSE        //getIO-Linkrelatederror:        err:=ProfinetCommon.DECODE_IOL_STATUS(al_read.IOL_STATUS);      END_IF    ELSIF(al_read.DONE_VALID)THEN      setpoint  :=(BytesToReal(aDataIn[0],aDataIn[1],aDataIn[2],aDataIn[3]));      END_IF    al_read.REQ:=al_read.BUSY;    //resetREQ,weneedjustoneexecution  END_IF
However, as soon as I split this out into a function block with a ReadAsync private method, accessed through an instance set up in the GVL, the call runs, there are no IOL_CALL.ERROR issues, but IOL_CALL.DONE_VALID is never TRUE. So I can't get any data back. I have attached a file highlighting the issue.
So, I think my GoogleFu is failing me, but how can I debug the DONE_VALID response? I don't know what is causing the problem. I am creating a struct / function block class for every IO-Link device.
Hello all
I have a Kunbus RevPi Core3 running a Profinet controller with various IO-Link devices attached. I can access process data without issue. The following code works fine for an acyclic call:
However, as soon as I split this out into a function block with a ReadAsync private method, accessed through an instance set up in the GVL, the call runs, there are no IOL_CALL.ERROR issues, but IOL_CALL.DONE_VALID is never TRUE. So I can't get any data back. I have attached a file highlighting the issue.
So, I think my GoogleFu is failing me, but how can I debug the DONE_VALID response? I don't know what is causing the problem. I am creating a struct / function block class for every IO-Link device.
Thanks for any links / suggestions
Regards
Ray
testbed_rebuild.project [259.94 KiB] (forum.codesys.com)