many88 - 2018-03-09

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);
CASE eState OF
   0: // Init
      IPAddress.sAddr:= '192.168.0.110'; // IP Adress where Codesys application is running
      uiPort:= 1202;
      xEnable:= TRUE;
      eSTATE := 10;
   10: // Start listening
      IF UDPPeer.xActive THEN
         UDPReceive_Buffer(xEnable:=TRUE,hPeer:=Peer);
            IF UDPReceive_Buffer.xReady THEN
               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);
            ELSIF UDPReceive_Buffer.xError THEN
               eState:= 20;
            END_IF
      ELSE
         eState:= 20;
      END_IF
   20: // Error
END_CASE
////////////////////////////////////////////////////////////////////////////////////