<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to TCP/ Client convert String DataReceived</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d4a08897d/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d4a08897d/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/8d4a08897d/</id><updated>2023-03-07T16:42:30.919000Z</updated><subtitle>Recent posts to TCP/ Client convert String DataReceived</subtitle><entry><title>TCP/ Client convert String DataReceived</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d4a08897d/?limit=25#411f" rel="alternate"/><published>2023-03-07T16:42:30.919000Z</published><updated>2023-03-07T16:42:30.919000Z</updated><author><name>laurentl38</name><uri>https://forge.codesys.com/u/laurentl38/</uri></author><id>https://forge.codesys.com4dcd4ffb6884307e26db824336af7c7424ab024c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you very much for this info, I will dig this track&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>TCP/ Client convert String DataReceived</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d4a08897d/?limit=25#20a2" rel="alternate"/><published>2023-03-07T14:45:43.219000Z</published><updated>2023-03-07T14:45:43.219000Z</updated><author><name>timvh</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.com451f6648b9a4ef5e876fdaf36f6a6fc15a4d5261</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The data which is received is written in the STRING (memory). A string needs a 0 terminating byte to see the end of the string. In your case hello is just written to the first 5 characters of the string. The rest is not changed, it doesn't write a 0 in the 6th byte of the string (as it shouldn't).&lt;/p&gt;
&lt;p&gt;So what you could do is write some additional code to check the size of the message your received and then in the next byte write 0 in the string.&lt;/p&gt;
&lt;p&gt;You could see the string as an array of bytes. So you could do something like (in this case):&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;IF TCP_READ_0.xReady THEN&lt;/span&gt;
&lt;span class="err"&gt;    DataReceived[TCP_READ_0.szCount] := 0;&lt;/span&gt;
&lt;span class="err"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In CFC you could do this with "MOVE" block with EN/ENO.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>TCP/ Client convert String DataReceived</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d4a08897d/?limit=25#0807" rel="alternate"/><published>2023-03-05T20:01:35.047000Z</published><updated>2023-03-05T20:01:35.047000Z</updated><author><name>laurentl38</name><uri>https://forge.codesys.com/u/laurentl38/</uri></author><id>https://forge.codesys.com32701293e8cfdfef511c3013e96a9c48d553d644</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;hello,&lt;/p&gt;
&lt;p&gt;I am beginner with codesys and I have some problem to create a TCP client&lt;br/&gt;
I am using hercule setup to simulate the server.&lt;br/&gt;
when I send "good morning world" at first, I receive this string in DataRecieved.&lt;br/&gt;
after if I send a shorter string "hello", I receive in DataRecieved "helloMorning World" with the end of my old message&lt;br/&gt;
I tried to put a Len(DataRecieved) instead of the SizeOF. but it doesn't work.&lt;br/&gt;
Do you have any Leads to solve my problem?&lt;/p&gt;
&lt;p&gt;Many thanks in advance!&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>