Ship Windows plug-and-play host exe with USB wait and autostart.

Users no longer need Python: run.bat or install_autostart.ps1; agent reconnects when CYD is plugged in.
This commit is contained in:
2026-10-27 20:23:57 +08:00
parent 8cc030178f
commit f83df3fd39
8 changed files with 257 additions and 66 deletions

View File

@@ -21,23 +21,35 @@ SI|host=DESKTOP|cpu=i7-13700K|cpu%=12.3|gpu=RTX 4070|gpu%=5|ram=18.2/31.8|disk=5
### 通用主机方案(Win10/11 · Linux · macOS)
业界常规做法(本仓库已采用):
ESP32 **读不到** PC 的 CPU/GPU,主机上必须有个小代理——但**不必安装 Python**。
| 用法 | 谁适合 |
|------|--------|
| **Windows 插上即用** | 双击 [`host/run.bat`](host/run.bat) 或跑一次 [`host/install_autostart.ps1`](host/install_autostart.ps1)(开机自启 + 等 USB) |
| **免安装单文件** | [`host/send_sysinfo.exe`](host/send_sysinfo.exe)(PyInstaller 打包,目标机无需 Python) |
| **开发 / Linux / macOS** | [`host/send_sysinfo.py`](host/send_sysinfo.py) + `pip install -r requirements.txt` |
采集栈(业界常规):
| 层级 | 库 / 接口 | 覆盖 |
|------|-----------|------|
| **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)。
| **CPU / 内存 / 磁盘** | [`psutil`](https://psutil.readthedocs.io/) | Windows / Linux / macOS… |
| **串口** | [`pyserial`](https://pyserial.readthedocs.io/) | 同上;断线自动重连、无口时等待插入 |
| **GPU 占用(可选)** | `nvidia-ml-py` → `nvidia-smi` → `amd-smi`/`rocm-smi` | 没有则 `gpu%=-1` |
```powershell
# Windows 最终用户(推荐)
cd host
.\install_autostart.ps1 # 装一次:以后插 USB 就推
# 或临时:
.\run.bat
# 开发者重打包 exe:
.\build_exe.ps1
# Linux / macOS / 有 Python 时:
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
python send_sysinfo.py -p /dev/ttyUSB0
```
## 刷写
@@ -71,25 +83,21 @@ cd firmware\cyd # 或 firmware\cyd_35r
## 推送本机信息
板子刷好并插上 USB 后,在主机上:
板子刷好后:
```powershell
cd host
python send_sysinfo.py
# 或
python send_sysinfo.py -p COM5 -i 1000
.\send_sysinfo.ps1 -Port COM5 # Windows 快捷入口
```
1. Windows:`cd host` → `.\install_autostart.ps1`(装一次)或 `.\run.bat`
2. 插上 USB;代理会等串口并自动推送(状态变 **live**)
注意:串口同时只能被一个程序占用;跑推送脚本时不要开 `pio device monitor`。
注意:串口同时只能被一个程序占用;跑代理时不要开 `pio device monitor`。卸载自启:`.\uninstall_autostart.ps1`。
## 文件
```
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 # 跨平台主入口
include/… src/… firmware/
host/send_sysinfo.exe # Windows 免 Python(入库)
host/run.bat # 双击启动
host/install_autostart.ps1 / uninstall_autostart.ps1
host/build_exe.ps1 # 重新打包 exe
host/send_sysinfo.py # 源码(Linux/macOS/开发)
host/requirements.txt
host/send_sysinfo.ps1 # Windows 启动器
firmware/
```