Connect the CODESYS IDE
This page walks you from a CODESYS project on your PC to an application running on a CODESYS runtime on an EmberNet node: add the gateway, find the device, log in, and download.
How the connection works
The CODESYS Development System never talks to a runtime directly. It talks to a CODESYS gateway, and the gateway talks to the runtime. On EmberNet that gateway is the CODESYS Edge Gateway for Linux from the App Store, and it is the only thing you point the IDE at.
| Piece | Port | Reachable from your PC |
|---|---|---|
| CODESYS Edge Gateway for Linux | 1217/tcp (1743/udp for its UDP block driver) | Yes, over Flux or the overlay network |
| PLC runtime (Control for Linux SL, Virtual Control for Linux SL, Virtual Safe Control SL, Control for Raspberry Pi SL) | 11740/tcp | No, by design |
We deliberately do not publish the runtimes' port 11740 on the mesh. The Edge Gateway makes that last hop itself, from the same node. That keeps one door per device instead of two, and it is why an Edge Gateway has to run on the same device as the runtime you want to program.
CODESYS itself is blunt about this: its manual says the programming ports of a controller, TCP 1217 and 11740 among them, must never be reachable from the Internet without a secure connection method such as a VPN. Flux is that method. Nothing about this setup opens either port to the Internet.
Before you start
- Your PC is on Flux or the overlay network. On Flux, that means the Flux client is enrolled and your identity has access to the tenant that owns the device. See Flux.
- A runtime is running on the device, deployed from the App Store.
- A CODESYS Edge Gateway is running on that same device. If there is not one, install CODESYS Edge Gateway for Linux from the App Store and deploy it to that device first.
- You have a CODESYS project whose Device matches the runtime product you deployed.
Step 1: Copy the gateway address
Open the dashboard, go to App Store > Running Apps, and find the card for your CODESYS runtime. Its Connect from CODESYS block shows:
- the gateway's Flux address and port, in the form
codesys-edge-gateway-for-linux-<site>-<node>.flux.internal:1217 - the gateway's overlay address and port, which is the node's overlay IP on port 1217 when the gateway runs on the host network
- the device name to look for when you scan the network
- which Edge Gateway serves this runtime, or a note that none is running on that device
The Edge Gateway's own card shows its address and port too. Use the copy buttons. Do not type these by hand and do not assume the port is 1217; the card shows the port that gateway is actually listening on.
Step 2: Add the gateway
- Open your project in the CODESYS Development System.
- In the Devices view, double-click the Device entry. The device editor opens on the Communication Settings tab.
- Click Gateway > Add New Gateway. (In the classic display mode of this tab, the button is Add Gateway.) The Gateway dialog opens.
- In Name, enter a name you will recognize, for example the site and node.
- In the driver list, select TCP/IP.
- Double-click the value of IP address and enter the address from the
card:
- For the Flux address, enter the host name with the
dns:prefix, for exampledns:codesys-edge-gateway-for-linux-<site>-<node>.flux.internal. The CODESYS Gateway dialog expects a DNS name to begin withdns:. - For the overlay address, enter the IP address as shown.
- For the Flux address, enter the host name with the
- Double-click the value of Port and enter the port from the card, normally
1217. - Click OK.
The gateway now appears on the Communication Settings tab. The circle on the gateway symbol turns green when CODESYS can reach it, red when it cannot, and black when the status is unknown.
Step 3: Find the device
- Select the gateway you just added and click Scan Network. The Select Device dialog opens and lists each configured gateway with the devices it can see.
- Under your gateway, select the entry with the device name from the
Running Apps card. CODESYS shows each device as
<device name> [device address]. - Click OK.
If the device name is unique on that gateway, CODESYS stores the name in the connection settings; otherwise it uses the device address. Either works.
Step 4: Set the active path
If CODESYS has not already made the channel active, select the device under your gateway and click Set Active Path (double-clicking the entry does the same). From now on every online command in this project goes through this path.
Under Device > Options, Store Communication Settings in Project decides whether the path is saved in the project or in your local CODESYS options. Either way, if you open the project on another PC you have to set the active path again.
Step 5: Log in
The first time you connect to a runtime that has no device user management yet, CODESYS tells you that user management is required for the device but is not enabled, and offers to enable it:
- Click Yes. The Add Device User dialog opens.
- Enter a Name and Password for the first device administrator and click OK.
- The Device User Logon dialog opens. Log in with the credentials you just created.
On a runtime that already has user management configured, CODESYS asks for your device user credentials whenever you log in.
Step 6: Download and run
- Click Online > Login (Alt+F8).
- What happens next depends on what is already on the runtime:
- No application on the controller: CODESYS asks you to confirm the download.
- The application changed since the last download: choose Login with online change, Login with download, or Login without any change. Use Login with download for a full download. You can also update the boot application at this point.
- A different application is running: CODESYS asks whether to overwrite it.
- Start the application, and check that it runs.
Only one CODESYS instance can be logged in to an application on a controller at a time (CODESYS V3.5 SP17 and higher). If a colleague is already logged in, your login is refused with an error.
Troubleshooting
The card says no Edge Gateway is running on that device. The runtime is fine; there is just no gateway next to it. Install CODESYS Edge Gateway for Linux from the App Store on that same device, then copy the address from the card again. A gateway on a different device cannot reach this runtime, because port 11740 is not on the mesh.
I tried to connect to the runtime on port 11740. That is intentional, not a fault. The runtime port is not published on Flux or the overlay network. Point the IDE at the Edge Gateway on port 1217 (or the port the card shows) and let the gateway make the last hop.
The gateway is not on port 1217. On a node that runs more than one CODESYS install, the first one gets the node's own ports and a later one can end up on a different port. Use the port the Running Apps card shows for that gateway, not the default.
The gateway circle stays red.
Check that your PC is connected to Flux and that your identity has access to
that tenant, or that you are on the overlay network. Then check the address:
a Flux host name needs the dns: prefix in the Gateway dialog.
The gateway is green but Scan Network does not show the device. Check that the runtime's card shows it running on the same device as the gateway. Then turn off Hide non-matching devices, filter by Target ID in the Select Device dialog. If the device appears now, your project's Device does not match the runtime you deployed. Double-clicking the device offers to update the device description in your project, provided that description is installed. Control for Linux SL and Virtual Control for Linux SL are different products, so make sure the project targets the one you deployed.
CODESYS documentation
Every IDE step on this page comes from the CODESYS online help:
- Tab: Communication Settings
- Command: Add New Gateway
- Establish the Connection to the PLC
- Command: Login
- Downloading and Starting the CODESYS Application on the Controller
- Edge Gateway for Linux