1 introduction

DL/T645 Multi-function Watt-hour Meter Communication Protocol is a physical connection and protocol used to unify and standardize multi-function watt-hour meters for data exchange with data terminals. This paper will be based on DL/T645-2007 multifunctional watt-hour meter communication protocol, introduce how to use Gushi Beacon communication test software to write test items, test multifunctional watt-hour meter.

2 Communication Protocol

2.1 the term

The watt-hour meter is composed of a measuring unit and a data processing unit. In addition to measuring active/reactive electricity energy, it also has two or more functions, such as time-sharing and measuring demand, and can display, store and output data.

2.2 Communication Interface

Communication parameters adopt 8 data bits, 1 stop bit and 1 parity bit. Support infrared port, default rate 2400bps; Support rs-485 standard serial electrical interface, support multi-point connection, standard rate of 600bps, 1200bps, 2400bps, 4800bps, 9600bps, 19200bps.

2.3 Data Link Layer

The DL/T645-2007 protocol is a half-duplex communication mode in the master-slave structure. The handheld unit or other data terminal is the master station and the multifunctional watt-hour meter is the slave station. Each multifunctional watt-hour meter has its own address code. The establishment and disconnection of communication links are controlled by the information frames sent out by the master station. Each frame consists of seven domains: frame start character, address domain of slave station, control code, data field length, data field, longitudinal verification code of frame information and frame end character. Each part consists of several bytes.

2.3.1 frame format

Frames are the basic unit for transmitting information. The following figure shows the frame format.

2.3.2 Transmission Mode

Leading bytes: Four leading bytes FEH are sent to wake up the receiver before the master station sends the frame information. Transmission order: all data items are transmitted first low byte, then high byte, the sender by byte to add 33H processing, the receiver by byte to subtract 33H processing. An example of data transmission: the value of power is 123456.78kwh, and the sequence of transmission is shown in the figure.

2.4 the application layer

DL/T645-2007 protocol application layer defines the read data, subsequent data read and write data, read when the communication address, written communication, radio school, freeze command, change the communication rate, change passwords, maximum demand reset, electric meter reset, reset, jump switch, alarm events, electrical, multi-function terminal output control Settings, such as security authentication command. For details, see DL/T645-2007.

3 test project preparation

3.1 Basic protocol preparation

3.1.1 Protocol Classification

Using the protocol incentive function of gusi debugging Sprite software, the DL/T 645-2007 communication protocol is classified and organized according to the tree structure, which makes the management more organized and the search more convenient. First of all, according to DL/T 645-2007 communication protocol data identification code table of appendix A classification, establish read electric energy data, the maximum demand and time data, read variable data, the event log data, reading data, writing parameter depending on A parameter data, record read frozen data, load data and control command set nine basic agreement. Then, according to the number of protocols in the basic protocol set, the small molecule protocol set is continued. For example, the basic protocol set contains too many protocols, so it can be further divided into several sub-protocol sets, such as reading the current electricity energy data, reading the 1 settlement energy data and so on, to achieve the purpose of effective management.

3.1.2 Agreement preparation

According to the protocol frame format, to facilitate control and display, the data of a protocol item is divided into eight parts: frame start character, address, frame start character, control code, data length, data id, verification code, and frame end character. The part that is dynamically increased or decreased is the data field, which can be further split according to specific commands. The following uses the “read total combined active power energy” command as an example to describe how to compile protocols.

The master requests frames

Slave station normal response frame

Slave exception reply frame

3.1.3 Common Protocol Library

Through the compilation, testing and verification of basic protocols, a common protocol library composed of basic protocols is established.

3.2 Compilation of test cases

A Test Case is a set of Test inputs, execution conditions, and expected results compiled for a specific purpose to Test a program path or verify that a specific requirement is met. Communication protocol testing belongs to black box testing, and the basic methods commonly used in black box testing such as equivalence class division method, boundary value analysis method, error inference method, cause-and-effect diagram method and so on can be used to design test cases.

After the completion of the test scheme design, The Software can use the preparation of the completion of the common protocol library, using building blocks, by copying and pasting commands can be very fast to create test cases. Test cases are usually organized in a tree structure according to the design hierarchy of the test scheme.

4 Test Methods

4.1 Test system composition

4.2 Individual test and overall test

Guessy debug Sprite software supports individual and collective testing, one test item at a time or the entire test suite. To do this, select the test item or test set that you want to test, and then execute the incentive command. The following uses the Read total combined active power as an example.

Protocol data parsing interface

Protocol incentive reporting interface

4.3 Single test and cycle test

Gesi debugging wizard software support single test and loop test, can well meet the needs of various debugging testing and performance testing. To do this, select the test item or test set that you want to test, and then execute the drive or loop drive command.

4.4 Fault Injection Test

Gesi debug wizard software support direct incentive and protocol incentive run at the same time, can well meet the needs of a variety of exception testing and fault injection testing. The method of implementation is to open a direct excitation project and run it as a fault information generator, and then execute the protocol excitation test to test whether the normal protocol commands can be executed correctly when there is illegal information injected into the electricity meter under test.

4.5 Script control tests

Gesi debugging wizard software support protocol script, can use C#, VB, Jscript three languages to control the test process, set and manage communication parameters and protocol frame data, call plug-in extension test function. For example, after the “Change communication Rate” command of DL/T645-2007 is executed, the communication rate of the electricity meter changes. If continuous testing is required, you must use the protocol script to change the baud rate of the communication interface in the OnRespond method.

Protocol scripts can call managed code components based on the Microsoft.net Framework for extended testing. Plugins are very convenient to use. By copying compiled components to the Plugins directory, you can call the common services provided by the plug-in directly in the functions of the script. For example, using the example plug-in ParallelPort, which includes the geshe.utils namespace, you can directly use the ParallelPort.read method.

Download the sample