Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ python3 scripts/vel.py gateway --mode all
python3 scripts/vel.py reliability --mode quick
```

打开 WSLg 图形窗口可执行 python3 scripts/vel.py dashboard。控制台分为内核、外设、RTOS 和日志页,读取实际仿真输出,并显示采样时间。可启动 Cortex-M3、Zephyr 内核、FreeRTOS、外设和网关验收。停止按钮只停止该窗口启动的任务。
图形实验入口是 python3 scripts/vel.py dashboard(WSLg + Tkinter)。左侧选择功能;Modbus 默认是 RTU 控制 GPIO。启动会话后,可读 DO、DI 和寄存器,单独设置 DO,再由 FC01 与从站位图确认。CAN 提供 Loopback 测试;未恢复的 micro-ROS 环境显示不可执行。日志页能看本次运行、原始 RTU 字节和从站日志。运行 python3 scripts/vel.py dashboard --advanced 查看寄存器,或加 --live 启动实时 FreeRTOS 监控。

验收入口为 python3 scripts/accept_gui_h1.py。更多信息见 [功能范围](docs/gui_h1_capabilities.md) 和 [验收报告](docs/gui_h1_report.md)。没有 WSLg 时可加 --headless 执行注册表和作业生命周期检查。

网关在启动时会显示当前步骤及日志位置。如果此前终端用 Ctrl+Z 挂起了进程,回到原终端运行 jobs -l 和 fg,恢复运行,或恢复后按 Ctrl+C 停止。新版入口收到 Ctrl+Z 时会取消运行并释放工作区锁。

Expand Down
118 changes: 118 additions & 0 deletions apps/rtos_inspector/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include "vel_runtime.h"
#include "queue.h"
#include "uart.h"

#define MMIO(address) (*(volatile uint32_t *)(uintptr_t)(address))
#define UART0 0x40004000UL
#define TIMER0 0x40000000UL
#define MAX_TASKS 8U

static QueueHandle_t samples;
static TaskHandle_t producer_handle;
static uint32_t produced, consumed, commands;
static TaskStatus_t tasks[MAX_TASKS];

static void producer(void *arg)
{
(void)arg;
for (;;) {
uint32_t next = produced + 1U;
if (xQueueSend(samples, &next, 0) == pdPASS) {
produced = next;
}
vTaskDelay(pdMS_TO_TICKS(140));
}
}

static void consumer(void *arg)
{
(void)arg;
for (;;) {
uint32_t sample;
if (xQueueReceive(samples, &sample, portMAX_DELAY) == pdPASS) {
consumed = sample;
}
vTaskDelay(pdMS_TO_TICKS(240));
}
}

static void field(const char *name, uint32_t value)
{
uart_putc(' ');
uart_puts(name);
uart_putc('=');
uart_u32(value);
}

static void inspector(void *arg)
{
(void)arg;
for (;;) {
/* Separate read and write paths for the UART. Reading DATA clears RXFULL. */
if ((MMIO(UART0 + 4U) & 2U) != 0U) {
uint32_t command = MMIO(UART0);
if (command == 'p') {
vTaskSuspend(producer_handle);
++commands;
} else if (command == 'r') {
vTaskResume(producer_handle);
++commands;
}
}

const UBaseType_t count = uxTaskGetSystemState(tasks, MAX_TASKS, NULL);
REQUIRE(count > 0U);
uart_puts("VEL_BEGIN");
field("tick", (uint32_t)xTaskGetTickCount());
field("switches", g_switches);
field("heap", (uint32_t)xPortGetFreeHeapSize());
field("heap_min", (uint32_t)xPortGetMinimumEverFreeHeapSize());
field("queue", (uint32_t)uxQueueMessagesWaiting(samples));
field("produced", produced);
field("consumed", consumed);
field("commands", commands);
field("cpuid", MMIO(0xE000ED00UL));
field("icsr", MMIO(0xE000ED04UL));
field("vtor", MMIO(0xE000ED08UL));
field("systick_load", MMIO(0xE000E014UL));
field("systick_value", MMIO(0xE000E018UL));
field("nvic_enabled", MMIO(0xE000E100UL));
field("nvic_pending", MMIO(0xE000E200UL));
field("uart_ctrl", MMIO(UART0 + 8U));
field("uart_state", MMIO(UART0 + 4U));
field("uart_div", MMIO(UART0 + 0x10U));
field("timer_ctrl", MMIO(TIMER0));
field("timer_value", MMIO(TIMER0 + 4U));
field("timer_reload", MMIO(TIMER0 + 8U));
field("tasks", (uint32_t)count);
uart_putc('\n');
for (UBaseType_t i = 0; i < count; ++i) {
const TaskStatus_t *task = &tasks[i];
uart_puts("VEL_TASK ");
uart_puts(task->pcTaskName);
field("id", (uint32_t)task->xTaskNumber);
field("state", (uint32_t)task->eCurrentState);
field("priority", (uint32_t)task->uxCurrentPriority);
field("stack_words", (uint32_t)task->usStackHighWaterMark);
uart_putc('\n');
}
uart_puts("VEL_END\n");
vTaskDelay(pdMS_TO_TICKS(350));
}
}

int main(void)
{
REQUIRE(uart_init());
MMIO(UART0 + 8U) = 3U; /* TX and RX. */
MMIO(TIMER0 + 8U) = 25000000U;
MMIO(TIMER0) = 1U; /* Free-running APB Timer 0, no IRQ. */
samples = xQueueCreate(4, sizeof(uint32_t));
REQUIRE(samples != NULL);
REQUIRE(xTaskCreate(producer, "Producer", 384, NULL, 1, &producer_handle) == pdPASS);
REQUIRE(xTaskCreate(consumer, "Consumer", 384, NULL, 2, NULL) == pdPASS);
REQUIRE(xTaskCreate(inspector, "Inspector", 512, NULL, 3, NULL) == pdPASS);
vTaskStartScheduler();
REQUIRE(0);
return 1;
}
2 changes: 2 additions & 0 deletions cmake/stage3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ set_tests_properties(arm_memory rtos_vendor PROPERTIES TIMEOUT 15)
set_tests_properties(rtos_scheduler rtos_gdb rtos_vendor PROPERTIES LABELS "Stage3_1")
set_tests_properties(arm_fatfs arm_fatfs_gdb PROPERTIES LABELS "Stage3_2")
set_tests_properties(logger_0 logger_1 logger_2 logger_3 logger_4 logger_5 logger_6 logger_gdb arm_memory PROPERTIES LABELS "Stage3_3")

vel_arm_firmware(rtos_inspector apps/rtos_inspector/main.c)
9 changes: 9 additions & 0 deletions docs/gui_h1_architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# GUI-H1 架构

默认 dashboard 使用 Tkinter 工作台。--advanced 和 --live 保留原来的寄存器与实时 FreeRTOS 监控。界面以 after 轮询本次会话日志,依赖检查在工作线程完成。注册表定义模式与固定参数,执行前再次校验,用户选择不会拼成 shell 命令。

vel_gui_job 持有功能锁,给实验提供独立工作区和证据目录,并保存命令、时刻、会话状态和退出码。它先温和停止所拥有的进程组,再按时限清理由 Linux subreaper 收养的子进程,包括旧测试另建会话的进程。关闭主窗口会等清理完成。高级监控可独立启动;从工作台打开时随主窗口清理。

Modbus 主站与 Tk 界面分进程。主站构建现有 Stage 8.2 从站,使用从站实际创建的 PTY,经 pymodbus 发出 FC01/02/03/04/05。读回的 FC01 状态与 IR7 以及 HR3 位图比对后才显示确认。DI 控件单独通过从站 UART0 既有仿真刺激接口改变虚拟输入,再使用 RTU FC02 与 IR6 确认。在 图形界面没有本地 GPIO 镜像。115 秒仿真会话到达上限后自动清理,也可手动停止。

每次交互保存 console.log、build.log、slave.log、rtu-wire.jsonl、slave-exit.json 和 result.json。LIVE 仅用于当前会话;历史记录显示时间与会话 ID,未产生数据时显示 N/A。CAN 等测试统计来自其原验收 JSON。
17 changes: 17 additions & 0 deletions docs/gui_h1_capabilities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# GUI-H1 功能与边界

| 功能 | 后端 | GUI 操作 |
| --- | --- | --- |
| Cortex-M3 | QEMU | 运行已构建的固件并检查 UART、SysTick、异常 |
| FreeRTOS | QEMU | CTest 调度、FatFs 和调试。高级窗口另有实时任务监控 |
| Zephyr 内核 | QEMU | 运行已构建的内核样例,显示实际任务和定时器计数 |
| GPIO / EXTI | Renode | 运行现有模拟 GPIO 和外部中断验收 |
| CAN | native_sim | 仅回环测试,显示发送、接收与一致性验证结果 |
| Modbus RTU | native_sim / PTY | 独立会话,单路 DO 控制与回读;DI 仿真刺激;寄存器读取;协议及故障测试 |
| Modbus TCP Gateway | native_sim | 快速故障检查或完整网关验收 |
| FatFs | Host | CTest 块设备及 FatFs 测试 |
| ROS 2 | Host | 已安装发行版的真实话题和服务检查 |
| micro-ROS / 完整历史链 | QEMU / XRCE / 多后端 | UNAVAILABLE,依赖 Lyrical 及未恢复的构建锁 |
| 物理硬件、RS485 电气特性 | — | NOT TESTED |

GUI 不执行完整历史回归。Modbus 为独立模拟从站,操作不触及真实硬件。CAN 页暂无自定义发送 API。缺少 WSLg 时,仍可运行 CLI 验收和 GUI-H1 的 headless 检查。
21 changes: 21 additions & 0 deletions docs/gui_h1_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# GUI-H1 验收 · 2026-11-24

基线 4fa470ac3df4b8459fca2dc8eccb13aad70c7ef9。环境为 Bridge-Ubuntu-24.04、WSLg/Tkinter、Zephyr 4.4.2 native_sim、pymodbus 3.11.4。验收显示实际本机行为。Hardware、物理 RS485 和 Ethernet 为 NOT TESTED。

| 检查 | 结果 |
| --- | --- |
| python3 scripts/accept_gui_h1.py | 7/7,通过注册表、参数、进程生命周期和真实 WSLg 窗口 |
| python3 scripts/accept_gui_h1.py --headless | 6/6(DISPLAY 和 WAYLAND_DISPLAY 为空) |
| 工作台关闭 | 实际等待 RTU 进程退出。独立验证高级窗口实时 QEMU 随主窗口退出 |
| 旧界面入口 | dashboard --self-test 通过,得到 Cortex-M3 UART 结果 |
| RTU GPIO | DO_0 由 FC05 置 1 后由 FC01 与 IR7 确认为 1,再置 0 并回读为 0。FC02 和 IR6 读回 DI 位图 0101。FC03 与 FC04 均返回 8 个寄存器 |
| 独立注册入口 | CAN、Renode GPIO/EXTI、Host FatFs、Zephyr 内核、ROS 2 依次运行,退出码均为 0 |
| Stage 8.3 Gateway | 7 组通过。6 项运行检查及独立 TCP/RTU 状态比对 |
| Stage 8.2 RTU fault | PASS |
| Stage 8.2 RTU protocol | **FAIL**。1000 笔旧测试出现一次无应答后停止,复跑仍出现于不同请求。延长等待及增加请求间距的诊断尝试也未消除,未保留对旧测试的改动。没有自动重试写入 |
| Stage 0–7 历史全量 133 项 | NOT RUN,现有 Lyrical / micro-ROS 构建依赖未恢复 |
| Stage 8.3.1 独立压力和耐久 | NOT RUN,本轮范围为 GUI-H1 |

本轮 GUI 验收的原始文件位于 build/workspaces/gui-h1/runs/rtu-odkbvc2f/。rtu-wire.jsonl 包含请求与响应;两条 FC05 命令 PDU 分别以 01050000ff00 和 010500000000 开头。console.log 保存 DO、DI、HR3、IR6、IR7 的前后读回。slave.log 包含实际 GPIO 统计和 INPUT bits=5。result.json 的 CANCELLED 是关闭窗口的预期生命周期结果,与会话中已确认的写入回读分别记录。slave-exit.json 保存从站退出结果。

测试索引:build/gui-h1-delivery.log(WSLg),build/gui-h1-final-tests.log(headless 和旧界面),build/gui-entry-urg4iqzr/(独立入口),build/gui-h1-regression/regression-vn4n77vi/(Gateway 和 RTU fault)。RTU protocol 复现日志保存在 build/gui-h1-regression/baseline-final/protocol.log;对应请求/响应在共用回归工作区的 modbus_stage8_2_ws/runs/master-*/wire.json。大日志与构建留在本机 build 目录。
17 changes: 17 additions & 0 deletions scripts/accept_gui_h1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Use --headless for the CLI subset, or run the real window acceptance."""
import argparse
import os
import subprocess
import sys

from vel_env import ROOT, tool_environment

parser = argparse.ArgumentParser()
parser.add_argument("--headless", action="store_true")
args = parser.parse_args()
command = [sys.executable, ROOT / "tests/gui/test_gui_h1.py"]
if args.headless:
command.extend(["Registry", "Lifecycle"])
elif not (os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY")):
parser.error("WSLg display unavailable. Use --headless for CLI-only verification.")
raise SystemExit(subprocess.run(command, cwd=ROOT, env=tool_environment(), timeout=210).returncode)
3 changes: 3 additions & 0 deletions scripts/stage8_1_install_renode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
version,url=pin['version'],pin['url']
archive=WS/('renode-'+version+'.tar.gz');target=WS/'tools/renode'/version
WS.mkdir(parents=True,exist_ok=True)
if not archive.exists() and (cached := os.environ.get("VEL_GUI_RENODE_CACHE")):
import shutil
shutil.copyfile(cached,archive)
if not archive.exists():
part=archive.with_suffix('.partial');subprocess.run(['curl','-fL','--connect-timeout','15','--max-time','180','--retry','2',url,'-o',str(part)],check=True,timeout=220);part.replace(archive)
sha=hashlib.sha256(archive.read_bytes()).hexdigest()
Expand Down
Loading