Files
DTU-HMI/README.md

65 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PC_HMI 本地 HMI 菜单逻辑的 PC 端模拟
本目录提供一个 **纯 C 语言的控制台程序**,在 PC 上模拟嵌入式 HMI 的菜单交互逻辑,方便调试和理解 `Menu_Route` / `Menu_Show_Proc` 的行为。
## 环境搭建
### 1. 安装 CMake
1. 访问 CMake 官网下载页:[`https://cmake.org/download/`](https://cmake.org/download/)
2. 下载适用于 Windows 的安装包(通常为 `cmake-*-windows-x86_64.msi`),安装时**勾选将 CMake 添加到 PATH**。
3. 安装完成后打开终端PowerShell / CMD执行
```powershell
cmake --version
```
能看到版本信息即表示安装成功。
### 2. 编译器与编码说明
- Windows 下默认使用 **Visual Studio / MSVC** 工具链进行编译。
- 源文件采用 **UTF8 编码并包含中文注释**`CMakeLists.txt` 中已经为 MSVC 打开 `/utf-8` 选项,无需额外配置即可正常编译。
## 目录结构
- `CMakeLists.txt` CMake 构建配置
- `include/menu.h` 菜单数据结构与接口声明
- `include/tcp.h` TCP 通信接口(客户端/服务端)
- `src/menu.c` 简单菜单树与菜单调度逻辑PC 版)
- `src/main.c` 主程序入口,从键盘读取按键并驱动菜单
- `src/tcp.c` TCP 实现Windows Winsock / Linux socket
## 构建步骤
### 1. Windows 示例(当前工程默认方式)
在仓库根目录下执行(注意路径中有空格时要加引号):
```powershell
mkdir build
cd "D:\Code\DTU 程序\DTU-HMI\build"
cmake ..
cmake --build .
```
### 2. 通用Linux / macOS 等)
```bash
mkdir build
cd build
cmake ../
cmake --build .
```
生成的可执行文件名为:
```text
pc_hmi # Windows / Linux 下均可
```
## TCP 通信