自动化 CI/CD 流水线

实现 IO-Link 测试自动化:我们的 IO-Link 测试工具不再需要鼠标操作。到 SPS 2026 展会时,Master Tester、Device Tester、COD、Diagnosis Tool 和 IO-Link Spy 均可在 Linux 下运行。只需一条命令即可自动启动测试,构建服务器随后读取测试结果。

此前,协议测试是个例外:每次提交时都会构建和检查固件,但 IO-Link 测试需要有人到实验室手动执行,因此错误往往在数周后才被发现。现在,测试可随每次提交或每晚运行,您只需在查看结果时使用 Windows。

流水线中的 IO-Link 测试:此前面临哪些障碍

构建服务器不会点击界面,它会启动程序、等待程序完成并分析返回值。带图形界面的测试软件通常无法在服务器上启动,或在第一个对话框处停住。

因此,测试链中的工具必须能够无需交互地运行,通过返回值报告结果,并生成服务器可读取的报告,通常为 JUnit XML 格式。

Test software with GUI vs. command line on the build serverFive things a build server needs: start without a desktop, no prompts, result as exit code, machine-readable report, configuration in the repository. The GUI meets none of them, command line and API meet all.What the build server needsTest software with GUIWith command line or APIRuns on the build agentwon't start without a desktopruns as a normal processNo promptsa dialog stalls the runall via parameters or filesResult as exit codevisible on screen only0, 1, 2, 3 by outcomeReadable reportPDF filed by handJUnit XML, JSON and PDFConfiguration in the repolives on the lab PCoptions file next to firmware
图 1:构建服务器对测试工具的要求。

测试规范 V1.1.6 和 CRA:为何证明材料如今至关重要

据 PROFIBUS & PROFINET International 统计,截至 2025 年底,全球已安装 7,100 万个 IO-Link 节点,仅 2025 年就新增了 970 万个。每种设备变型和每个固件版本都必须重新测试。从 2026 年 12 月起,我们所有的测试工具都将按照 V1.1.6 规范进行测试。 此外还有欧盟网络弹性法案 (CRA):报告义务自 2026 年 9 月起生效,所有规定自 2027 年 12 月起生效。届时,测试报告须纳入技术文档并保存十年。测试链会自动保存每个固件版本的测试报告。

五款支持命令行的 IO-Link 测试工具

工具功能接口输出结果
Master Tester测试主站协议命令:mtaJUnit、PDF、JSON、项目文件
Device Tester测试设备协议和固件更新通过插件执行命令JUnit、PDF、项目文件
COD模拟任意设备,生成错误和负载REST APIJSON
Diagnosis Tool 和 IO-Link Spy记录线路通信数据通过 HTTP API 执行命令通信记录

主站测试仪

命令 mta 使用与图形界面应用程序相同的测试逻辑,在 Linux 下通过 .NET 9 运行。如果只修改了 Data Storage,可以针对性地运行其 20 项测试。
# Aufbau prüfen: Master, Master Tester Unit, Kabel
mta check --mtu-port /dev/ttyUSB0 --eut-port 2 --stcs-host 192.168.1.20

# Nur die Gruppe Data Storage, mit JUnit-Bericht
mta run ci/master.mtproj --select DS --save results/master.mtproj --report results/master.xml

# Dauerlauf: 100 Wiederholungen
mta-repeater --run "ci/master.mtproj --mtu-port /dev/ttyUSB0" --iterations 100 --stop-on failed
mta 的返回值
值含义
0全部通过
1至少一项测试失败
2操作错误
3测试环境异常:缺少许可证、Master Tester Unit 或 STCS
130测试中止,部分结果仍会保留

区分返回值 1 和 3 非常重要,这样就不会把线缆松动误报为固件错误并转交给开发人员。

设备测试仪

Device Tester 在收到参数后也可无界面启动。IODD 和测试脚本是必需的,其他设置均保存在代码仓库中的选项文件里。通过这种方式也可以测试设备的固件更新。

# dt_ci.txt #
-port /dev/ttyACM0
-iodd "iodd/MyDevice-IODD1.1.xml"
-testScript "scripts/Protocol_test_cases.xml"
-otherconfig 30 true false true 0
-junitReport "results/device.xml"
Device_Tester_application -options ci/dt_ci.txt
Device Tester 的返回值
值含义
0 / 1全部通过 / 至少一项测试失败
2 / 3 / 4IODD、测试脚本或选项无效
8无法连接到 Device Tester
10缺少必需参数
11 / 13插件缺失或版本过旧
14测试硬件需要固件更新

