ea5ef6b7515aefc2ee4510f54a599c56e78b44f0
8 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
518e12f200 |
chore(gate): cppcheck 受检范围与编码规范对齐,存量 30 条 style 清零
起因:装真 cppcheck 2.21.0 后本钩子暴露 106 条命中,其中 76 条本就不该被扫。 cppcheck 与 coding-standard 两个钩子的注释都自称「范围一致」,实际各漏一块, 而本钩子此前从未真正跑起来(C:\cppcheck\cppcheck.exe 是坏 zipapp,进程根本没起, --error-exitcode 对「没跑起来」不生效),所以没人发现。两轮合计 834 条命中里 802 条是「不该被扫的」,真问题被完全淹没。 一、范围对齐(106 → 30) cppcheck 钩子 exclude 补三条 104 上游前缀:App/iec60870/common/、 App/iec60870/104/business/、App/iec60870/104/IEC104[_.]。三条只豁免上游库 尚未改造的部分,我们自己的小写适配文件(iec104_core/net_mcu/source/comm)仍受检。 不能改写成祖先目录 App/iec60870/,那会把适配层一起豁免。 test-cppcheck 钩子排除 test/host/iec104_netmcu/results(按 check_static_selftest.py 生成的自检变异体是故意写坏的副本,不是被测代码)。 二、剩余 30 条直接改代码清零(未建抑制基线) 逐条核过:cppcheck 判对了,它们违反本仓 docs/代码规范/嵌入式C语言代码规范_V1.0.md §6.1.1「变量应在使用前声明,并尽可能在靠近使用的地方声明」。仓内对「永久免检」 有明确反对立场(coding-standard 的 104 排除注释写着「改完必须删掉这三行,否则等于 自建代码永久免检」),故不建抑制基线,直接改对: - iec104_comm.c:4 处 v > IEC104_COMM_CA_MAX / PORT_MAX 删除。上界 65535 是 uint16_t 类型极限,比较恒为假(compareValueOutOfTypeRangeError);宏本身保留, App/app/ui_data_feed.c 的 UI 范围提示仍要用它表达合法带上界。 - ioboard_bits.c:删 && (i < IOBOARD_DI_COUNT),外层 for 已限定,且它在取下标之后才判。 - iec104_source.c:三处 ifdef 哑变量(a/p/raw、e/i/b/raw/p/element、i/m/g/valid) 把声明搬进各自编译档内,删掉全部 (void)x 抑制句——正是这些抑制句让 cppcheck 认为「读了未赋值变量」(unassignedVariable)。另 remote_lookup / parameter_config 的 i/n/p、g/m 就近声明。 - iec104_net_mcu.c:Listen 的 uint32_t i、Wait 的 listen_slot/client_slot/sock 移进各自分支;sock 加 const。 - net_socket.c:net_pending_bytes 的 p_sock 加 const。 - ui_task.c:ui_task_wave_load_head 的 FRESULT fr 移进 if (ofr == FR_OK) 块。 - ioboard_di.c:ioboard_di_snap_read 的 s1/s2 移进重试循环。 - ui_page_yx.c:pg_refresh 的 dio_row 移进板级开入开出区分支。 三、实证 - cppcheck 钩子:106 → 30 → 0,Passed。 - 反证钩子没被排除条款吞掉:注入 variableScope 探针 → 立即报出 variableScope + unreadVariable 两条;恢复后重新 Passed。 - Keil BUILD_OK 0 errors 0 warnings,Program Size 逐项不变 (Code=365896 RO=48336 RW=2736 ZI=173104)=本轮全是纯排版,零目标码变化。 - test-cppcheck Passed(0 命中)。 - 全量 manual 阶段 52 根钩子全绿、0 失败。 - host 套件:iec104_comm 50/50、ioboard 131/131、iec104_dtu 7 tests OK、 iec104_serv 50/50、net_socket 683/683、sys_clock 111/111、iec104_netmcu 17/17、 net_events 34/34、net_listener 34/34、net_pending 43/43、net_select 22/22、 ui_sink 17/17、lftpd 35/35、lftpd_inet 29/29、time_sync 33/33。 - UI golden:77 个页面 + 待机水位 + rtlive 全通过。 - net-handle:495 文件 PASS 0 违规。 - 裁剪档 IEC104_SOURCE_NO_VALUE_STORE 隔离编译 rc=0 无 error/warning (声明搬进 #else 后必须保证该档仍成立)。 - BOM:ui_page_yx.c / ui_task.c 编辑后 BOM 被剥,已补回,check_bom_drift rc=0。 四、顺带修掉的两处真实漏项 - ram_baseline.py 的 subsystem_of() 前缀表漏 ioboard:App/util/ioboard_di.c 编出的 ioboard_di.o(4 B)一直静默算进「其它」而非「应用」,台账配额表看不见。 - 内存台账回填:a2242b73(IEC104_Net_Listen 修复)是上次回填 |
||
|
|
50ee1b4402 |
docs(ioboard): tighten shadow-register note and fix polarity item ref
Two comment-only follow-ups carried over from gate #33 (both deferred by the reviewer to keep the accepted face frozen; no code, no size impact - attestation restamped after a no-diff rebuild): - Drivers/BSP/IOBOARD/README.md item 6: the "what I last asked for" gloss of the software shadow register is exact for the 9 relay/LED bits but not for bit6, which ioboard_do_get() reports as the driver-synthesised supply state. Qualify it in place and point at item 4 for the rule instead of restating it. - test/host/ioboard/ioboard_test.c: the ACTIVE-level comment says the polarity fact lives in README section 6 item 7; it has always been item 5 (item 7 is the PE2/PE4 naming residue). This test is the polarity pin, so a wrong cross-ref here is the worst place to leave one. |
||
|
|
6e0755f971 |
feat(ioboard): make KO_24V an auto relay supply enable (9 channels)
KO_24V (PF4, bit6) is not an externally controllable output: it feeds the other KO channels, so the driver now asserts it automatically whenever any relay-class channel (bit0/1/2/3/7/8) is attracted, and never for the three LED channels (bit4/5/9). Externally controllable outputs become 9; physical bit map, DO_COUNT=10, DO_MASK_ALL=0x03FF, k_do_pin[] binding, per-port BSRR segments and the uint16_t path are unchanged. - ioboard_do_write: clear the caller's bit6, synthesize it from IOBOARD_DO_RELAY_MASK (0x18F), then one shadow store + one apply, so bit6 changes in the same BSRR write as its GPIOF neighbours. - ioboard_do_get: bit6 now reports the actual 24V supply state, not an echo of the caller's write. Power-on release keeps PF4 low. - board test Phase 3 derives expectations from RELAY_MASK (no second truth table); the KO_24V row exercises "write ignored" and a new auto-24V check verifies set-on-relay / drop-on-release. - host contract test pins RELAY_MASK membership (excludes bit6 and LED bits, union fills 0x3FF); 131/131 passed. - docs: sync note v1.4 + BSP README unify the semantics (9 controllable + auto supply enable); stale "10 controllable" and "24V interlock not implemented" wording removed; netlist-unknown routing, PC15 backup-domain 3 mA limit and the missing auxiliary contact remain documented as open facts. Verified: Keil rebuild 0 error 0 warning (sizes identical to parent wave), host unit tests 131/131, check_bsp_err / check_doc_links / git diff --check clean. Board Phase 3 still needs a bench run. |
||
|
|
74efa671bb |
feat(ioboard): wire 6 new CubeMX pins into 10-channel DO driver
Flat-expand the board output driver from 4 to 10 channels as decided: IOBOARD_DO_COUNT 4->10, mask uint8_t->uint16_t, IOBOARD_DO_MASK_ALL 0x03FF. The 6 new pins keep their bit positions: KO_LED1=PF2(bit4), KO_LED2=PF3(bit5), KO_24V=PF4(bit6), KO4=PF5(bit7), KO5=PC15(bit8), KO_LED3=PE6(bit9); the original 4 (KO6/TRIP/ERT/CLZ) keep bit0..3. Backups-domain PC15 is used as a signal bit only (+/-3 mA limit). No 24V supply interlock and no LED special-casing: the driver writes KO_24V as an ordinary bit; callers needing relay power sequencing must assert it before energizing a channel. do_write/get/read_level and the shadow register are all uint16_t; do_apply flushes four port segments (GPIOC/GPIOF/GPIOC/GPIOE) and do_read_level caches three port ODRs. UI: UI_DATA_DO_N 4->10, dio_do_mask uint16_t, UI_DATA_VER 3->4 because dio_do_valid shifts 211->212; feed mask and dio row table extended; content-page golden references regenerated for 51 rows / 7 pages. Host ioboard tests 127/127 and ui_data tests 305/305 pass; Keil rebuild 0 errors 0 warnings. RAM ledger, memory snapshot and size attestation refilled from the authoritative map. Docs: ioboard spec v1.2->v1.3 and the resolved 6-pin question closed out. |
||
|
|
12e0617909 |
fix(gates): close the BOM gate hole that let new files skip the check
The BOM gate claimed to stop BOMs from being stripped, but it only ever inspected files that were already tracked AND already had a BOM. A new file under a BOM-listed directory could be born without one and never be noticed, because the scan never returned it and, even if it had, the "no HEAD version" branch skipped it. Editing a listed file and losing its BOM is a real accident that already happened once; creating one without a BOM was the same accident with no safety net at all. Measured before and after on the same untracked file with no BOM: before: checked 101 files, no drift, exit 0 after: FAIL, names the file, exit 1 The count of 101 was itself the symptom: with one more file present the honest number is 102. The old code was not "silently passing a clean tree", it was not looking. The scan now includes untracked files, and a listed file with no HEAD version must carry a BOM. Files that are tracked without a BOM keep their historical pass so this does not flood existing code with failures; instead the two that were listed but had no BOM were given one so the list means what it says. That exposed a conflict nobody had hit yet. The font file is generated, and the generator rewrites it from scratch on every run, so a hand-added BOM survived until the next regeneration and then vanished. The BOM gate and the generated-fresh gate could not both pass. The generator now puts the BOM back as its last step, idempotently, so the two gates agree and the whole UI directory keeps its uniform encoding. Font content is untouched: everything after the first three bytes is byte-identical. The menu generator gains a real read-only mode. It previously had no options at all and always rewrote its outputs; the arrows it printed were accurate. That made it easy to mistake for a checker, since an unchanged tree produces identical bytes and looks untouched. --check now reports up to date or stale without writing anything, and the registration tables are checked the same way. Default behaviour and output are unchanged. The telemetry page header no longer restates the board's input hardware facts. They live in the IOBOARD README, which is where the board's electrical behaviour belongs; the page keeps only what it alone can say: that the output rows show the shadow register rather than contact feedback, why an invalid sample draws -- instead of 分, and that these twelve rows are not in the point table. One fact, one place. The team rule for experiments now requires the file hash, the located line number, and both runs. A report once cited a line number that did not exist in the final file, which left no way to confirm which version had actually been tested. |
||
|
|
515db819ab |
feat(ui): fold board inputs and outputs into the telemetry page
The 12 board-level rows now live at the end of the 遥信量 page instead of a separate 开入开出 page: 8 opto inputs (DI_A..DI_H) and 4 relay outputs (KO6/TRIP/ERT/CLZ). 33 rows become 45, five pages become six. The standalone page, its menu entry, its golden references and both build registrations are removed. Folding the display is not folding the point table. The board rows render from dio_di_* / dio_do_* and stay out of yx_bits / yx_valid / yx_dp: any change to those carriers is provably absent from this diff. IEC 104 mapping and YX_VALID_MASK are untouched, so nothing new is reported to a master station. Input polarity was wrong and is fixed here. On this board a 24 V input drives the opto, which pulls the 74HC165 pin LOW, so the raw mask is inverted relative to "has signal". The bit assembly only reordered bits; nothing converted the level. The screen showed 分 on every channel no matter what the operator drove in. Polarity now converts once, in the driver, behind IOBOARD_DI_LEVEL_ACTIVE (0 = active low), so callers see 1 = has signal for both inputs and outputs. Verified on the board: page 5 shows YX33 followed immediately by DI_A, crossing the 33-point boundary with no drift; DI_C reads 合 because the operator's signal is on channel C, the other seven read 分; page 6 shows DI_H then all four outputs 释放. Page rows end at y=134, the footer starts at y=144. Input bit order is only partly verified: channel C was confirmed against a real signal, the other seven have not been exercised channel by channel. The board detects the presence of 24 V, not contact closure, and the output rows show the shadow register (our intent) rather than mechanical contact feedback. All three limits are recorded in the page header and in the IOBOARD README. Also adds a polarity guard to the host tests: the input polarity was flipped once already, and until now no assertion would have caught a silent re-flip, since only the DO side was pinned. |
||
|
|
2b466b85f0 |
feat(ui): add DI/DO status page showing 8 inputs and 4 outputs
New read-only content page under 实时数据 → 开入开出 showing the board's
8 opto inputs (DI_A..DI_H, 合/分) and 4 relay outputs (KO6/TRIP/ERT/CLZ,
吸合/释放) as a 12-row list, 8 rows per page, 2 pages.
Data path reuses the existing de-bounced input poll instead of adding a
second hardware reader:
defaultTask (50 ms) → ioboard_di_snap_publish() → de-bounced snapshot
→ ioboard_di_snap_lookup() [new registration channel]
→ ui_data_feed_tick() (uiTask, 200 ms)
→ ui_data_rt_t.dio_di_* / dio_do_*
No new critical sections, no new hardware access on the UI path. Outputs
come from the volatile shadow register (a memory read, no lock).
Semantic honesty, recorded in ui_page_di_do.c and README §6:
· Output state is the software shadow register (ODR mirror), NOT a
mechanical contact feedback — this platform has no auxiliary contact
readback path. ioboard_do_read_level() also reads ODR, so comparing
the two is tautological.
· IOBOARD_DO_LEVEL_ACTIVE polarity has not been checked against the
schematic.
· Input bit order has not been verified by manual shorting. The
2026-11-16 run read 0x00 eight times because the operator had no time
to short each channel — the data path itself was fine.
· Board-level inputs are deliberately kept out of the 33-point telemetry
bitmap (IEC 104 point-table semantics); the two have no mapping.
Invalid snapshots render "--", never 合/分 or 吸合/释放: painting "no data"
as "all inputs released" would tell the field the inputs are open when we
simply failed to read them.
Board-verified 2026-11-16: page 1 shows 分 on all 8 inputs, page 2 shows
释放 on all 4 outputs, page footer and paging correct. Input bit order
still pending manual shorting.
Also: regenerate ui_font_cn_12 for 吸/释, add golden references for both
pages, align check_menu_rows.py L2 geometry with the now-4-item submenu,
and register the new source file in both the Keil project and CMake.
Reviewed independently; zero blocking findings.
|
||
|
|
fd767d1dcd |
feat(ioboard): 开入开出板驱动、去抖快照与主机侧单测接入
74HC165 开入 + 光耦继电器开出的完整硬件抽象层,接进 defaultTask 的 50ms 节拍。开入 8 路(第二块 165 数据线板上未接,故只有 8 位), 开出 4 路(高电平吸合)。 驱动 BSP drivers: - IOBOARD/ioboard.c 装载与移位时序,每步注明数据手册依据; SH/LD 拉高前先拉低 CLK,否则装载瞬间多移一位; 单次读取上界 26us(延时按最慢列 VCC 2V 全温区取值)。 - IOBOARD/ioboard_bits.c 位序组装纯函数,只依赖 stdint.h, 主机侧可直接 include 做单测:读 8 次为 H,G,F,E,D,C,B,A, A 放 bit0(bit(7-i) = reads[i])。 - 极性集中在 IOBOARD_DO_LEVEL_ACTIVE 一处,接口语义统一为 mask 的 1 = 吸合。 业务接线: - App/util/ioboard_di.c 通道去抖与双区快照,纯逻辑; 刻意不 include ioboard.h(其引脚宏会牵入 main.h), 两处路数常量由测试的编译期静态断言钉住。 - default_task.c 的 default_task_di_poll():读失败不喂去抖、 不写发布值,只把上一有效值加 valid=0 发布出去, 避免"全 0"被现场读成开入全部复归。 - 去抖实际粒度 50ms(每个轮询周期喂一拍),最坏上报约 100ms; 想要真 20ms 需另建定时器,本次不做。 - Src/main.c 在 app_main_init 之前调 ioboard_init(), 上电即把 4 路出口钉在全释放并确认 165 静止态。 测试: - test/host/ioboard/ 100 条断言。位序主判据为单比特两端 (只有 A 得 0x01、只有 H 得 0x80)加八点双射穷举; 混合图样降级为辅助,因该图样曾先后被算成 0xA5、0x5A、0xAA。 - 去抖覆盖 20ms 边界、抖动不翻、跨 49.7 天回绕。 - 失败语义覆盖"失败保留上次有效值"与"失败窗口内的真实变位不丢"。 文档: - 新增 docs/硬件平台/开入开出实施说明.md。 - 硬件规格与能力边界 §5 的能力边界现状改写:出口继电器与 开入回路已具备、业务层未接入;4 路开出只可台架验证, 不得用于真实跳闸。 - 修正 docs/文档规范.md §3.1:原文要求所有互链用仓库根相对, 与 check_doc_links.py 的实际解析基准矛盾(markdown 链接按 当前文档目录解析,反引号路径才按仓库根)。改为区分两类, 并补 §3.1b 写明对应校验器。 - 清理 docs/任务规划/登记簿.md 改名为硬件改版登记.md 后 遗留的 9 处旧名引用。 门禁: keil-build 0 Error 0 Warning;主机侧单测 ioboard 100/100、 sb_proto 45/45;pre-commit 48 根钩子全通过。 |