CXA_SocketComm empty TCP read buffer

Hello community,

I wanted to establish a TCP connection between PLC and another application.
However, I receive the messages but when I send a short message I can see that the buffer is not emptied and remaining characters from the longer string message persist. I tried to empty the string before receiving new data but this did not help

I hope you have a hint for me.

Best,
Karim
Best reply by danielsimila

Hi Karim, 
Which versions are you using on your system? 

I use the following snippet to extract my recieved message with a ctrlX CORE @ version 1.20:

(* Receive some data *)
fbRecv(Execute:=TRUE, Socket:=udiSocket, ValueAdr:=ADR(strRecv), NoOfBytes:=SIZEOF(strRecv)-1);
IF fbRecv.Done=TRUE THEN
	(* Received some data *)
	strRecv := LEFT(strRecv, UDINT_TO_INT(fbRecv.NoOfRecBytes)); (* end of string marker *)
	fbRecv(Execute:=FALSE);
END_IF

 

 

View original
4 replies