COD

COD 可模拟任何具有 IODD 的设备。测试程序可通过 REST API 使其延迟响应、生成错误的校验和或报告 Data Storage 错误。同时,COD 还会统计主站重启或超出周期时间的次数。

curl http://localhost:49851/device/communication/stats

Diagnosis Tool 和 IO-Link Spy

两者共用一条在测试台上持续运行的命令,也支持 ARM 计算机。测试链通过 HTTP 启动和停止通信记录,并将记录与报告保存在一起。

TEConcept.IOLinkLineDataCLI --mode Api --port /dev/serial/by-id/usb-... --http-port 8735

分离构建服务器和 Linux 测试台

构建在普通构建计算机上进行,测试则在通过 USB 连接测试硬件的 Linux 计算机上执行。该计算机注册为独立的 Runner,仅接受来自内部代码仓库的任务。

From commit to test report via build machine and test bench PCStep 1 commit and step 2 build run on the build machine. The firmware image goes to the Linux test bench PC. There it is flashed, a capture starts, the IO-Link tests run and the results are saved. Exit code and JUnit report go back to the gate, which allows or blocks the merge. The artifacts can optionally be reviewed in the GUI on a Windows PC.Build machine (server or cloud)Test bench PC (Linux, self-hosted runner)1CommitPush ormerge request2BuildBuild firmware,unit testsReview (optional)Windows PC, view onlyArtifacts7Gate0: merge allowedelse: blocked3FlashFlash firmwareto the device4CaptureDiagnosis orSpy records5IO-Link testsmta orDevice Tester6ResultsSave JUnit, PDFand capturefirmware.hexExit code, JUnit
图 2:从代码提交到测试报告。

设备和主站制造商的示例测试配置

Example setup for a device manufacturerThe CI server sends the job to a Linux PC at the test bench. Via USB the PC controls the Device Tester hardware, which is powered with 24 volts and connected to the device under test by an IO-Link cable. An IO-Link Spy is clamped onto the cable and connected to the PC via USB-C. A debug programmer flashes the firmware onto the device under test. Optionally, a Windows PC fetches the reports from the CI server to view them in the GUI.CI serverGitLab, Jenkins,GitHub, Azure DevOpsWindows PCview onlyReportsTest bench PC (Linux)self-hosted runnerDevice Tester (CLI)Diagnosis CLIFlash toolJobDebug programmerSWD or JTAGUSBPower supply24 V DCDevice Tester hardwarevia USBIO-Link Deviceunder test24 VUSBIO-Link (M12)SpyUSB-CSWD
图 3:设备制造商的示例配置。

对于主站制造商,Master Tester Unit 负责测试协议,其他端口上的 COD 则为主站施加负载。COD 的计数器随后会显示主站是否维持了周期时间。

Example setup for a master manufacturer with protocol and load testThe CI server sends the job to a Linux PC at the test bench. It runs mta, one COD Communication Server per COD on ports 49851 to 49853 and the Diagnosis CLI, with the STCS local or on the network. Through the STCS the PC accesses the master under test via SMI. Via a USB hub, the Master Tester Unit connects to port 2 of the master under test, three CODs to ports 1, 3 and 4, and an IO-Link Spy sits on the cable to port 4. Optionally, a Windows PC fetches the reports from the CI server to view them in the GUI.CI serverGitLab, Jenkins,GitHub, Azure DevOpsTest bench PC (Linux)self-hosted runnermta · STCS · Diagnosis CLICOD servers (49851–49853)JobIO-Link Masterunder testPort 1Port 2Port 3Port 4SMI via STCSUSB hubUSBLoad test: all ports in useCOD (49851)Master Tester UnitCOD (49852)COD (49853)--eut-port 2SpyUSB-CWindows PCview onlyReports
图 4:主站制造商的负载测试示例配置。

GitLab CI 中的任务示例如下:

master-protocol:
  stage: iolink
  tags: [iolink-bench]
  script:
    - ./ci/flash.sh build/master.hex
    - mta check --mtu-port /dev/ttyUSB0 --eut-port 2 --stcs-host 192.168.1.20
    - mta run ci/master.mtproj --select DS --report results/master.xml
  artifacts:
    when: always
    paths: [results/]
    reports:
      junit: results/master.xml

