My goal is to speed up and automate some processes like importing code and alarm texts in an alarm group. To this end, I want to use the ScriptEngine API in Python and preferably not even open the CODESYS application. Now, to streamline the programming we need the debugging capabilities and Visual Studio Code sounded like the easy way to go (Although I am new to it).
Now after some attempts I feel that I am stuck and need a clear guideline of how to set up the environment, I believe a manual does does not exist for CODESYS, am I right?
Install Procedure
Here is the procedure up to where I am now:
(the numbering in brackets refers to the image.)
Install programs as described in the Visual Studio Code (VS Code), "Hallo World" example.
This gives you VS Code, some python distribution (mine is Anaconda) and a sense of what configurations can be done and how (e.g. settings.json and launch.json).
Install the extension in VS Code (below (1)): Python (Python extension for Visual Studio Code)
This should allow for remote debugging.
Open and configure the launch.json file (as described in the 'Hallo World' link) for its debug configurations.
(ps1: open launch.json by pressing the gear Icon above (2).)
(ps2: note that the options in the debugger (1, 2) match the options in the launch.json (3).)
Questions
This is where I don't know how to proceed.
1 - What preset should I start with in launch.json? (When I press "Add Configuration..." at the bottom right, I get among others:)
-> Remote attach (Uses application Port number),
-> Attach using Process ID.
2 - Do I use "Attach" or "Lauch" as options in "request"?
3 - Can I use the debug options when Codesys is already running, or do I need to launch it in a special way like:
4 - Where do I run the actual python program when I want to debug?
-> Using Codesys and run the script from there,
-> Using VS Code and run the script from there,
-> Always use the CMD line to launch Codesys AND the script.
Thanks in advance for your time, let this topic be a help for anyone trying to setup the environment.
Sadly I did not get any feedback on this and was not able to get it to work using Visual Studio Code.
I believe I have used a Codesys environment to get something up, but I cant remember any specifics, its too long ago.
Good luck with it!
Kind regards,
Jan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear reader,
My goal is to speed up and automate some processes like importing code and alarm texts in an alarm group. To this end, I want to use the ScriptEngine API in Python and preferably not even open the CODESYS application. Now, to streamline the programming we need the debugging capabilities and Visual Studio Code sounded like the easy way to go (Although I am new to it).
Now after some attempts I feel that I am stuck and need a clear guideline of how to set up the environment, I believe a manual does does not exist for CODESYS, am I right?
Install Procedure
Here is the procedure up to where I am now:
(the numbering in brackets refers to the image.)
This gives you VS Code, some python distribution (mine is Anaconda) and a sense of what configurations can be done and how (e.g. settings.json and launch.json).
This should allow for remote debugging.
(ps1: open launch.json by pressing the gear Icon above (2).)
(ps2: note that the options in the debugger (1, 2) match the options in the launch.json (3).)
Questions
This is where I don't know how to proceed.
1 - What preset should I start with in launch.json? (When I press "Add Configuration..." at the bottom right, I get among others:)
-> Remote attach (Uses application Port number),
-> Attach using Process ID.
2 - Do I use "Attach" or "Lauch" as options in "request"?
3 - Can I use the debug options when Codesys is already running, or do I need to launch it in a special way like:
4 - Where do I run the actual python program when I want to debug?
-> Using Codesys and run the script from there,
-> Using VS Code and run the script from there,
-> Always use the CMD line to launch Codesys AND the script.
Thanks in advance for your time, let this topic be a help for anyone trying to setup the environment.
Kind Regards,
Jan
Last edit: jantje 2020-10-20
more posts ...
Hi,
did you ever get this to run?
Best
Till
Last edit: aguado 2023-09-12
Hi Till,
Sadly I did not get any feedback on this and was not able to get it to work using Visual Studio Code.
I believe I have used a Codesys environment to get something up, but I cant remember any specifics, its too long ago.
Good luck with it!
Kind regards,
Jan