Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
Hello all,
I have a problem , I want to delete the buffer because when I receive the next message it will simply overwrite the previous message and not entirely delete it.
I tried to follow the example from CAA library but it is the same as use UDP_Receive function.
UDPPeer(xEnable:=xEnable, ipAddr:=IPAddress, uiPort:=uiPort, hPeer=>Peer);CASEeStateOF
  0: //Init
    IPAddress.sAddr:='192.168.0.110'; // IP Adress where Codesys application is running
    uiPort:=1202;
    xEnable:=TRUE;
    eSTATE :=10;
  10: //Startlistening
    IFUDPPeer.xActiveTHEN
      UDPReceive_Buffer(xEnable:=TRUE,hPeer:=Peer);
        IFUDPReceive_Buffer.xReadyTHEN
          hqueue:=SBM.CreateQueue(peError:=CAA.gc_pNULL);
          SBM.ENQueueBuffer(hQueue:=hqueue, hBuffer:=UDPReceive_buffer.hBuffer);
          SBM.GetQueueLength(hQueue:=hqueue,peError:=CAA.gc_hINVALID);
          hqueue1:=SBM.DeQueueBuffer(hQueue:=hqueue,peError:=CAA.gc_hINVALID);SBM.CopyBufferData(hBuffer:=hqueue1,pData:=ADR(sReceived),szSize:=SIZEOF(sReceived),szLength:=SBM.GetBufferSize(hqueue1,peError:=CAA.gc_hINVALID),szOffset:=0);
          udpData :=  sReceived; // Data from UDP-stream
          ctRecAnswers :=ctRecAnswers+1; // Number of UDP calls
          sReceived :='';
          SBM.DeleteBuffer(hBuffer:=hqueue1);
        ELSIFUDPReceive_Buffer.xErrorTHEN
          eState:=20;
        END_IF
    ELSE
      eState:=20;
    END_IF
  20: //ErrorEND_CASE////////////////////////////////////////////////////////////////////////////////////
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all,
I have a problem , I want to delete the buffer because when I receive the next message it will simply overwrite the previous message and not entirely delete it.
I tried to follow the example from CAA library but it is the same as use UDP_Receive function.