展会演示:在 Raspberry Pi 上实现测试自动化

为参加 SPS 展会,我们基于 Raspberry Pi 5 搭建了一个测试台,用于测试我们的单端口 USB-C 主站。其中,Master Tester Unit 模拟设备,IO-Link Spy 记录通信数据。

Setup of the SPS 2026 trade show demoA Raspberry Pi 5 running Linux is CI agent and test bench PC. It runs pytest, the MTA command line, STCS 2.0, the Diagnosis CLI, the web UI with MCP server and a results share. Connected via USB: the 1-port USB-C IO-Link master under test with 24 volt supply, the Master Tester Unit playing the device, and the IO-Link Spy on the cable between master and MTU. A Windows laptop only displays the results, an AI agent can optionally start the tests via MCP.24 V DCIO-Link Masterunder testSpyMTUplays the DeviceRaspberry Pi 5 · LinuxCI agentpytest · mta · STCSDiagnosis CLIWeb UI · MCPUSB-CUSBUSBWindows laptopview onlyEthernetAI agent (optional)MCP
图 7:展会演示配置。

完整的测试逻辑只需五行代码:

PROTOCOL_TESTS = ["SDCI_TC_0184", "SDCI_TC_0210", "SDCI_TC_0168"]

@pytest.mark.parametrize("tc", PROTOCOL_TESTS)
def test_master_protocol(tc, spy_capture, run_dir):
    result = mta.run(tc, save=run_dir / f"{tc}.mtproj")
    assert result.passed, result.failure_summary()

官方脚本中的三项测试显示为绿色,第四项则故意显示为红色:脚本副本预期的 VendorID 为 65001,但设备报告的是 65000。此次运行耗时不到 30 秒,包含 141 个测试用例的完整脚本运行约需 14 分钟。

实际运行报告:三项测试为绿色,一项故意设为红色。

演示的 Web 界面。AI 智能体也可通过 MCP 服务器启动测试。

退出码:测试失败时由谁处理?

Which exit code goes to whomAfter the test run the pipeline reads the exit code. 0 means passed, the merge is allowed. 1 means a test case failed, the development team reviews test case and capture. 3 from the Master Tester or 8 from the Device Tester means the test setup is faulty, the test bench gets checked. 2 from the Master Tester or 2 to 4 and 10 from the Device Tester means an invalid call, the pipeline configuration gets fixed.Test run finishedPipeline readsthe exit code0 · passedall test cases greenMerge allowedArchive report and capture1 · test case failedrun complete, test redDevelopment teamReview test case and capture3 (mta) · 8 (Device Tester)test setup faultyCheck test benchCable, hardware, STCS, license2 (mta) · 2–4, 10 (Device Tester)invalid call or filePipeline configParameters, IODD, test script
图 5:各退出码对应的负责人。

测试计划:每次提交、每晚和发布前

Three test cycles: every commit, every night, before releaseEvery commit runs a setup check and the matching test groups with a JUnit report. Every night runs the full suite, endurance runs, error and load tests with CODs and a capture of each run. Before release the full conformance run produces the PDF test report as the basis for the manufacturer declaration.frequent, small scoperare, full scopeEvery commitSetup check with mta checkTest groups for the changeJUnit report in merge requestEvery nightFull test suiteEndurance runs, mta-repeaterError and load tests with CODsCapture of every runBefore releaseFull conformance runPDF test reportBasis for Manufacturer Declaration
图 6:三种测试频率。

自动化 IO-Link 测试的优势

协议错误可在修改当天发现,代码提交记录、失败的测试结果和通信记录集中存放在一处。初始配置需要花费时间,但之后每次测试都会以相同方式运行。

这不能替代制造商声明所需的一致性测试,但由于测试链使用的测试工具与我们获得认可的测试中心相同,一致性测试中出现意外问题的可能性将大大降低。

常见问题:CI/CD 流水线中的 IO-Link 测试

测试链能否替代一致性测试?

不能。不过,Master Tester 和 Device Tester 也可通过命令生成所需的 PDF 测试报告。

仅在查看报告、项目文件和通信记录时需要;测试本身在 Linux 下运行。

目前依据 V1.1.5,从 2026 年 12 月起依据 V1.1.6。

价格和许可证信息可应询提供。此外,您还可以租用 COD 和 Diagnosis Tool,租期为三个月或六个月。