CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Tue Jul 17, 2018 2:52 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Mar 09, 2018 9:56 pm 
Offline

Joined: Sat Jul 25, 2015 7:41 pm
Posts: 1
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.

Code:
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
////////////////////////////////////////////////////////////////////////////////////


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited