<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Structure Bug</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/</id><updated>2021-09-22T06:14:21.613000Z</updated><subtitle>Recent posts to Structure Bug</subtitle><entry><title>Structure Bug</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/?limit=25#882b" rel="alternate"/><published>2021-09-22T06:14:21.613000Z</published><updated>2021-09-22T06:14:21.613000Z</updated><author><name>Quirzo</name><uri>https://forge.codesys.com/u/quirzo/</uri></author><id>https://forge.codesys.com95eba82f8c194a486579849ac26bc44044620e54</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;It's how C-style strings work. The system needs to know somehow when it ends and that is done by adding a 0 byte to the end of the text.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Null-terminated_string" rel="nofollow"&gt;https://en.wikipedia.org/wiki/Null-terminated_string&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structure Bug</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/?limit=25#cfe3/cb85" rel="alternate"/><published>2021-09-21T11:30:18.153000Z</published><updated>2021-09-21T11:30:18.153000Z</updated><author><name>Reinier Geers</name><uri>https://forge.codesys.com/u/reinier-geers/</uri></author><id>https://forge.codesys.com7f048da78b38f3a916897804c0897159dbd5a19e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Why is there a string end ?  I try now with AT %MD  Hopefully it will solve my problem.  &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structure Bug</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/?limit=25#cfe3" rel="alternate"/><published>2021-09-21T09:31:12.291000Z</published><updated>2021-09-21T09:31:12.291000Z</updated><author><name>quirzo</name><uri>https://forge.codesys.com/u/quirzo/</uri></author><id>https://forge.codesys.comb571442be79c5b7b4ce807ffcc0e3ae784de8743</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Remember that STRING takes always one extra byte, as there is always a string end byte. So STRING(16) takes 17 bytes.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structure Bug</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/?limit=25#6a93/2547" rel="alternate"/><published>2021-09-21T08:48:19.108000Z</published><updated>2021-09-21T08:48:19.108000Z</updated><author><name>Reinier Geers</name><uri>https://forge.codesys.com/u/reinier-geers/</uri></author><id>https://forge.codesys.com2eb2b34496931ac64c6218027990f35d4ab84787</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks !  But same problem.  if there is a real or string its a problem.&lt;/p&gt;
&lt;p&gt;{attribute 'pack_mode' := '1'} &lt;br/&gt;
TYPE stNIR_400_Ethernet :&lt;br/&gt;
STRUCT&lt;br/&gt;
    usiDHCP         :USINT;&lt;br/&gt;
    sIP_Adres       :STRING(16);&lt;br/&gt;
    sIP_Sub         :STRING(16);&lt;br/&gt;
    sIP_Gate        :STRING(16);&lt;br/&gt;
    sIP_Server      :STRING(16);&lt;br/&gt;
    sGauge_ID       :STRING(65);&lt;br/&gt;
    usiDiag_Dump    :USINT;&lt;br/&gt;
    sDiag_UDP_Adr   :STRING(16);&lt;br/&gt;
    sProfinet       :STRING(65);&lt;br/&gt;
    arrDummy        :ARRAY&lt;span&gt;[1..37]&lt;/span&gt;  OF USINT;&lt;br/&gt;
    uiCRC :UINT ;&lt;/p&gt;
&lt;p&gt;END_STRUCT&lt;br/&gt;
END_TYPE&lt;/p&gt;
&lt;p&gt;&lt;img src="./attachment/attachment.png" width="50%"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Structure Bug</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/?limit=25#6a93" rel="alternate"/><published>2021-09-21T07:59:44.902000Z</published><updated>2021-09-21T07:59:44.902000Z</updated><author><name>quirzo</name><uri>https://forge.codesys.com/u/quirzo/</uri></author><id>https://forge.codesys.comdae484f6c151175cb123759186cbd3889a45a911</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;It might be because of pack mode, which causes padding bytes between structure variables.&lt;/p&gt;
&lt;p&gt;Try to add &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;{attribute 'pack_mode' := '1'} &lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;above the struct definition. In pack mode 1, there are no padding bytes and the copy should work.&lt;/p&gt;
&lt;p&gt;Example (from Beckhoff site, &lt;a href="https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2529746059.html&amp;amp;id=3686945105176987925" rel="nofollow"&gt;https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2529746059.html&amp;amp;id=3686945105176987925&lt;/a&gt;):&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;{attribute 'pack_mode' := '1'} &lt;/span&gt;
&lt;span class="err"&gt;TYPE ST_MyStruct:  &lt;/span&gt;
&lt;span class="err"&gt;STRUCT &lt;/span&gt;
&lt;span class="err"&gt;    bEnable         : BOOL;&lt;/span&gt;
&lt;span class="err"&gt;    nCounter        : INT; &lt;/span&gt;
&lt;span class="err"&gt;    nMaxSize        : INT;&lt;/span&gt;
&lt;span class="err"&gt;    bMaxSizeReached : BOOL;&lt;/span&gt;
&lt;span class="err"&gt;    bReset          : BOOL;&lt;/span&gt;
&lt;span class="err"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="err"&gt;END_TYPE &lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Structure Bug</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59f373c00d/?limit=25#18ed" rel="alternate"/><published>2021-09-20T12:04:04.192000Z</published><updated>2021-09-20T12:04:04.192000Z</updated><author><name>Reinier Geers</name><uri>https://forge.codesys.com/u/reinier-geers/</uri></author><id>https://forge.codesys.comd245634b4fb71cf061ace888834bf5136d95702f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Codesys 3.5.9.2.  I recieve data to an Array. Then i use Sysmemcpy to  copy it to a structure .But with real and string it misses a byte.  So 16 bytes i have to copy to a string(15).   WHY ??  For real i have to copy byte 4-7 to get the right value.  &lt;/p&gt;&lt;/div&gt;</summary></entry></feed>