Onno - 2015-09-07

Hello,

Setup: Schneider Electric TM251MESE running the TCP-Server code
With putty I connect to this plc with raw tcp communication on port 4711.

The plc response is Hello World: 100
When I response with Hello World: 100 the response is Hello World: 99 etc.
As expected the value decrements every time the correct response is send back to the plc
The eState variable is switching from Init to Send to Read, Send, Read...

After I close the putty window the state switches to Error then to Init, assuming this is expected behaviour.

When I try to connect again the connection is made, the Hello World: __ string is returned and eState switches to Read.
The next cycle handling this state fails:
The putty window closes.

Setting breakpoints: after executing

TCPRead(xEnable:= TRUE, hConnection:= Connection, szSize:= SIZEOF(sReceived), pData:= ADR(sReceived));

TCPRead.xError is true, eState switches from Error into Init.

Every time I connect again the Hello World: __ string is send again but every attempt to receive (TCPRead) results in an Error then Init.

Only by a cold reset I can connect again and send data back to the plc.

What is happening?
Is there a method to reset the functionblocks in this example?

I tried this example as I need to implement a connection from a robot to this plc.

Are there any other examples of a simple tcp-server arround with some error handling?

Thanks in advance!
Best regards,
Onno