A kind of sending control method of communication protocol test
Technical field
The present invention relates to the sending control method of a kind of communication protocol test, belong to communication interface and protocol test field thereof.
Background technology
Along with development communication technologies, the test of various communication interface and agreement thereof is a necessary links of technological development and the examination and test of products.Current existing communication interface and protocol test thereof, artificial evaluation can only be provided, manually complete translation data, manually the function that many Frames, timing cycle, received frame mate rear triggering is completely set, automation protocol test function more easily is not provided." method of testing of communication protocol interface and system (application number: CN201110279981.4) describe a kind of communication protocol method of testing to Chinese invention patent, as shown in Figure 1.This communication protocol method of testing is based on the function of test script module invocation protocol test library, simulant-client behavior, and sending test data to measurand, generic logic service simulator receives replys data, is transferred to described test script module and verifies.The transmitting portion of this communication protocol method of testing, the selection to sent out data can be realized by test script and protocol test storehouse, but this test macro does not comprise control test being sent to data-frame times, circulation, triggering, communication data can only be realized produce, send, can only be used for verifying the consistency sending data and the reception data according to the generation of test protocol storehouse, data protocol cannot be adapted to because of the different and different situation of device characteristics, interface features, cannot complete complicated, for a long time, the autorun of continuous change condition.
Increasingly sophisticated along with serial communication protocol, existing serial ports computer debugging acid can not meet debugging needs.Existing serial ports computer debugging acid usually can only complete the transmitting-receiving of simple serial ports and control and circulation sending function.But the current test to serial communication reliability, also needs to send delay to serial ports, wait sends after replying again, automatically revises transmission frame data, automatically complete check code calculating and fill in.For this reason, the new demand that serial port protocol sends testing software is proposed.
Summary of the invention
The object of the invention is the sending control method proposing the test of a kind of communication protocol, the transmission data text of designed test input, except comprising transmission data, also comprise label, variable, data calculate and transfer function, transmission control function and test parameter arrange function, thus realize test condition and automatically change in communication test process, realize the agreement framing after automaticdata change, realize data easily to calculate and format conversion, realizing circulation more flexibly to send and conditional jump, realizing the automatic answer function according to receiving data.
The present invention is for solving the problems of the technologies described above and providing the sending control method that a kind of communication protocol is tested, and the method comprises following steps:
Step 1, to communication protocol test transmission data text carry out text resolution process, decomposite send data, label, variable, data calculate and transfer function, transmission control function and test parameter function is set;
Step 2, send control treatment and receive the transmission control function that text resolution process provides, prepare to perform and comprise circulation and redirect control, time triggered control and the transmission control of condition trigging control; The test parameter that test parameter arranges function process to be provided according to text resolution process arranges function, arranges the parameter of communication protocol test;
Step 3, under circulation and redirect control, send data, label, variable and data and to calculate and transfer function is input to data and calculates and conversion process, obtain data and calculate and the result of transfer function and the current value of variable;
The current value of step 4, transmission data, variable and the result of data calculating and transfer function are input to and send data genaration process, produce outgoing data;
The outgoing data that step 5, the process of transmission data genaration produce is saved through caching process;
Step 6, when the trigger condition of time trigging control and condition trigging control meets, the outgoing data of buffer memory sends from communication transmission interface by data sending processing.
Wherein, the parameter of described communication protocol test comprises the parameters to communication transmission interface and communications reception interface.
Further, the parameter of described communication protocol test comprises the parameters to test environment.
Further, the parameter of described communication protocol test comprises the parameters to the process receiving and send data, statistics, measurement and display.
Further, described time triggered controls to comprise Time-delayed trigger and controls.
Further, described time triggered controls to comprise clocked flip and controls.
Further, the reception data that described condition trigging control obtains from communications reception interface according to reception data processing, judging to produce trigger condition through receiving data characteristics, controlling data sending processing when trigger condition meets and outgoing data is sent from communication transmission interface.
Further, described step 1 can circulate to step 6, and in each circulation, the text resolution process of step 1 only carries out dissection process to partial content in transmission data text according to sending control function.
As shown in Figure 2, the usefulness of the method is, by comprising the symbol definitions such as variable sum functions in transmission data text, can realize testing and control more flexibly the theory diagram of communication protocol test sending control method proposed by the invention.Specifically, send the label in data text, variable, data calculate and transfer function, thus realize sending the automatic calculating of data in test process and convenient generation.The test parameter sent in data text arranges function, may be used for the parameter characteristics such as the speed of dynamic conditioning communication interface in test process, according to different test request change test total environment.Test parameter arranges function can also carry out further data analysis to transmission data and reception data, such as: extraction receives particular piece of data in data and the numerical value being converted to actual physics meaning corresponding shows; Communicate in statistical test procedures success rate; Change transceiving data in the displaying contents of display window and form; Test post is exported at display window.
Send control function to be used for implementing to control more flexibly to the data transmission procedure of communication protocol test, to simplify automatic testing process, provide abundanter test function.Calculate and conversion process, the process of transmission data genaration, outgoing data caching process and final data sending processing because data transmission procedure comprises data.The transmission that the present invention implements controls to comprise two controlling units.A controlling unit controls for the circulation and redirect that send data genaration, and another controlling unit controls the time triggered that in buffer memory, outgoing data startup sends to control and condition trigging control.The setting sending control mode is remained and is described by the functional form sent in data text.Circulation and redirect control function can facilitate the description of test process greatly, such as: by the circulating cycle with the communication target address that variable changes, can realize multiobject data and send test; By carrying out redirect according to different condition, the self-adaptive processing to different test case can be realized.Time triggered controlling functions is also extremely important to communication test.Control can realize communication equipment response time, the measurement of replying processing time equal time parameter by time triggered.In the present invention, time triggered comprises Time-delayed trigger and clocked flip two type.Condition trigging control then controls for realizing communication protocol transmission more flexibly, such as sends reply data, simulated failure data transmission test, analog communication conflict test according to receiving data.Condition trigging control also can cancel transmission according to condition, and sends the restructuring of data by combination circulation and redirect control realization.
Accompanying drawing explanation
Fig. 1 is the theory diagram of the method for testing of existing a kind of communication protocol interface.
Fig. 2 is the theory diagram of the sending control method of a kind of communication protocol test that the present invention proposes.
Embodiment
The application background of a specific embodiment of the present invention carries out communication protocol test based on serial ports of computers to the serial data interface of electric equipment.The basic transmission data format adopted in the transmission data text of communication protocol test is with the form of space-separated, 16 system byte data strings, and acquiescence serial sending order is that low byte is front.Such as, when the character string sent is " ABCDEF ", the transmission data text of its correspondence is: 41 42 43 44 45 46.
The embodiment of the present invention passes through prefix " # " identification label or variable, by prefix " $ " recognition function in transmission data text.The form difference of label or name variable has the data of variable assignments, character string, comprises the formula expression that common numerical operation function, string operations function and check code calculate in bracket after being name variable.Such as: the corresponding label definition of #lable_name, label name is called lable_name; #var1 (1.5) corresponding variable-definition, name variable is var1, and its numerical value is 1.5; #var2 (" ABCD ") defined variable var2, initial assignment is character string " ABCD "; #var3 (k1:s:k2) defined variable var3 is from k1 to k2, and step-length is the array of s; #var4 (max (x, y)+1.5) defined variable var4, its numerical value equals the result of expression formula (max (x, y)+1.5).
The data of the embodiment of the present invention in transmission data text calculate and transfer function comprises: from label
l 1to label
l 2byte length computing function $ LEN (
k, XF,
l 1,
l 2), wherein
kbyte number shared by length data, XF is used for arranging communication low byte and sends at front (HF) at front (LF) or high byte, and in follow-up function, XF definition is identical; From label
l 1to label
l 2check code computing function $ CHECK (
type,
l 1,
l 2), wherein
typecorresponding checking algorithm type; By character string
str_hexas 16 systems represent transmission data type conversion function $ BYTE (
str_hex); By data
xbe converted into
kthe data type conversion function $ NUM of byte signless integer, signed integer, single precision floating datum, double-precision floating points (
k, XF,
x), $ INT (
k, XF,
x), $ FLOAT (LF/HF,
x) and $ DOUBLE (LF/HF,
x); Monocase
xbe converted to 1 send byte data type conversion function $ CHAR (
x); Character string
xbeing converted to length is
kthe data type conversion function $ STRING of the transmission data of byte (
k, XF,
x).
The transmission control function of the embodiment of the present invention in transmission data text comprises circulation and redirect control function, time triggered control function and condition trigger function.Wherein, circulation and redirect control function comprise: skip to label from current location
l 1place byte location circulation send cyclical function $ LOOP (
l 1); Cycling jump function $ WHILE (
x1, CMP,
x2,
l 1), if namely inputted
x1 He
xthe manner of comparison Rule of judgment that 2 foundation CMP specify meets, then skip to label from current location
l 1the byte location circulation at place is sent out and is performed; Or directly jump to label
l 1the direct redirect function $ JMP of the byte location at place (
l 1).Time triggered control function comprises: Time-delayed trigger control function $ DELAY (
time), send before control sends this function after data, by time delay
timecontinue again after the set time to send; Timed sending control function $ WTTST (
str_test_time), send and control wait to arrive
str_test_timethe testing time follow-up supervention of setting send.Condition trigger function comprises: wait to be compared
x1 He
xthe 2 manner of comparison Rule of judgment of specifying according to CMP meet follow-up supervention give or stop the condition sending send function $ TILL (
x1, CMP,
x2) and condition stop function $ STOP (
x1, CMP,
x2); Wait for that serial ports has and receive time delay after data
timeagain triggering following send control function $ WRXQ (
time); Wait for that serial ports has reception
kindividual byte data again triggering following send control function $ WRXN (
k); Wait for that serial ports receives to comprise
str_hexthe data of specifying again triggering following send control function $ WRXS (
str_hex).
The test parameter of the embodiment of the present invention in transmission data text arranges function and comprises three classes.First kind test parameter arrange function comprise serial port setting function $ COMSET (...), may be used for selecting serial ports number, baud rate is set, byte bit length, position of rest are various, verification mode.Equations of The Second Kind test parameter arranges function for arranging test environment parameter, such as test title arrange function $ TEST_TITLE (
str_title) (
str_titlefor input of character string), send and receive byte counter reset function $ CLR_BYTE_COUNTER (), arrange testing time function $ SET_TEST_TIME (
h1,
m1,
s1) (
h1,
m1,
s1respectively corresponding arrange time, minute, second numerical value), between the reception byte of complete received frame maximum delay arrange the $ SET_RX_FM_GAP such as function (
v1) (
v1for millisecond time-delay numerical value).3rd class testing optimum configurations function is used for receiving and sending the process of data, statistics, measurement and display, such as: return the function TXFRAME () of nearest transmission frame and frames received certificate and RXFRAME (), statistics send byte quantity and receive the function TX_BYTE_NUM () of byte quantity and RX_BYTE_NUM (), measure last transmission frame complete last byte be sent to the function TXRXGAP () in the time interval that the first character that receives reply frame saves, test result display mode arrange function SET_DISPMOD (
str_m1, val1) (
str_m1for display mode attribute,
val1for display mode arranges numerical value) and receive window printout reporting function $ REPORT (
str_format, #
a1, #
a2) (
str_formatfor report output form,
a1,
a2for
str_formatvariable parameter numerical value in character string) etc.
The text resolution process of the embodiment of the present invention in treatment step 1, according to the formal definition of above-mentioned transmission data, label, variable sum functions, decomposites and sends data, label, variable, data calculate and transfer function, transmission control function and test parameter arrange function.
In step 2, send the transmission control function that control treatment provides according to text resolution process, execution comprises circulation and redirect control, time triggered control and the transmission of condition trigging control controls; The test parameter that test parameter arranges function process to be provided according to text resolution process arranges function, arranges the parameter of communication protocol test.
In step 3, under circulation and redirect control, send data, label, variable and data and to calculate and transfer function is input to data and calculates and conversion process, obtain data calculating and the Output rusults of transfer function and the current value of variable.
In step 4, send data, the current value of variable and the Output rusults of data calculating and transfer function and be input to the process of transmission data genaration, produce outgoing data.
In steps of 5, the outgoing data that the process of transmission data genaration produces is saved through caching process.
In step 6, when the trigger condition of time trigging control and condition trigging control meets, the outgoing data of buffer memory sends from communication transmission interface by data sending processing.
When the embodiment of the present invention is applied to the test of computer based serial communication protocol, transmission data text is write by test man, can control test process neatly, thus realize statistics to protocol conformance, call duration time parameter measurement, performance such as communication success rate etc., control display window flexibly, provide abundant test function, be convenient to the performance index checking communication equipment serial ports.