Files
serverinfotest/README.md
DESKTOP-PUHFO60\dsx2016 8cc030178f Add cross-platform Python host agent with psutil and optional NVML.
Replace Windows-only WMI collector so Win10/11, Linux, and macOS can feed the same SI protocol.
2026-10-27 20:21:08 +08:00

96 lines
3.3 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.
# CYD 本机 / 服务器信息面板
在 **2.8" / 3.5" CYD** 上显示当前电脑的 **CPU、GPU、内存、磁盘** 等主要信息。显示/触控骨架对齐 [tftest](../tftest) / [wifitest](../wifitest);板型差异按 [CYD_PROJECT_GUIDE.md](../CYD_PROJECT_GUIDE.md)。
| 板型 | env | 屏 / 触控 | 背光 |
|------|-----|-----------|------|
| **2.8" · 2432S028R** | `cyd`(默认) | ILI9341 + XPT2046 SoftSPI | GPIO**21** |
| **3.5" · 3248S035C** | `cyd_35r` | ST7796 + GT911 I2C | GPIO**27** |
本工程**无外设接线**(只吃 USB 供电 + 串口)。
## 原理
ESP32 无法直接读 PC 硬件。主机端跑跨平台脚本,经 **USB 串口** 按行推送:
```
SI|host=DESKTOP|cpu=i7-13700K|cpu%=12.3|gpu=RTX 4070|gpu%=5|ram=18.2/31.8|disk=512/931
```
屏上 LVGL 面板解析后画进度条;超过约 5 秒无新包显示 **stale**。
### 通用主机方案(Win10/11 · Linux · macOS)
业界常规做法(本仓库已采用):
| 层级 | 库 / 接口 | 覆盖 |
|------|-----------|------|
| **CPU / 内存 / 磁盘** | [`psutil`](https://psutil.readthedocs.io/) | Windows / Linux / macOS / BSD… |
| **串口** | [`pyserial`](https://pyserial.readthedocs.io/) | 同上 |
| **GPU 占用(可选)** | [`nvidia-ml-py`](https://pypi.org/project/nvidia-ml-py/)(NVML)→ `nvidia-smi` → `amd-smi`/`rocm-smi` | NVIDIA 最稳;AMD 有驱动/CLI 时可用;没有则 `gpu%=-1`(名称仍尽量读) |
入口:**[`host/send_sysinfo.py`](host/send_sysinfo.py)**(推荐)。Windows 也可 `.\host\send_sysinfo.ps1`(内部仍调 Python)。
```powershell
cd host
pip install -r requirements.txt
pip install nvidia-ml-py # 有 NVIDIA 时建议装
python send_sysinfo.py # 自动选串口
python send_sysinfo.py -p COM5 # Windows
python send_sysinfo.py -p /dev/ttyUSB0 # Linux
```
## 刷写
| 板型 | 目录 |
|------|------|
| 2.8" | [`firmware/cyd/`](firmware/cyd/) |
| 3.5" | [`firmware/cyd_35r/`](firmware/cyd_35r/) |
```powershell
cd firmware\cyd # 或 firmware\cyd_35r
.\flash.ps1
# 或
.\flash.ps1 -Port COM3
```
源码烧录:`pio run -e cyd -t upload`(3.5:`-e cyd_35r`)
重新打包:`.\firmware\export_from_build.ps1`(3.5 加 `-Env cyd_35r`)
串口监视:`pio device monitor -b 460800`
## 本地 git(必做)
本工程是**独立本地 repo**,有效改动都要提交;**不 push**(除非明确要求)。顺序对齐 [CYD_PROJECT_GUIDE.md](../CYD_PROJECT_GUIDE.md) §0 / §3:
1. 改代码
2. `pio run -e cyd -t upload`(或 `cyd_35r`)真机验证
3. `.\firmware\export_from_build.ps1`(需要时加 `-Env cyd_35r`)
4. `git add -A` → `git commit`
禁止:只改代码不烧录、不导出固件、**不本地 commit** 就收工。
## 推送本机信息
板子刷好并插上 USB 后,在主机上:
```powershell
cd host
python send_sysinfo.py
# 或
python send_sysinfo.py -p COM5 -i 1000
.\send_sysinfo.ps1 -Port COM5 # Windows 快捷入口
```
注意:串口同时只能被一个程序占用;跑推送脚本时不要开 `pio device monitor`。
## 文件
```
include/pins.h, touch.h, host_info.h, ui.h, lv_conf.h
src/main.cpp, touch.cpp, host_info.cpp, ui.cpp
host/send_sysinfo.py # 跨平台主入口
host/requirements.txt
host/send_sysinfo.ps1 # Windows 启动器
firmware/
```