Hi,
We are currently testing the use of the CODESYS IDE together with CODESYS Virtual Control SL, running five instances on an Ubuntu system using Docker.
So far, we have not found clear documentation on how to configure and map serial ports individually for each Virtual Control SL instance.
Our setup uses a USB hub with multiple USB-to-RS-485 converters. The goal is to create a virtual test environment with five Modbus RTU slaves and one master communicating over RS-485.
We attempted to modify the file VirtualInstance.cfg, located at /var/opt/codesysvcontrol/instances/device1, in order to add or configure serial ports manually.
However, every time we start the runtimes from the CODESYS IDE (Run command), this configuration file is automatically rewritten by CODESYS, and our changes are lost.
Additionally, we noticed that the VirtualInstance.cfg file does not include a “Devices” entry mapping serial interfaces (for example, mappings related to ttyUSB devices).
Is there an official or recommended way to add and persist serial port mappings, or to configure specific serial ports for each Virtual Control SL runtime instance?
Alternatively, is there documentation explaining how serial devices should be handled in multi-instance Docker-based deployments using Deploy Control SL?
Could someone please provide guidance on this topic or point us to relevant documentation or examples?
Thank you in advance for your support.
Hi
I got the solotion!
The anwser is to use a docker wrapper!
Codesys IDE Deploy Control SL uses docker CLI what let you build a wrapper on in.
For CODESYS Virtual control in combination with serial interfaces, you have to declare the USB TTY in the configuration of the virtual runtime.
Edit CODESYSControl.cfg file​
nano /var/opt/codesysvcontrol/instances/codesys/conf/codesyscontrol/CODESYSControl.cfg​
(codesysvcontrol is the container name)
​
Add the following lines at the end of the file :​
[SysCom]​
Linux.Devicefile=/dev/ttyUSB
In the virtual runtime configuration then, in « Genericcommands » field, add the following lines (no comma between the two parameters)
–device=/dev/ttyUSB0:/dev/ttyUSB0 --device=/dev/ttyUSB1:/dev/ttyUSB1
Adapt to your tty names.
Then in the CODESYS configuration
1 Like
Hi quenorha
Hi Quenorha, thank you for your response — your solution is much better than what I did.
I initially thought the answer might involve using Generic Commands. However, I couldn’t find any documentation explaining how to use it or what else would also be required, such as modifying the CODESYSControl.cfg file.
I tried editing the CODESYSControl.cfg file directly, but this approach did not work for me. Every time I stop and run the instances, the Deploy Control SL overwrites (or recreates) this file, so all manual changes are lost. I am currently using CODESYS without a license, which means the runtime stops every two hours, making this behavior even more noticeable.
I still have two questions:
-
If it is also necessary to modify the CODESYSControl.cfg file, what is the recommended way to do this so that it is not overwritten by Deploy Control SL during stop/run cycles?
-
Do the Generic Commands execute commands at the Docker/container level, or directly on the CODESYS Runtime? It is not clear to me how these commands are interpreted and where they actually take effect.
Thank you for ywonderful help
Hi quenorha,
Your just neet do set Generic Commands.
It is enough.
Therefore, you do not need to change CODESYSControl.cfg or CODESYSControlUser.cfg
In resume, you just need to map your serial ports to that in docker as you said.
–device=/dev/ttyUSB0:/dev/ttyUSB0 --device=/dev/ttyUSB1:/dev/ttyUSB1
Adapt to your tty names.
I used symlinks that´s why you see below ttyInversor01
Thank you
1 Like