<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Codesys Crash with Python</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d71710918/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d71710918/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/8d71710918/</id><updated>2020-02-27T15:02:55.786000Z</updated><subtitle>Recent posts to Codesys Crash with Python</subtitle><entry><title>Codesys Crash with Python</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d71710918/?limit=25#2aa4" rel="alternate"/><published>2020-02-27T15:02:55.786000Z</published><updated>2020-02-27T15:02:55.786000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com1cb3e7ba679c979a5dcf48f5d291fde3381dea27</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I did post an example python script in the store products part of this forum (which is appropriate for the Test Manager):&lt;br/&gt;
&lt;a class="" href="http://forum.codesys.com/viewtopic.php?f=20&amp;amp;t=5480" rel="nofollow"&gt;http://forum.codesys.com/viewtopic.php?f=20&amp;amp;t=5480&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This example script shows how to generate a PLCOpenXML for a function block which implements the IEC Unit Test interface.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys Crash with Python</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d71710918/?limit=25#074e" rel="alternate"/><published>2020-02-27T15:02:55.131000Z</published><updated>2020-02-27T15:02:55.131000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comd1f9302a07117d8f549fda9506ca9c3874ef71ab</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi, Labview,&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://ironpython.codeplex.com/" rel="nofollow"&gt;IronPython&lt;/a&gt; is a different product than &lt;a class="" href="http://python.org/" rel="nofollow"&gt;CPython&lt;/a&gt; which just tries to implement the same language. IronPython is a complete re-implementation of the Python core in C# with a completely different internal architecture, using the &lt;a class="" href="http://en.wikipedia.org/wiki/Dynamic_Language_Runtime" rel="nofollow"&gt;Dynamic Language Runtime&lt;/a&gt; of the .NET Framework, while the original CPython is a &lt;a class="" href="http://docs.python.org/2.7/library/dis.html#bytecodes" rel="nofollow"&gt;Bytecode Interpreter&lt;/a&gt; implemented in C.&lt;/p&gt;
&lt;p&gt;The &lt;a class="" href="http://www.jython.org/" rel="nofollow"&gt;Jython&lt;/a&gt; follows a similar goal with a pure Java implementation of Python. See &lt;a class="" href="http://www.toptal.com/python/why-are-there-so-many-pythons" rel="nofollow"&gt;Why Are There So Many Pythons?&lt;/a&gt; for an explanation of (some of) the different implementations of Python.&lt;/p&gt;
&lt;p&gt;All the parts of the standard library which CPython implements in C were reimplemented in C# for the IronPython project (or are still missing / not supported). The cTypes module is one of them. Thus, it is naturally that it contains a different set of quirks and bugs compared to the CPython cTypes module. &lt;/p&gt;
&lt;p&gt;Additionally, IronPython is not as widespread as CPython, and thus not that well tested in those corner areas like cTypes. &lt;/p&gt;
&lt;p&gt;CODESYS and the CODESYS Test Manager include IronPython, because the CODESYS V3 IDE is implemented in .NET, and IronPython naturally fits there. It is &lt;strong&gt;not easily possible&lt;/strong&gt; to just replace IronPython by CPython in CODESYS, because the internal structures of the interpreter are completely different. CPython code cannot call into .NET objects, thus it would be impossible to call into any CODESYS function, rendering it completely useless for that purpose.&lt;/p&gt;
&lt;p&gt;We did investigate alternatives, like the &lt;a class="" href="http://pythonnet.sourceforge.net/" rel="nofollow"&gt;Python for .NET&lt;/a&gt; project which aims to provide a bridge between CPython and .NET, but this project seems to be unmaintained since 2007, and thus is not suitable base for a script engine for CODESYS.&lt;/p&gt;
&lt;p&gt;As for the workaround solutions, I think I did already mention most of them via E-Mail, including:&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys Crash with Python</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d71710918/?limit=25#d9a9" rel="alternate"/><published>2020-02-27T15:02:54.531000Z</published><updated>2020-02-27T15:02:54.531000Z</updated><author><name>labview</name><uri>https://forge.codesys.com/u/labview/</uri></author><id>https://forge.codesys.com45fe0d0bbffa1737426f00dfea8b9733bb13f563</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi M.Schaber,&lt;/p&gt;
&lt;p&gt;I can share B2902A.dll file if you want. &lt;/p&gt;
&lt;p&gt;Meantime, there is no issue on Python 2.7 and 3.3 so it is very hard to convince as customers/users stand point  &lt;/p&gt;
&lt;p&gt;My next question is Test Manager has been tested using cPython before released to market?  &lt;/p&gt;
&lt;p&gt;Anyway, do you have any workaround solution?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys Crash with Python</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d71710918/?limit=25#f50c" rel="alternate"/><published>2020-02-27T15:02:52.735000Z</published><updated>2020-02-27T15:02:52.735000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com4e4c0727c0bd3273eb0e5427de598570d8c64c28</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi, Labview,&lt;/p&gt;
&lt;p&gt;As this issue seems to also happen with pure IronPython (the screenshot mentions the ipy.exe), it is not related to CODESYS.&lt;/p&gt;
&lt;p&gt;Maybe there is a bug in the cTypes implementation of IronPython, or maybe the signature for the call is slightly wrong, and cPython just tolerates the mismatch due to some implementation details, while .NET does not tolerate the problem.&lt;/p&gt;
&lt;p&gt;I don't know whether LabView provides debugging assistance for those cases (headers, debug symbols etc.), but I guess that you will need to debug deeper to solve the problem. You will need Visual Studio, the IronPython source code, and the debug symbols, so you can get more details of the crash.&lt;/p&gt;
&lt;p&gt;Without access to the B2902A.dll and as much debug material (headers, symobols etc.) as possible, noone will be able to help you.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys Crash with Python</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d71710918/?limit=25#790d" rel="alternate"/><published>2020-02-27T15:02:52.076000Z</published><updated>2020-02-27T15:02:52.076000Z</updated><author><name>labview</name><uri>https://forge.codesys.com/u/labview/</uri></author><id>https://forge.codesys.coma4aa694ca714f8759a464a744473fd113cba2a53</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;I am running ctypes command in Test Manager which is calling external DLL, and it crashes! I have no idea why? &lt;/p&gt;
&lt;p&gt;I have attached the Crash screenshot for your reference.&lt;/p&gt;
&lt;p&gt;In addition, there is no issue for Python 2.7 and 3.3 &lt;/p&gt;
&lt;p&gt;Kindly refer to the part of the python code as below,&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;ctypes&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;time&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;DLLHANDLE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cdll&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LoadLibrary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"C:&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;INSTRDLL&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;builds&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;DCSOURCEDLL&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;B2902A.dll"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;INPUTSCRIPT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"SYSTEM{DCSOURCE1|INIT}"&lt;/span&gt;
&lt;span class="n"&gt;INPUTVOLTAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;
&lt;span class="n"&gt;c_INPUTSCRIPT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_char_p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;INPUTSCRIPT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;c_INPUTVOLTAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;INPUTVOLTAGE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;SOURCEHANDLE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;DLLHANDLE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DCSOURCE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c_INPUTSCRIPT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;c_INPUTVOLTAGE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Basically, The DLL is calling instrument to perform initialization once INPUTSCRIPT is issued.&lt;/p&gt;
&lt;p&gt;I have attached the Crash screenshot and another screenshot with no crash using Python 2.7 after executed full script. Please help...&lt;/p&gt;
&lt;p&gt;Please advise!&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Python_2.7.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=487"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: IpyCrash.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=486"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>