<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Read bytes from Codesys runtime into external Python script</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/d7f9a0b3e5/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/d7f9a0b3e5/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/d7f9a0b3e5/</id><updated>2024-10-04T08:45:50.488000Z</updated><subtitle>Recent posts to Read bytes from Codesys runtime into external Python script</subtitle><entry><title>Read bytes from Codesys runtime into external Python script</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/d7f9a0b3e5/?limit=50#69ea" rel="alternate"/><published>2024-10-04T08:45:50.488000Z</published><updated>2024-10-04T08:45:50.488000Z</updated><author><name>Artur Wiebe</name><uri>https://forge.codesys.com/u/arwie/</uri></author><id>https://forge.codesys.com50ebc032ab6c9b674d4d3d11c5efac6b6dd6efbe</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I wrote a howto setup shared memory between CODESYS and Python.&lt;br/&gt;
Working example code is linked.&lt;/p&gt;
&lt;p&gt;Fast variable exchange between CODESYS and PYTHON via shared memory:&lt;br/&gt;
&lt;a href="https://gist.github.com/arwie/ff56783d9a2fff52940de82ae1bc1a22" rel="nofollow"&gt;https://gist.github.com/arwie/ff56783d9a2fff52940de82ae1bc1a22&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Read bytes from Codesys runtime into external Python script</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/d7f9a0b3e5/?limit=25#cb96" rel="alternate"/><published>2020-02-27T15:45:06.159000Z</published><updated>2020-02-27T15:45:06.159000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.coma927073b132a57a07b5d7f5efc4e6d3fe44e533c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
a really nice option is for sure to use OPCUA Client on python side:&lt;br/&gt;
 l &lt;a class="" href="https://forum.codesys.com/viewtopic.php?f=23&amp;amp;t=6247&amp;amp;x=19932&amp;amp;p=19932&amp;amp;lan=en" rel="nofollow"&gt;viewtopic.php?f=23&amp;amp;t=6247&amp;amp;p=19932#p19932&lt;/a&gt; l &lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Edwin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Read bytes from Codesys runtime into external Python script</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/d7f9a0b3e5/?limit=25#6822" rel="alternate"/><published>2020-02-27T15:45:03.825000Z</published><updated>2020-02-27T15:45:03.825000Z</updated><author><name>efra-mx</name><uri>https://forge.codesys.com/u/efra-mx/</uri></author><id>https://forge.codesys.com6b0e87a361a4098dc8a97673e9d4001e8b70b730</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you share your example? I would like to do something similar but with C++&lt;br/&gt;
It will be highly appreciated.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Read bytes from Codesys runtime into external Python script</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/d7f9a0b3e5/?limit=25#bf49" rel="alternate"/><published>2020-02-27T15:45:02.888000Z</published><updated>2020-02-27T15:45:02.888000Z</updated><author><name>AndreasDeDeDe</name><uri>https://forge.codesys.com/u/andreasdedede/</uri></author><id>https://forge.codesys.comb529c59e049105b9ee6a8d0fd602989ad6a1f429</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have found a solution: Shared Memory. There is a free package to download from the codesys store, and for linux + python, google "posix_ipc" for a lib that implements shared memory in Python. There is example code on the download site. Also note, for ARM and Intel CPUs, you can use the shared memory without any mutexes. If you share the memory between only two processes (Here: codesys and my python script), and one only reads and the other only writes, they can do that asynchronously and simultaneously. For communicating into the other direction, just add another shared memory.&lt;/p&gt;
&lt;p&gt;Another possibility is modbus, but i didn't delve too deep into that subject.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Read bytes from Codesys runtime into external Python script</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/d7f9a0b3e5/?limit=25#1689" rel="alternate"/><published>2020-02-27T15:45:00.488000Z</published><updated>2020-02-27T15:45:00.488000Z</updated><author><name>AndreasDeDeDe</name><uri>https://forge.codesys.com/u/andreasdedede/</uri></author><id>https://forge.codesys.com456dede564280da3be9b427bf4e2a186c2c8cd1d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello there!&lt;/p&gt;
&lt;p&gt;I'd like to have a function in a python script, maybe looking like this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;readBytesFromCodesys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;someDataSourceIdentification&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;with which i could read bytes from the Codesys runtime, for example, from a Profinet slave that runs in the currently running codesys Project.&lt;br/&gt;
The best solution i came up with would involve writing and reading a shared file, and maybe synchronizing the data transfer between codesys and python via 4 GPIOs.&lt;br/&gt;
is there another way to do this? &lt;/p&gt;
&lt;p&gt;Greetings&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>