<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to DINT adds 2 additional empty bytes in array/union</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/27954aabcf/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/27954aabcf/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/27954aabcf/</id><updated>2021-10-12T11:58:09.093000Z</updated><subtitle>Recent posts to DINT adds 2 additional empty bytes in array/union</subtitle><entry><title>DINT adds 2 additional empty bytes in array/union</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/27954aabcf/?limit=25#42f5" rel="alternate"/><published>2021-10-12T11:58:09.093000Z</published><updated>2021-10-12T11:58:09.093000Z</updated><author><name>drled</name><uri>https://forge.codesys.com/u/drled/</uri></author><id>https://forge.codesys.com6737635bfb576687afb06bc710f9e9d307212141</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The problem was solved by setting {attribute 'pack_mode' := '1'} &lt;br/&gt;
Thanks!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>DINT adds 2 additional empty bytes in array/union</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/27954aabcf/?limit=25#01a8/6f82" rel="alternate"/><published>2021-10-08T14:34:00.977000Z</published><updated>2021-10-08T14:34:00.977000Z</updated><author><name>Ingo</name><uri>https://forge.codesys.com/u/ingo/</uri></author><id>https://forge.codesys.combc0df1609969cac475017a59835f30c405894a89</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I can agree with Tim. This is the problem. But when changing the pack mode, your program will not work on all controllers. For instance, when you have an ARM CPU, with a bit bad luck at the way the memory is connected, it is likely, that your DINT will not be correctly copied, when the memory is not aligned. So I really can't recommend to use this pragma, if you don't know exactly what you are doing.&lt;/p&gt;
&lt;p&gt;I think you can say, that only in two cases, this is no problem:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;you access the memory only with SysMemCpy()&lt;/li&gt;
&lt;li&gt;your application has to run only on a specific controller, and you proved, that it works on this one.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</summary></entry><entry><title>DINT adds 2 additional empty bytes in array/union</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/27954aabcf/?limit=25#01a8" rel="alternate"/><published>2021-10-08T14:15:25.300000Z</published><updated>2021-10-08T14:15:25.300000Z</updated><author><name>timvh</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.com59c30196773b7e8daa85ffaff13c44a8da351368</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Probably pack mode 4 is used on your controller. You can add an "attribute" to the structure with e.g. pack mode 0 and it then probably works as you expect. See &lt;a href="https://help.codesys.com/webapp/_cds_pragma_attribute_pack_mode;product=codesys;version=3.5.17.0" rel="nofollow"&gt;https://help.codesys.com/webapp/_cds_pragma_attribute_pack_mode;product=codesys;version=3.5.17.0&lt;/a&gt; for more information.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>DINT adds 2 additional empty bytes in array/union</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/27954aabcf/?limit=25#8bef" rel="alternate"/><published>2021-10-07T11:40:53.619000Z</published><updated>2021-10-07T11:40:53.619000Z</updated><author><name>drled</name><uri>https://forge.codesys.com/u/drled/</uri></author><id>https://forge.codesys.com8587f8673e532c4d53e603e8ce50cf914a50de3f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I'm relatively new to the codesys platform.&lt;/p&gt;
&lt;p&gt;I'm creating an interface by using a union.&lt;br/&gt;
Everything works fine, except when start adding a DINT variable (int, word etc is working fine).&lt;/p&gt;
&lt;p&gt;When monitoring "online", it seems that right before the DINT there are added 2 empty bytes for no reason?&lt;br/&gt;
Can someone explain this behaviour?&lt;br/&gt;
&lt;img src="./attachment/myIssue.png" width="50%"/&gt;&lt;img src="./attachment/mystructure.png" width="50%"/&gt;&lt;img src="./attachment/myUnion.png" width="50%"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>