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:
@@ -11,8 +11,8 @@ recorded in the directory manifests before local compatibility edits.
|
||||
|
||||
| Check | Status |
|
||||
| --- | --- |
|
||||
| Original byte provenance | `UPSTREAM.sha256`; independent final 84-file check passed, six controlled source differences |
|
||||
| C99 assertions | 43 original invocations unchanged; independent AC5 true passes / false fails, invalid capacities including SOE128 rejected |
|
||||
| Original byte provenance | `UPSTREAM.sha256`; independent final 84-file check passed, seventeen locally differing files: twelve reviewed patches and five trailing-blank-line-only. The command-table patch spans two files in one directory (`IEC104_Command.h` and `.c`) and both are counted. The SOE-128 change touches `IEC104_TcpServer_Config.h` and `IEC104_AsduQueue.h` (capacity) plus `IEC104_TcpServer.c` (assert message text), with three comment-only corrections in `IEC104_Slave.h`, `IEC104_TcpServer.h`, `IEC104_Spontaneous.h` (stale "256" SOE wording fixed to 128, quantifiers only, semantics untouched; Lead decision 2026-11-18). |
|
||||
| C99 assertions | 43 original invocations remain; every assertion condition unchanged (one message text tracks the SOE capacity macro); independent AC5 true passes / false fails, invalid capacities including SOE128 rejected |
|
||||
| Final compiler diagnostics | Independent AC5 default/compact: 62 translation-unit compilations, RC0 and zero diagnostics; simulator and runtime tests tracked separately |
|
||||
| Static memory / runtime integration | Separate build-verifier and integration task evidence; no board runtime claim |
|
||||
| License | No license grant confirmed; redistribution not authorized by this import |
|
||||
@@ -30,7 +30,10 @@ Local edits use the Edit tool only.
|
||||
standalone Net header. In pre-C11 C, each existing assertion expands to a
|
||||
line-unique typedef with array bound `(condition) ? 1 : -1`; false assertions
|
||||
are compile errors. C11 targets retain native assertions. All 43 assertion
|
||||
invocations and their conditions/messages remain unchanged, including SOE=256.
|
||||
invocations remain, and every assertion CONDITION is unchanged. The only
|
||||
message text that differs is the SOE guard's event count, which tracks the
|
||||
capacity macro this product sets to 128 (see below); on C99 the message is
|
||||
discarded by the shim, so no assertion semantics move with it.
|
||||
- `104/IEC104_TcpServer.c`: two explicit `IEC104_TcpEventType_t` casts when
|
||||
expanding the byte-sized ring header into event validation helpers; no
|
||||
condition, capacity, storage layout or runtime behavior is changed.
|
||||
@@ -38,16 +41,68 @@ Local edits use the Edit tool only.
|
||||
convert nonnegative enum range checks to unsigned upper-bound comparisons.
|
||||
Invalid negative values still convert above the valid range and are rejected;
|
||||
AC5 no longer diagnoses pointless unsigned comparisons against zero.
|
||||
- `104/business/IEC104_Command.h`: mask each TYPE_BIT shift count with 15.
|
||||
- `104/business/IEC104_Command.h` + `104/business/IEC104_Command.c`: mask each
|
||||
TYPE_BIT shift count with 15, and remove the per-point `common_address`.
|
||||
Selected valid branches already use shifts 0..13; range guards still return
|
||||
zero for unsupported types. This avoids MSVC diagnostics about unsigned
|
||||
underflow in unselected conditional branches, not a proven executed runtime UB.
|
||||
The point table now sorts by IOA only; the instance binds its station CA on the
|
||||
first accepted request and `Find_Point` rejects any other CA before searching,
|
||||
so a CA mismatch still takes the unchanged unknown-IOA path. Point entry size
|
||||
drops from 12 to 8 bytes on ARM Compiler 5, letting the application hold the
|
||||
table in const Flash instead of static RAM. No capacity, SOE, ordering or
|
||||
acceptance semantics change; see `ci-artifacts/iec104-mcu-skeleton/core-trim/`
|
||||
for the element-wise and lookup equivalence probes.
|
||||
- Added `common/IEC60870_FaultEvent.c` as an exact-copy link dependency of
|
||||
`IEC104_Spontaneous_Publish_Fault_Event`, with Lead authorization.
|
||||
- `UPSTREAM.sha256`: 84 original byte hashes (29 implementations, 54 directory
|
||||
headers and the declarative profile header). Paths are relative to this
|
||||
directory and to `IEC60870-Slave/`; hashes describe upstream bytes, not the
|
||||
six locally patched files. The compatibility header is new and not upstream.
|
||||
twelve locally differing files. The compatibility header is new and not upstream.
|
||||
- Trailing blank lines: five files (`common/IEC60870_Codec.c`,
|
||||
`common/IEC60870_InformationObjects.c`, `common/IEC60870_InformationObjects.h`,
|
||||
`common/IEC60870_InformationObjects_Internal.h`,
|
||||
`examples/iec104_dtu_profile.h`) differ from upstream by exactly one
|
||||
end-of-file blank line, removed by the repository's `end-of-file-fixer`
|
||||
pre-commit hook (it does not exempt this tree). Content normalized for that
|
||||
single line is byte-identical to upstream, and `verify_vendor.py` asserts as
|
||||
much: its `BLANK` class may only list such files, and a semantic edit carried
|
||||
into one of them fails the check instead of hiding behind the class.
|
||||
- SOE capacity: this product sets `IEC104_TCP_SOE_CAPACITY` and
|
||||
`IEC104_ASDU_SOE_MAX_CAPACITY` to `128U` (upstream `256U`) to fit the RAM
|
||||
budget, and the guard message text follows the new count. IEC 60870-5-101/104
|
||||
does not specify SOE depth; the only numeric lower bound in play is the
|
||||
Swedish Svk TR02-04-04 §7.4.1 guidance of 100 entries, so 128 stays compliant.
|
||||
The assertion CONDITION (`SOE_CAPACITY == ASDU_SOE_MAX_CAPACITY`) is untouched,
|
||||
so the invariant it guards still holds.
|
||||
|
||||
## Capacity override surface (skeleton profile)
|
||||
|
||||
Eleven per-module capacity macros are already wrapped in `#ifndef`, so a build may
|
||||
override them with `-D` **without editing any source file**. This is what keeps the
|
||||
MCU skeleton profile small while the simulator keeps every business module enabled.
|
||||
`verify_vendor.py` compiles both the default and compact configurations and would
|
||||
catch an undefined-macro regression, but note that no `-D` is baked into any source.
|
||||
|
||||
| Macro | Default | File |
|
||||
| --- | --- | --- |
|
||||
| `IEC104_INTERROGATION_TASK_CAPACITY` | `4U` | `104/business/IEC104_Interrogation.c` |
|
||||
| `IEC104_INTERROGATION_EVENT_CAPACITY` | `4U` | `104/business/IEC104_Interrogation.c` |
|
||||
| `IEC104_SYSTEM_COMMAND_TASK_CAPACITY` | `4U` | `104/business/IEC104_SystemCommand.c` |
|
||||
| `IEC104_SYSTEM_COMMAND_RESET_CAPACITY` | `4U` | `104/business/IEC104_SystemCommand.c` |
|
||||
| `IEC104_PERIODIC_SCAN_GROUP_CAPACITY` | `4U` | `104/business/IEC104_PeriodicScan.c` |
|
||||
| `IEC104_PARAMETER_TASK_CAPACITY` | `4U` | `104/business/IEC104_Parameter.c` |
|
||||
| `IEC104_REMOTE_PARAMETER_TASK_CAPACITY` | `2U` | `104/business/IEC104_RemoteParameter.c` |
|
||||
| `IEC104_CLOCK_SYNCHRONIZATION_TASK_CAPACITY` | `4U` | `104/business/IEC104_ClockSynchronization.c` |
|
||||
| `IEC104_READ_TASK_CAPACITY` | `4U` | `104/business/IEC104_Read.c` |
|
||||
| `IEC104_COMMAND_REPLY_CAPACITY` | `4U` | `104/business/IEC104_Command.c` |
|
||||
| `IEC104_SPONTANEOUS_CAPACITY` | `IEC104_TCP_SERVER_CAPACITY` | `104/business/IEC104_Spontaneous.c` |
|
||||
|
||||
`IEC104_SPONTANEOUS_CAPACITY` is overrideable but yields no RAM saving (its pool
|
||||
element is callbacks/state, not a capacity-sized array), so the skeleton profile
|
||||
leaves it at its default. The 92% gate is unaffected: these macros size single
|
||||
instance work queues inside a business module, not the TCP server pool, SOE=128,
|
||||
k/w windows or concurrency semantics.
|
||||
- Independent hash/diff and AC5 true/false assertion verification is performed
|
||||
by build-verifier; product integration and simulator build have separate owners.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user