<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/</id><updated>2020-02-27T14:44:29.869000Z</updated><subtitle>Recent posts to External Debugger</subtitle><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#77d7" rel="alternate"/><published>2020-02-27T14:44:29.869000Z</published><updated>2020-02-27T14:44:29.869000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comc02ed73ab8db0341aa240c42e6da1743bc207ac8</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;there's some additional information about the test manager in the store:&lt;br/&gt;
&lt;a class="" href="http://store.codesys.com/codesys-test-manager.html" rel="nofollow"&gt;http://store.codesys.com/codesys-test-manager.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can also use a free trial license to try it out before buying (but you'll need a dongle even for the trial license).&lt;/p&gt;
&lt;p&gt;HTH,&lt;br/&gt;
Markus&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#1df8" rel="alternate"/><published>2020-02-27T14:44:29.312000Z</published><updated>2020-02-27T14:44:29.312000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comaf799fdd400784b6bd8923cf7a2fe99621d283c9</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, andipandi,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;andipandi hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Many thanks for the answer, Markus.&lt;br/&gt;
The python debugging part looks good, I will try this.&lt;br/&gt;
As for the testing, I think I want to go for option 2, the CODESYS Test Manager.&lt;br/&gt;
My main goal is to automate codesys (actually a program that is built on/extends codesys) but find many UI controls not to adhere to MSAA or MSUIA standards and thus I am looking for another way to be able to do what I want. (Right now I am using Silktest.)&lt;br/&gt;
What sort of control do I have with Test Manager? Can I integrate test manager into test running in another context, like any test runner?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The execution of Test Manager Scripts can be triggered via Command Line arguments, this way, it can be included in CI systems (we use it in-house, where we integrated CODESYS into the Jenkins build server using both Script Engine (for build tasks) and the Test Manager (for automated test execution).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#b4d3" rel="alternate"/><published>2020-02-27T14:44:27.808000Z</published><updated>2020-02-27T14:44:27.808000Z</updated><author><name>andipandi</name><uri>https://forge.codesys.com/u/andipandi/</uri></author><id>https://forge.codesys.com33a597115d7a00ecb8a4c5d38cb1009faadfc10f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Many thanks for the answer, Markus.&lt;/p&gt;
&lt;p&gt;The python debugging part looks good, I will try this.&lt;/p&gt;
&lt;p&gt;As for the testing, I think I want to go for option 2, the CODESYS Test Manager.&lt;/p&gt;
&lt;p&gt;My main goal is to automate codesys (actually a program that is built on/extends codesys) but find many UI controls not to adhere to MSAA or MSUIA standards and thus I am looking for another way to be able to do what I want. (Right now I am using Silktest.)&lt;/p&gt;
&lt;p&gt;What sort of control do I have with Test Manager? Can I integrate test manager into test running in another context, like any test runner?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#a5b7" rel="alternate"/><published>2020-02-27T14:44:27.221000Z</published><updated>2020-02-27T14:44:27.221000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comaa7bc5b57750a8cd85c9c83d9dccab840c7aa1ec</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;Just to recall, there are two debugging approaches possible with IronPython in CODESYS:&lt;br/&gt;
- The .NET based approach using the .NET debugging APIs&lt;br/&gt;
- The Python (settrace) based approach&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;andipandi hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
What is the special command line option? And what sort of script is needed?&lt;br/&gt;
Is it just the option to run the script, and is the script just any script that waits a little at the beginning before doing its work?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The python debugger based approach is a little more complicated. You need an Python IDE with "remote debugging" enabled and waiting for connections, and then the connection script needs to hook into sys.settrace() and open the connection to the debugger.&lt;/p&gt;
&lt;p&gt;For example, we successfully got it working with PyCharm using the following command line:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;CODESYS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt; &lt;span class="c1"&gt;--profile="CODESYS V3.5 SP5" --scriptDebugger="D:\test\charmdebug\initdebug.py"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The file "initdebug.py" itself looks like:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;__future__&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;print_function&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;__future__&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;unicode_literals&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"D:\test\Env2\Lib\site-packages\pycharm-debug.egg"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;pydevd&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;scriptdebuggersetup&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;pydevd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;settrace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'localhost'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;51234&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdoutToServer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderrToServer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;scriptdebuggershutdown&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;pydevd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stoptrace&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You will need to adapt the pathes (and possible hostname and port) to match your own installation.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;andipandi hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Also, how does the attach to process work, do I just have the same python script file open in Visual Studio and say "attach to process"? I have Visual Studio Tools for Python installed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If you're using Python Tools for Visual Studio, I'd suggest you use the .NET based debugger approach, as it is much less troublesome.&lt;/p&gt;
&lt;p&gt;You just use "Attach to process" to the running CODESYS instance &lt;em&gt;before&lt;/em&gt; you start the script, and select "Python" as well as "Managed (V4.0)". (It may also be "Managed (V4.0, V4.5)" or similar depending on the installed VS and .NET versions, just make sure you don't select the "Managed (V2.0/3.0/3.5)" instead. Then you simply open the script in Visual studio, set the breakpoint, and start it in CODESYS, that should work (and did in all my tests).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;andipandi hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Also, I noticed with a script I was running that it was blocking the GUI. Do you have the python interpreter running in the UI thread, so if I run a python script I cannot control the UI anymore? I would like to do both, run python script and control UI at same time.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Yes, the python interpreter is running in the main thread. A technical reason is that the CODESYS architecture is inherentily bound to the UI thread for most API calls for historical reasons, so for running the scripts in a background thread, each interaction between the script and CODESYS would have to be marshalled to the UI thread. Another reason is that the focus of the ScriptEngine is to automate tasks which the user also can do manually - user interaction during those automated tasks would very likely disturb the script due to side-effects.&lt;/p&gt;
&lt;p&gt;Depending on your exact use case, the solution may be:&lt;/p&gt;
&lt;p&gt;HTH,&lt;br/&gt;
Markus&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#f86b" rel="alternate"/><published>2020-02-27T14:44:26.692000Z</published><updated>2020-02-27T14:44:26.692000Z</updated><author><name>andipandi</name><uri>https://forge.codesys.com/u/andipandi/</uri></author><id>https://forge.codesys.com3c8d5ea8018d8465f3db5acde060abcd19df1ac5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;M.Schaber hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
The python based debugging approach currently requires that one starts CODESYS with special command line parameters, and needs an active "connection" script to be maintained, so the ScriptEngine can actually connect to the debugger.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;What is the special command line option? And what sort of script is needed?&lt;/p&gt;
&lt;p&gt;Is it just the option to run the script, and is the script just any script that waits a little at the beginning before doing its work?&lt;/p&gt;
&lt;p&gt;Also, how does the attach to process work, do I just have the same python script file open in Visual Studio and say "attach to process"? I have Visual Studio Tools for Python installed.&lt;/p&gt;
&lt;p&gt;Also, I noticed with a script I was running that it was blocking the GUI. Do you have the python interpreter running in the UI thread, so if I run a python script I cannot control the UI anymore? I would like to do both, run python script and control UI at same time.&lt;/p&gt;
&lt;p&gt;Thanks, best&lt;br/&gt;
Andreas Reiff&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#04d2" rel="alternate"/><published>2020-02-27T14:44:25.131000Z</published><updated>2020-02-27T14:44:25.131000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com6e72da409801f8ff2d98b95e999265da22b3872c</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 always tried using "Managed" rsp. ".NET" code, and it also worked. Glad you got it to work.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#dc1b" rel="alternate"/><published>2020-02-27T14:44:24.565000Z</published><updated>2020-02-27T14:44:24.565000Z</updated><author><name>Markus G</name><uri>https://forge.codesys.com/u/markus-g/</uri></author><id>https://forge.codesys.com16cff3a6998f640cf4342a6459a16e9b9d693640</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I figured out the problem. When attaching the script to the Codesys.exe process, i have to select code type 'Python' to make it work&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Aufnahme1.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1061"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#c0d9" rel="alternate"/><published>2020-02-27T14:44:23.991000Z</published><updated>2020-02-27T14:44:23.991000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.come2ddf3eebfc4b0addacca7acb41fa58c17d8d3f3</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;To be honest, I have no idea what's going wrong.&lt;/p&gt;
&lt;p&gt;Just some thoughts:&lt;br/&gt;
- Are you sure the file path is the same?&lt;br/&gt;
- What happens if you call the System.Diagnostics.Debugger.Launch() or System.Diagnostics.Debugger.Break() functions?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#9089" rel="alternate"/><published>2020-02-27T14:44:22.179000Z</published><updated>2020-02-27T14:44:22.179000Z</updated><author><name>Markus G</name><uri>https://forge.codesys.com/u/markus-g/</uri></author><id>https://forge.codesys.com6edf897981e8ab2fdef3d7a1ef16907348950b4d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello, &lt;/p&gt;
&lt;p&gt;i have a question concerning debugging Python scripts in Visual Studio: &lt;/p&gt;
&lt;p&gt;i have installed PTVS 2.1 and try to debug the script example of the Codesys user's conference. I opened a script file, attached it to running Codesys.exe. Then i started the script from Codesys, but i cannot get Visual Studio to hit the breakpoint:&lt;/p&gt;
&lt;p&gt;Do i miss something? Thx...&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Aufnahme2.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1030"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External Debugger</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/eac3fd2daf/?limit=25#e49a" rel="alternate"/><published>2020-02-27T14:44:21.481000Z</published><updated>2020-02-27T14:44:21.481000Z</updated><author><name>jester</name><uri>https://forge.codesys.com/u/jester/</uri></author><id>https://forge.codesys.comf2724410872b000b88bb2b00a37160e2beffdd81</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello, thank you for the fast Feedback ... hope the CDS Python Debugger will coming soon  &lt;/p&gt;&lt;/div&gt;</summary></entry></feed>