- feat(client): 增加裁判比赛计时、技术暂停与选手端局域网同步 - feat(armor): 红蓝共用通用固件,按客户端选队并显示网络连接状态 - feat(armor): 仅在对局进行中允许扣血,其他阶段保留受击闪烁 - feat(client): 将计时置于血条中间并增加开赛前五秒全屏动画 - fix(client): 修复连续血条、对手镜像和图传断连灰度遮罩 - fix(client): 统一界面中文字体并整理各页面文案 - fix(maintenance): 备份迁移装甲板分区,恢复 SDK 构建与固件打包 - refactor(repo): 按 armor、vt 和 client 整理工程与脚本,移除旧参考实现 - test: 补充线路、受击许可、回环 UDP、维护和 HUD 验证 - docs: 同步构建、协议、比赛控制和硬件验证边界 验证:前端构建与 19 项相关测试通过;核心 91 项单元测试与 2 项回环 UDP 集成测试通过;装甲板规则 25 项、线路 26 项、Tauri 51 项测试通过;独立探测器 5 项与目录回归 4 项通过。完成 C3 两组阈值实际编译、导出与 ZIP 校验,检查 900×600 / 1280×720 页面、倒计时和随包中文字体。 未执行烧录、板上运行、跨电脑广播或硬件稳定性验证。
66 lines
2.6 KiB
Python
66 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Compile the actual driver handoff function with deterministic queue stubs."""
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
source = (root/'components/esp32-camera/driver/cam_hal.c').read_text()
|
|
start = source.index('camera_fb_t *cam_take_latest(')
|
|
end = source.index('\nvoid cam_give(', start)
|
|
function = source[start:end]
|
|
out = root/'target/latest-frame-test'
|
|
out.mkdir(parents=True, exist_ok=True)
|
|
test = r'''
|
|
#include <assert.h>
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
typedef unsigned TickType_t;
|
|
typedef struct { int id; } camera_fb_t;
|
|
static struct { size_t frame_cnt; } object = {3}, *cam_obj = &object;
|
|
static camera_fb_t frames[] = {{0},{1},{2},{3},{4},{5}};
|
|
static int calls, releases[6], mode;
|
|
static camera_fb_t *cam_take(TickType_t wait) {
|
|
assert(wait == (calls == 0 ? 100 : 0));
|
|
++calls;
|
|
if (mode == 1 || (mode == 2 && calls == 2)) return NULL;
|
|
assert(calls < 6);
|
|
return &frames[calls];
|
|
}
|
|
static void cam_give(camera_fb_t *frame) { releases[frame->id]++; }
|
|
'''+function+r'''
|
|
static void reset(int scenario) {
|
|
mode=scenario; calls=0;
|
|
for(int i=0;i<6;i++) releases[i]=0;
|
|
}
|
|
int main(void) {
|
|
uint32_t skipped=99;
|
|
// A producer that stays ahead cannot make the drain loop run forever.
|
|
reset(0);
|
|
camera_fb_t *latest=cam_take_latest(100,&skipped);
|
|
assert(calls==3 && latest->id==3 && skipped==2);
|
|
assert(releases[1]==1 && releases[2]==1 && releases[3]==0);
|
|
// An unavailable/invalid newer candidate must not release our valid frame.
|
|
reset(2);
|
|
latest=cam_take_latest(100,&skipped);
|
|
assert(calls==2 && latest->id==1 && skipped==0 && releases[1]==0);
|
|
// A first-frame timeout has no handle to return, and resets the skip count.
|
|
reset(1);
|
|
assert(cam_take_latest(100,&skipped)==NULL && skipped==0 && calls==1);
|
|
// A single capture buffer performs no second, nonblocking acquisition.
|
|
reset(0); object.frame_cnt=1;
|
|
latest=cam_take_latest(100,NULL);
|
|
assert(calls==1 && latest->id==1 && releases[1]==0);
|
|
puts("4 latest-frame ownership and bounded-drain scenarios passed");
|
|
}
|
|
'''
|
|
(out/'latest-frame.c').write_text(test)
|
|
compiler = shutil.which('clang') or shutil.which('gcc')
|
|
if not compiler:
|
|
sys.exit('A host clang or gcc is required for this optional driver test')
|
|
binary = out/('latest-frame.exe' if sys.platform=='win32' else 'latest-frame')
|
|
subprocess.run([compiler,'-std=c11','-Wall','-Wextra','-Werror',str(out/'latest-frame.c'),'-o',str(binary)],check=True)
|
|
subprocess.run([str(binary)],check=True)
|