Files
STM32F4-Base/App/iec60870/IMPORT.md
T
wandering1 c0cef2fca0 refactor(app): 去掉 App/protocol 层,104 迁入 App/iec60870/104_port
IEC 60870 是标准族(含 104/101),原 App/protocol/ 把它拆成
iec60870/(vendor 核心)+ iec104/(我方适配)两棵同级树,多一层且
看不出「104 只维护一个」。现按标准族收口:

  App/protocol/iec60870        -> App/iec60870
  App/protocol/iec104          -> App/iec60870/104_port
  App/protocol/{README.md,.gitkeep}  删除
  App/protocol/iec104/iec104_asdu.h  删除(零 include / 零注册的孤儿)

vendor 子树(104/ common/ examples/)逐字节未改:91 个 R100 重命名、
git diff --cached -M 后 0 insertions / 0 deletions,另按字节直比 89/89
一致;UPSTREAM.sha256 差异集仍等于既有 17 项受控差异,非篡改。
适配层只改注释里的路径字样,无逻辑行。

门禁配套:
- coding-standard 的 exclude 不能写祖先 App/iec60870/——rename_ref 机械
  改出的祖先形态会把 2,191 行适配层一起豁免掉。改为三条精确前缀
  common/ 104/ examples/,适配层 11/11 回到受检;vendor 直调脚本仍报
  88 处违规而钩子 Skipped,证明确实由 exclude 生效而非空跑。
- check_registration 的 KNOWN_GAPS 键与理由文本同步到新路径。

验证:Keil 0 errors 0 warnings(Code=367464 RO-data=48492
RW-data=2288 ZI-data=173544),构建日志与 .d 依赖证明 5 个适配 .o
真被编入;模拟器 0 警告并跑通 iec104-tcp 13/13 真实 TCP 回环;
pre-commit 25 Passed / 0 Failed;doc-links 30 处问题全在
IEC60870-Slave/ 供应商快照,我方文档零新增。

顺带删掉仓根误入库且零引用的 _all_hook.txt 与 _scope.txt。
2026-11-18 14:15:10 +08:00

8.3 KiB

IEC60870-Slave product subset

Source: repository IEC60870-Slave/ at baseline f84855a5.

The source directory is retained as the independent validation baseline. Only this product subset is to be compiled into the replacement product target. No example main is included. Copying is byte-preserving; source hashes are recorded in the directory manifests before local compatibility edits.

Verification status

Check Status
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

Required scope: APCI transport, GI/CI, spontaneous/periodic measurements, commands, clock synchronization, read, standard parameters and Type200-203. History, recording, file storage and firmware-upgrade backends are not imported; product integrations must reuse existing subsystems. Organizational source import is not a rename; baseline paths remain unchanged. Local edits use the Edit tool only.

Local patches

  • Added common/IEC60870_StaticAssert.h, included by shared Types and the 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 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.
  • 104/IEC104_SendManager.c and 104/business/IEC104_Spontaneous.c: 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 + 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 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.

License

No license grant has been inferred. The baseline license must be checked before redistribution outside this authorized project integration.

Layout

  • common: shared ASDU, information-object codecs and time representation.
  • 104: mature transport and business state machines.
  • examples: DTU declarative point-profile header only, never an example main.

The board network backend is a later integration task; importing this subset does not by itself remove dependencies of the current board service.

Resource capacities must be measured before adjustment. No assertions, quality gates, stack limits or compiler diagnostics are disabled by this import.