The background,

What is Statute 104?

104 statute national power equipment communication of a standard protocol, the version is currently divided into IEC104 1997 and 2002 two versions, there is no change in the process, the 02 version is only in the 97 version extended telemetry, telemetry and other information body address, the difference is as follows:

category 1997 version of the base address Version 2002 base address
Remote communication 1H—-400H 1H—-4000H
telemetry 701H—-900H 4001H—-5000H
Remote control B01H—-B80H 6001H—-6100H
Instruction in B81H—-C00H 6201H—-6400H
The electricity C01H—-C80H 6401H—-6600H

Second, 104 statute frame format analysis

104 Protocol frame format:

There are three types of control domain formats:

1) U format: uncounted control function type, used to transmit control command packets.

APDU in U format contains only APCI, and the frame length is 6 bytes.

2) I format: information transmission format type. It is used to transmit the packet containing the information body and confirm the information packet in I format.

APDU in I format contains APCI and ASDU

3) S format: monitoring function type of counting, used to transmit confirmation packets to the station.

APDU in S format contains only APCI, and the frame length is 6 bytes.

The contents of an APDU frame in S format are as follows: 68 04 01 00 98 53 The first four bytes are fixed, and the last two bytes indicate the receiving number. S frames and I frames are used in combination to confirm information. The master and sub-stations can send the information at a frequency, such as receiving 8 I frames and replying to an S frame, or requesting to receive an I frame and replying to an S frame.

②.104 Statute ASDU:

Data unit identifier:

1) Data unit type:

Type identifier (TYP) : 1 byte

Variable structure qualifier (VSQ) : 1 byte

2) Transfer reason (COT) : 2 bytes

3) ASDU public Address (ADR) : 2 bytes

4) Information object address (InfoAdr) : 3 bytes

Common type identification (TYP) :

Variable structure qualifier (VSQ) : 1 byte, the highest bit is the continuous flag (1: continuous, 0: discontinuous), and the last seven bits indicate the number of information objects.

When variable structure qualifier highest continuous 1, the corresponding n information object, the first body address information object contains information (3 bytes) said since this statute address, the second information object contains information no longer address, the second information object address is increasing in the first address information object information in the body. When the highest bit of the variable structure qualifier is 0, it indicates discontinuity, and each information object contains the information body address.

Transfer reason (COT) : 2 bytes, low byte first, high byte second.

Packet instance parsing

Example 1: Data total call reply packet.

Send: 68 0E 62 03 DC 53 64 01 06 00 01 00 00 00 00 14

Reception: 68 0E DC 53 64 03 64 01 07 00 01 00 00 00 00 14 68 10 DE 53 64 03 01 83 14 00 01 00 01 00 00 01 00 01 68 3A E0 53 64 03 0D 89 14 00 01 00 01 40 00 D8 A3 C0 3F 00 55 E3 C5 3F 00 6B BC C4 3F 00 D7 A3 CE 42 00 00 80 CE 42 00 70 BD CE 42 00 F6 08 88 43 00 CC CC 5C C1 00 70 BD C7 42 00 68 0E E2 53 64 03 64 01 0A 00 01 00 00 00 00 14

1. Send a message: Call the full data activation frame

2. Receive the packet

Contains: call full data activation confirmation frame, remote message data frame, telemetry data frame and call full data activation end frame

1) Call full data activation confirmation frame:

2) Remote data frame:

3) Telemetry data frame:

(1) Example 1

(2) Example 2

68 12 02 00 00 00 00 0D 01 03 00 01 00 01 40 00 00 00 DC 43 00 Description: 68: Start address 12: Total byte length 02: send sequence number +2 00 00: receive sequence number 0D: Communication standard 01: Number of requests sent 03: Request cause (abrupt) DC 43: attribute valueCopy the code

(3) Instance 3 byte array transfer mode:

ByteArray = ByteUtil. GetByteArray ((float) float.valueof (utfRes)); resultBytes[0] = 0x68; // Header resultBytes[1] = 0x12; ResultBytes [2] =(byte) (0x00+temp); // resultBytes[2] =(byte) (0x00+temp); temp+=2; resultBytes[3] = 0x00; resultBytes[4] = 0x00; resultBytes[5] = 0x00; resultBytes[6] = 0x0D; ResultBytes [7] = 0x01; ResultBytes [8] = 0x03; ResultBytes [9] = 0x00; resultBytes[10] = 0x01; resultBytes[11] = 0x00; ResultBytes [12] = (byte) (0x01+ I); resultBytes[12] = (byte) (0x01+ I); resultBytes[13] = 0x40; resultBytes[14] = 0x00; add=i; ResultBytes [15] = byteArray[3]; resultBytes[15] = byteArray[3]; resultBytes[16] = byteArray[2]; resultBytes[17] = byteArray[1]; resultBytes[18] = byteArray[0]; resultBytes[19] = 0x00;Copy the code

4) Call full data activation end frame:

Example 2. Data mutation is used to upload packets

Reception: 68 42 AA 53 5E 03 0D 07 03 00 01 00 01 40 00 DC F9 BE 3F 00 02 40 00 94 18 C4 3F 00 03 40 00 6F 12 C3 3F 00 04 40 00 D7 A3 CE 42 00 07 40 00 29 DC 86 43 00 08 40 00 99 99 59 C1 00 09 40 00 8F C2 C7 42 00

1. Data frames uploaded by mutation, discontinuous data of telemetry type.

Examples of three,

Send: 68 0E 60 03 BC 53 65 01 06 01 01 00 00 00 00 00 45

Reception: 68 0E BC 53 62 03 65 01 07 00 01 00 00 00 00 45 68 21 BE 53 62 03 0F 84 25 00 01 00 01 64 00 B8 04 00 00 00 10 00 00 00 01 47 00 00 00 02 05 00 00 00 03 68 0E C0 53 62 03 65 01 0A 00 01 00 00 00 00 45

1. Send a message: Call the electrical activation frame

2. Received message: including the call electricty activation confirmation frame, the call electricty data frame, and the call electricty activation end frame

1) Call power activation confirmation frame:

2) Electricity data frame:

3) Call power activation end frame

Four, the last

Thanks to other bloggers for providing ideas, I am just standing on the shoulders of giants to carry them!!