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);    // ID of IO-Link Master
    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 :=65;          // 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 :=4;
    al_read.IOL_Data :=ADR(aDataIn);    // an ARRAY[] OF BYTE will be returned
   Â
    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;    //reset REQ, we need just one execution
  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]
Related
Talk.ru: 1
Talk.ru: 2
Talk.ru: 3