Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

7.6 KiB

Modbus Runtime Cleanup Implementation Plan

For agentic workers: Execute this plan inline. Do not create a worktree
because the current working directory contains the user’s uncommitted project
changes and is the only complete current project state.

Goal: Remove unused IAR build inputs and IAR-only Modbus snapshots while
preserving the PLC protocol behavior and the two requested live-watch arrays.

Architecture: The target remains an STM32F407/uC-OS-II Modbus RTU slave.
Only the IAR project source list and application-level diagnostic path change;
the protocol core, backup module, interrupt behavior, public data storage, and
TouchWin contract remain intact. The final project design is generated after
the source edits so every locator reflects the finished code.

Tech Stack: IAR EWARM 8.3, STM32F4 HAL, uC/OS-II, C99 host tests,
PowerShell static checks, Markdown.

Global Constraints

  • Preserve holdingRegisters, coilStorage, and extendedHoldingRegister.
  • Preserve standard function codes 0x01/0x03/0x05/0x06/0x0F/0x10, private
    functions 0x41/0x42/0x43, and the 0x00010000 RTC retention path.
  • Do not edit vendor sources under Drivers/ or RTOS sources under Core/OS/.
  • Retain EWARM/Modbus/Exe/Modbus.hex, document/, uC-OS2_temp/, and IAR
    settings files.
  • Do not stage or commit because the worktree contains unrelated user changes.

Task 1: Remove unused HAL compilation entries

Files:

  • Modify: EWARM/Modbus.ewp:1140-1173
  • Verify: EWARM/Modbus/List/Modbus.map

Interfaces:

  • Consumes: the current link map, which records zero linked sections for the
    eight listed HAL translation units.

  • Produces: an IAR source list that compiles only the HAL modules used by the
    current target.

Task 2: Remove IAR-only Modbus snapshots while retaining live-watch data

Files:

  • Modify: Core/Src/main.c:30-41, 107-116, 630-710, 730-780, 818, 890-940
  • Modify: Core/Inc/main.h:37-51
  • Modify: Core/OS/Cfg/app_cfg.h:45-47
  • Modify: Core/Modbus/app_runtime_test.c:78-106

Interfaces:

  • Consumes: holdingRegisters, coilStorage, and extendedHoldingRegister
    as the only IAR Live Watch data interface.

  • Produces: the same UART recovery and RTU behavior without exported snapshots
    or their RAM buffers.

Task 3: Improve comments in project-owned runtime and protocol modules

Files:

  • Modify: Core/Src/main.c
  • Modify: Core/Inc/main.h
  • Modify: Core/OS/Cfg/app_cfg.h
  • Modify: Core/Modbus/modbus.c
  • Modify: Core/Modbus/modbus.h
  • Modify: Core/Modbus/modbus_backup.c
  • Modify: Core/Modbus/modbus_backup.h
  • Modify: Core/Src/stm32f4xx_it.c
  • Modify: Core/Inc/stm32f4xx_it.h

Interfaces:

  • Consumes: existing APIs and symbol names.

  • Produces: Doxygen comments that explain ownership, protocol constraints,
    concurrency boundaries, parameter units, side effects, and error behavior.

Task 4: Remove reproducible artifacts and prevent regeneration

Files:

  • Modify: .gitignore
  • Delete: root app_runtime_test.exe, modbus_backup_test.exe,
    modbus_protocol_test.exe, and all root *.stackdump
  • Delete: EWARM/Modbus/Obj/, EWARM/Modbus/List/Modbus.map,
    EWARM/Modbus/Exe/Modbus.out, EWARM/Modbus/Exe/Modbus.sim, and
    EWARM/Modbus.dep

Interfaces:

  • Consumes: Modbus.hex as the retained downloadable firmware artifact.

  • Produces: a source workspace without host-test binaries or IAR intermediate
    outputs.

Task 5: Generate the source-aligned project design and run regression gates

Files:

  • Create: docs/项目设计.md
  • Verify: Core/Modbus/modbus_test.c, Core/Modbus/modbus_backup_test.c,
    Core/Modbus/app_runtime_test.c, Core/Modbus/check_rtu_runtime_invariants.ps1,
    Core/Modbus/check_no_communication_counters.ps1, EWARM/Modbus.ewp

Interfaces:

  • Consumes: final source line numbers after Tasks 1-4.

  • Produces: a maintainable design document whose code references can be opened
    directly in the source tree.