feat(iec104): 把 104 骨架完整迁到 MCU 板端并在台架跑通总召
把 IEC104 从模拟器端整体搬到板端:协议栈原先由独立 iec104Task 驱动, 现在改为 netTask 单 owner 的 threadless 驱动,退役独立任务。 驱动与后端: - 新增 iec104_net_mcu.c/.h,实现 IEC104_Net.h 的 11 个 ABI 函数, 用槽表加单调句柄映射 net_socket 的单 fd 模型;CLIENT 拆除只走 net_drop_conn_locked,绝不 net_close 监听 fd。 - net_socket 增 5 个 owner-only 接口(net_accept_locked、 net_drop_conn_locked、net_pending_bytes、net_send_try、 net_mono_now_ms)。 - iec104_serv.c 重写为 iec104_serv_net_tick(),在 netTask 1ms 主循环 里驱动 core;无 osDelay/阻塞调用,喂狗是第一句。 - Src/freertos.c 删除 iec104Task 三件套,对应栈水位探针表项同步删除。 内存:目标板 192KB SRAM 装不下 vendor 默认容量档,按实测裁剪到 skeleton 档(TCP 缓冲、业务池、SOE 256->128、值槽密集化), RW_IRAM1 118,408 B / 90.3%,留 2,178 B 余量。 台架修复(只在真硬件暴露): - SNTP s_ctx.fd 零初始化后为 0,而 net fd 0 是合法槽位下标, 首次代次变化时误 net_close(0) 关掉 ftpTask 的监听槽,导致 104 连接被 FTP 的 220 banner 抢走;改为显式 .fd = -1。 - Accept 幂等:单 fd 模型下 vendor 每轮重试 Accept 会拿到同一 fd, 后端改为会话在役时返 WOULD_BLOCK,Close 不再清槽。 验证: - Keil 全量重建 0 error 0 warning,uvprojx 零抖动。 - 模拟器真实 TCP 13/13、transport 10/10。 - netmcu 后端单测 13/13(新增 N12)。 - 台架 serial-boot-test required 全中;板端 2404 总召 129 帧收到 59 遥信(53 有源、全 IV)+ 16 双点 + 30 遥测(PT1 三相非零、 UN/频率/温度按未标定置 IV)、遥控选择执行全否定、校时 COT 7。 - 期间顺带修正 UI 漂移自检文案、.serialtest required 陈旧项、 coding-standard 对 vendor 与外部 ABI 名字的排除口径。
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Self-test the static checker against a deliberately BAD source copy.
|
||||
|
||||
Generates a copy of the real backend with `net_close_sock` injected into the
|
||||
IEC104_Net_Close CLIENT branch, runs check_static.py.main() on the copy, and
|
||||
asserts S1 fails there while the real source still passes. The product source
|
||||
is never edited; the mutant stays under results/static_mutant/.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, HERE)
|
||||
import check_static # noqa: E402
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
|
||||
SRC = check_static.SRC
|
||||
OUT = os.path.join(HERE, "results", "static_mutant")
|
||||
MUTANT = os.path.join(OUT, "iec104_net_mcu_BAD.c")
|
||||
NEEDLE = " client_slot_drop(slot);\n return result(IEC104_NET_OK, 0, native_error);\n }\n /* LISTEN 分支"
|
||||
|
||||
|
||||
def main():
|
||||
os.makedirs(OUT, exist_ok=True)
|
||||
with open(SRC, "r", encoding="utf-8") as fh:
|
||||
text = fh.read()
|
||||
assert text.count(NEEDLE) == 1, "Close CLIENT branch marker not unique"
|
||||
bad = text.replace(
|
||||
NEEDLE,
|
||||
" (void)net_close_sock(net_get_sock(slot->fd)); /* BAD mutant */\n" + NEEDLE,
|
||||
1,
|
||||
)
|
||||
assert bad != text, "mutant injection did not change the copy"
|
||||
with open(MUTANT, "w", encoding="utf-8", newline="\n") as fh:
|
||||
fh.write(bad)
|
||||
|
||||
real_rc = check_static.main()
|
||||
mutant_rc = check_static.main(MUTANT, OUT)
|
||||
with open(os.path.join(OUT, "selftest.txt"), "w", encoding="utf-8") as fh:
|
||||
fh.write("real_rc={}\nmutant_rc={}\n".format(real_rc, mutant_rc))
|
||||
fh.write("real source: {}\nmutant: {}\n".format(SRC, MUTANT))
|
||||
print("static-checker selftest: real_rc={} mutant_rc={}".format(real_rc, mutant_rc))
|
||||
return 0 if real_rc == 0 and mutant_rc != 0 else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user