Windows Subsystem for Linux (WSL)

<< 点击显示目录 >>

主页  exOS使用助手 > exOS Automation Help > Development >

Windows Subsystem for Linux (WSL)

本帮助使用 Windows Subsystem for Linux (WSL) 与 exOS编译 一起编译 Linux 源代码

Topology

注:本帮助的内容假定使用的是 Windows 10 和 Windows Linux 子系统(WSL)。对于在旧版本 Windows 上运行的开发人员来说,最有前途的选择可能是使用 ssh 连接到外部 Linux 环境。尽管该帮助未提及如何完成各种任务,但 exOS 与 WSL 并无直接依赖关系,因此应该可以通过远程 Linux 系统完成相同的操作。

 

设置 WSL

要使用 WSL,需要安装 Windows 10。

这里  需要安装一个 Debian 发行版,以便在 WSL 上运行。

软件源 https://github.com/br-automation-com/exOS-WSL 提供了用于 exOS 构建和模拟目标的现成镜像。正如资源库中提到的,为 WSL 安装与目标系统相同版本的 Debian 非常重要。

 

设置 exOS 构建环境

为了使用 WSL 构建和调试 Linux 程序,  需要 将构建环境 设置为包含 exos-data-eth 软件包。

如果安装了新的 exOS TP,请务必更新 WSL 中的构建环境。

还要确保该构建环境是默认的 WSL 映像(即从右键菜单 "在此打开 Linux shell "打开 WSL 时所打开的 WSL 映像)。使用以下命令即可完成(假设 "Debian "是 Build-WSL-image 的名称):

wsl -s Debian

 

模拟使用

 

构建环境

首先,WSL 的目的是用于 exOS 构建链,从 AS 编译和打包 Linux 程序。在这里,WSL 是一个很好的选择,因为它可以像其他编译器一样作为后台任务运行。

 

部署目标

通过使用 https://github.com/br-automation-com/exOS-WSL 资源库中提供的 "目标 "镜像  ,还可以激活部署模拟,提供与 "真实 "exOS 目标相同的功能(但执行速度较慢)。

使用部署目标完成后,可能需要终止 wsl 映像,以免 OPCUA 端口 (4840) 在本地主机后台打开,从而与其他 ArSim OPCUA 服务器发生冲突。

wsl -t DebianTarget

 

调试目标

在使用 WSL 调试时,可通过 VsCode 等集成开发环境手动执行 Linux 程序,从而绕过自动部署。调用

/usr/bin/exos_mr -c ./exos-data.conf/exos-data.conf

数据连接设置(exos-data.conf)位于 \Temp\Transfer\CONFIG\HARDWARE\FilesToTransfer\AddonsData\exos\exos-data 下 。

 

在这种情况下,ExComponentInfo_0.Operational 将被设置为 true,这意味着在 "正常 "目标(已启用部署)上加载组件时会自动连接的 AR 应用程序可以保持不变。

 

//自动连接:
WaterTankCyclic_0.Enable := ExComponentInfo_0.Operational;

 

从这里开始,Linux 程序可在同一 WSL 映像中执行或在调试环境(IDE)中运行

RunProgramWSL


The Windows Subsystem for Linux (WSL) is used within this help to compile Linux sources with the exOS Build Chain

Topology

Note: The contents for this help presumes the usage of Windows 10 and the Windows Subsystem for Linux (WSL). For developers running on older Windows versions, the most promising alternative is probably to use an ssh connection to an external Linux environment. Even though this help does not mention how to accomplish the various tasks, exOS has no direct dependencies to WSL and thus it should be possible to accomplish the same behaviour via a remote Linux system.

 

Setting up WSL

In order to use WSL, a Windows 10 installation is needed.

Here a Debian distribution should be installed to run on WSL.

The repository https://github.com/br-automation-com/exOS-WSL offers ready-made images for exOS build and simulation targets. As also mentioned in the repository, it is important to use the same version of Debian for WSL that is installed on the target system.

 

Setting up the exOS build environment

In order to build and debug Linux programs with WSL, the build environment needs to be setup to include the exos-data-eth package.

Always update the build enviroment in WSL if new exOS TP are installed

Also make sure that this build environment is the default WSL image (this is the WSL image opened when opening WSL from the context menu "Open Linux shell here"). This is done with the command (assuming "Debian" is the name of the Build-WSL-image):

wsl -s Debian

 

Usage with simulation

 

Build environment

First and foremost, WSL is intended to be used for the exOS build-chain, to compile and package Linux programs from Automation Studio. Here, WSL is an excellent choice, as it can operate as a background task, just like any other compiler.

 

Deployment target

By using the "target" image provided in the https://github.com/br-automation-com/exOS-WSL repository, deployment can also be activated for simulation providing the same functionality (yet slower execution) as a "real" exOS target.

When finished using the deployment target, it can be necessary to terminate the wsl image, that the OPCUA port (4840) isnt open in the background on the local host, and thus conflicts with other ArSim OPCUA servers.

wsl -t DebianTarget

 

Debugging target

When debugging with WSL, Linux programs can be executed manually from an IDE like VsCode, and bypass the automatic deployment. This is accomplished by calling

/usr/bin/exos_mr -c ./exos-data.conf

.. from the Temporary FilesToTransfer folder where the Simulation is active. The data-connection settings (exos-data.conf) are located under \Temp\Transfer\CONFIG\HARDWARE\FilesToTransfer\AddonsData\exos\exos-data

 

The ExComponentInfo_0.Operational will be set to true in this case, meaning AR applications that would automatically connect as soon as the Component is loaded on a "normal" target (where deployment is enabled), can function unchanged.

//Auto connect:
WaterTankCyclic_0.Enable := ExComponentInfo_0.Operational;

From here, Linux programs can be executed or run in a debugging environment (IDE) within the same WSL image

RunProgramWSL