I am using the docker image for codesys-ide and I am trying to start with a simple task by building a project. I have created the project in a Windows Machine with Codesys v3.5 SP16.
When I run the docker image with codesys and run the following script:
# encoding:utf-8 from __future__ import print_function import os import scriptengine # opens project proj = projects.open(r"MyProject.projectarchive", primary = True) application = proj.active_application #This line causes the error application.generate_code() proj.close()
I get the following error:
Error: Running script 'z:/builds/codesys_test/run.py' caused exception System.ArgumentException: Traceback (most recent call last):
File "z:/builds/codesys_test/run.py", line 25, in <module>
ValueError: ScriptObjects need a non-empty Guid! </module>
Attached you will find the Project I created. The project is archived as when I tried to first open the project without archiving the libraries, Codesys complained that it couldnt find the libraries.
In addition I modified the codesys bash file as I need to run my own scripts from a different folder in the docker container:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/bin/bash WINE=wine set -x # get first CODESYS profile and start the script with it profile=$(basename "$(ls -1 ~/.wine.cds/drive_c/CODESYS/CODESYS/Profiles/*.profile* | head -n 1 | sed 's,\.profile.*,,')") echo ${profile} # check if file exists, before we call CODESYS with it if [ ! -f ${1}.py ]; then echo "error: script '${1}.py' not found." exit -1 fi export DISPLAY=:91 Xvfb :91 &> /dev/zero & sleep 1 export WINEPREFIX=~/.wine.cds # test that running scripts work ${WINE} ~/.wine.cds/drive_c/CODESYS/CODESYS/Common/CODESYS.exe --culture=en --profile="'"${profile}"'" --runscript="z:${BASEPATH}/noop.py" --noUI 2> /dev/zero # remove output log [ -f .codesys.output.txt ] && rm -f .codesys.output.txt ${WINE} ~/.wine.cds/drive_c/CODESYS/CODESYS/Common/CODESYS.exe --culture=en --profile="'"${profile}"'" --runscript="z:${1}.py" --noUI sleep 1 killall Xvfb rm -rf /tmp/.X91* |
If you have any idea of why this error happens or any suggestion on what could be the reason I would gladly appreciate it.
Thanks in advanced,
Victor
Just an update. I have looked in more detail the output of the CODESYS cli and when I open a .project file (Without archiving) I get also an error.The eror occurs when with the python Script engine API I trying to generate the project (i.e., open(),generate_code())
I have to mention that the project is done in a Windows Machine with CODESYS Control Win V3. So should it be possible to develop projects in CODESYS Control Win V3 and use the docker image? I also tried installing manually the Codesys Control Winv3 packages by downloading them from here:
https://store-archive.codesys.com/ftp_download/3S/ControlWinSL/305021/3.5.16.0/CODESYS%20Control%20Win%203.5.16.0.zip
Afterward I unzip the file and use the package extension to install both packages (CODESYS Control Win 3.5.16.0.package,CODESYS Control Win 64 3.5.16.0.package) with the following command:
Altough I am not sure if this should work as I see in the zip an .exe file which is larger than the package extension file itselfs so I dont know If I should install it directly with Wine e.g.
wine z:/builds/CODESYS Control Win 3.5.16.0.exe
In addition I tried installing the libraries that were missing with the use of the helper script:
alas when trying to install them I got the following error:
So what I did is manually changed the version of the library IOStandard in the script to 3.5.16.0 and the signature error did not happen again.
Nevertheless the first error described in this comment happened. So at this moment I am not sure if the current docker container supports the use of CODESYS Control WinV3 projects or just CODESYS Control for linux SL. I could try using the linux variant but my end goal is to use CI/CD for student projects at the university and I find it easier for them to install CODESYS natively in Windows.
I am open to any discussion on how I could use CODESYS Control Win v3 or something I am missing that could help solve this issue
BR
Victor
After going down the rabbit hole long enough I have found a temporal solution for my problem.
Issue Summary:
I want to compile CODESYS projects for "CODESYS Control Win V3" devices through CI/CD with a docker container from this repo. The problem is that the docker container does not find the references to some libraries even though they are installed.
How to reproduce the issue:
1) Create a new CODESYS project (3.5.16.0 x86) in a Windows machine through the project wizard. It is worth mentioning that I did a clean install of CODESYS and used different machines with W7 and W10 to test the reproducibility of the error.
2) Compile the project file with the docker container as described in the first post.
Cause of the problem
As the error was related to the library references I first tried using the script from here:
to install the libraries automatically.
The output that I logged was:
This means that the only missing library is the BreakpointLoggingFunctions. But since this library is not used and does not cause the errors I checked what information did the library manager had. I used the following script to print out more information about the libraries:
Output from the script:
This made me realize that the effective_resolution property for the Standard lib was None. So I decided to manually set the redirection as follows
After setting the redirection the project could be compiled
Final Notes
I also tested this error by using a W7 Virtual Machine (VM) as a build server and had similar issues related to references not being found for the standard library. The only time it worked with this VM is when the project was done inside the VM and this project file was used for the build.
Also by using the library manager installer script mentioned in this post I noticed that the effective_resolution for the library BreakpointLogging wasnt changed and the value was still None, so it seems that installing the library did not change the placeholder it required and would need perhaps the "set_redirection" method.
For now the problem seems to be solved and I can use the docker container with some slight modifications for my Lectures in Automation Systems at the University.
Regards
Victor
Thanks for diving into the rabbit whole. 😉
I now improved the error reporting and stability of build-bootapp.
Hint: You can call it like this, from the folder of your *.project file...
docker run -v $(pwd):$(pwd) -w $(pwd) codesys-ide codesys build-bootapp