该文件IEC104.zip是一个压缩包,内含与IEC60870-5-104通信协议相关的资源和文档。适合从事电力系统自动化领域工作的专业人士使用。
# IEC104 and IEC101 Protocol Implementation
This document describes the implementation of the IEC104/IEC101 communication protocol for power grid applications. The protocol code is designed to be platform-independent, having been tested on both STM32 and Linux platforms.
## Key Features
- **Platform Independence**: Abstracts hardware-specific details such as memory allocation functions.
- **Queue Management**: Implements a simple first-in-first-out (FIFO) queue with the ability to replace it with other algorithms based on requirements.
### Steps for Porting:
1. Implement function pointers in `_iec10x` structure according to specific platform needs.
2. Register implemented `iec10x` interface using `RegisterIEC10XMoudle`.
3. Create a thread to call `Iex104_Receive` for packet reception and parsing.
4. Establish another thread for calling `Iec10x_Scheduled`, which handles queue scheduling.
5. Implement a third thread that manages the state machine, controlling data packet enqueuing and dequeuing.
### Directory Structure
- **IEC0x**:
- iec101.c: IEC101 protocol package content
- iec104.c: IEC104 protocol package content
- iec10x.c: Queue initialization, enqueue/dequeue functions, priority management and scheduling
- **PRIO_QUEUE_Iec10x**: Contains the specific algorithm for queue operations.
### Important Functions:
- `Iec10x_Scheduled`: Manages dequeuing packets based on priorities.
- `IEC10X_Enqueue`, `IEC10X_Dequeue`, and `IEC10X_FindQHead`: Handle packet enqueuing, dequeuing, and identifying the highest priority packet respectively.
- Functions with prefix `IEC10X_` are used for packaging different protocol packets.
- `Iec104_StateMachine`: Manages state transitions in IEC 104 protocol.
- `Iex104_Receive`: Handles incoming data reception and parsing.
### Important Structures:
The `_iec10x` structure uses function pointers to facilitate platform-specific implementations. It includes various functionalities such as memory management, queue operations, sending packets over the network, time setting/getting functions, station state retrieval, value fetching from stations, link address obtaining, information number acquisition related to devices and configurations.
This design allows for easy adaptation of the protocol implementation across different hardware platforms while maintaining consistent behavior.