A kind of sending control method of communication protocol test
Technical field
The present invention relates to a kind of sending control methods of communication protocol test, belong to communication interface and its protocol test neck
Domain.
Background technique
With development communication technologies, the test of various communication interfaces and its agreement is the one of technological development and the examination and test of products
A necessary links.Current existing communication interface and its protocol test, can only provide artificial evaluation, be accomplished manually conversion number
According to, the function that triggers after a plurality of data frame, timing cycle, receiving frame exact matching is manually set, do not provide more easily from
Dynamicization protocol test function.Chinese invention patent " communication protocol interface test method and system (application number:
CN201110279981.4 a kind of communication protocol test method) is described, as shown in Figure 1.The communication protocol test method is based on
The function of test script module invocation protocol test library, simulant-client behavior, and test data are sent to measurand, lead to
It is received back complex data with logical services simulator, the test script module is transferred to and is verified.The communication protocol test side
The selection to sent out data may be implemented by test script and protocol test library in the transmitting portion of method, but the test macro is not
Comprising to test send data-frame times, circulation, triggering control, can only realize communication data generate, send, be only used for testing
Card send data and according to test protocol library generate reception data consistency, can not adapt to data protocol because device characteristics,
Interface features are different and different situations, are unable to complete the autorun of complicated, prolonged, continuous change condition.
Increasingly sophisticated with serial communication protocol, existing serial ports computer debugging tool is no longer satisfied debugging and needs
It wants.Existing serial ports computer debugging tool is typically only capable to complete simple serial ports transmitting-receiving control and cycles through function.However,
Currently to the test of serial communication reliability, it is also necessary to retransmit after sending delay, waiting reply to serial ports, modify automatically
Frame data are sent, check code calculating is automatically performed and fills in.For this purpose, proposing that serial port protocol sends the new demand of test software.
Summary of the invention
The purpose of the present invention is to propose to a kind of sending control method of communication protocol test, the hair of designed test input
Send data text, in addition to comprising send data, also comprising label, variable, data calculate and transfer function, send control function with
And function is arranged in test parameter, to realize that test condition changes automatically during communication test, realizes automaticdata variation
Agreement framing afterwards realizes that convenient and fast data calculate and format conversion, realize it is more flexible cycle through and conditional jump, realize
According to the automatic answer function for receiving data.
The present invention provides a kind of sending control method of communication protocol test, this method packet to solve above-mentioned technical problem
Containing following steps:
Step 1 carries out text resolution processing to the transmission data text of communication protocol test, decomposites and sends data, mark
Number, variable, data calculate and transfer function, send control function and test parameter function is arranged;
Step 2, transmission control processing and receive the provided transmission control function of text resolution processing, are ready to carry out including following
Ring and the transmission jumped including control, time trigger control and condition triggering control control;Test parameter is arranged function and handles
Provided test parameter is handled according to text resolution, and function, the parameter that setting communication protocol is tested are set;
Step 3, in the case where recycling and jumping control, send that data, label, variable and data calculate and transfer function input
It is calculated to data and conversion process, acquisition data calculates and the processing result of transfer function and the current value of variable;
Step 4, transmission data, the current value of variable and data calculate and the processing result of transfer function is input to hair
It send data generation to handle, generates outgoing data;
Step 5, transmission data generate outgoing data caused by processing and are saved by caching process;
Step 6, when time trigger control and condition triggering control trigger condition meet when, data sending processing will cache
Outgoing data from communication transmission interface send.
Wherein, the parameter of communication protocol test includes that the setting to communication transmission interface and communications reception interface is joined
Number.
Further, the parameter of communication protocol test includes the setting parameter to test environment.
Further, the parameter of communication protocol test includes processing, statistics, the measurement to data are sended and received
With the setting parameter of display.
Further, time trigger control is controlled comprising Time-delayed trigger.
Further, time trigger control is controlled comprising clocked flip.
Further, the reception number that condition triggering control is obtained according to reception data processing from communications reception interface
According to generating trigger condition by receiving data characteristics judgement, data sending processing controlled when trigger condition meets by outgoing data
It is sent from communication transmission interface.
Further, the step 1 to step 6 can recycle, and the text resolution of step 1 handles foundation in each cycle
It sends control function and dissection process only is carried out to partial content in transmission data text.
The functional block diagram of communication protocol proposed by the invention test sending control method as shown in Fig. 2, this method it is beneficial
Place is by, comprising symbol definitions such as variable and functions, more flexible test control may be implemented in sending data text
System.Specifically, sending, the label in data text, variable, data calculate and transfer function, are surveying to realize and send data
Automatic calculating and convenient generation during examination.Function is arranged in the test parameter sent in data text, can be used for testing
The parameter characteristics such as speed of dynamic adjustment communication interface in the process change test total environment according to different test requests.Test
Parameter setting function can also carry out further data analysis to sending data and receiving data, such as: it extracts and receives data
Middle particular piece of data is simultaneously converted to the corresponding numerical value of actual physical meaning and is shown;Success rate is communicated in statistical test procedures;
Sending and receiving data is changed in the display content and form of display window;Test post is exported in display window.
Control function is sent for implementing more flexible control to the data transmission procedure that communication protocol is tested, to simplify certainly
Dynamic test process, provides richer test function.Since data transmission procedure includes that data calculate and conversion process, transmission number
According to generation processing, outgoing data caching process and final data sending processing.The transmission that the present invention is implemented controls
Two controlling units.One controlling unit is for the circulation for sending data generation and to jump control, another controlling unit is
The time trigger control and condition triggering control that outgoing data starting is sent in control caching.Send the setting of control mode still
It is to be described by sending the functional form in data text.Test process can be significantly facilitated by recycling and jump control function
Description, such as: the communication target address by generating variation with variable in the circulating cycle, the data that multiple target may be implemented are sent
Test;By being jumped according to different condition, the self-adaptive processing to different test cases may be implemented.Time trigger control
Function is also extremely important to communication test.It may be implemented by time trigger control to the communication equipment response time, reply
Handle the measurement of the time parameters such as time.In the present invention, time trigger includes Time-delayed trigger and clocked flip two types.Condition
Triggering control then sends control for realizing more flexible communication protocol, for example sends reply data, simulation according to data are received
Fault data sends test, analogue communication conflict test.Condition triggering control can also be cancelled according to condition to be sent, and passes through knot
It closes circulation and jumps control and realize the recombination for sending data.
Detailed description of the invention
Fig. 1 is a kind of functional block diagram of the test method of existing communication protocol interface.
Fig. 2 is a kind of functional block diagram of the sending control method of communication protocol test proposed by the present invention.
Specific embodiment
The application background of a specific embodiment of the invention is the serial data based on serial ports of computers to electrical equipment
Interface carries out communication protocol test.Basic transmission data format employed in the transmission data text of communication protocol test is
By space-separated, in the form of 16 system byte data strings, defaulting serial transmission sequence is low byte preceding.For example, when sending
Character string be " ABCDEF " when, corresponding transmission data text are as follows: 41 42 43 44 45 46.
The embodiment of the present invention identifies label or variable by prefix " # " in sending data text, is identified by prefix " $ "
Function.The difference of the format of label or name variable be data after name variable in bracket with variable assignments, character string,
The formula expression calculated comprising common numerical operation function, string operations function and check code.Such as: #lable_
Name corresponds to label definition, the entitled lable_name of label;#var1 (1.5) correspondence variable-definition, name variable var1,
Its numerical value is 1.5;#var2 (" ABCD ") defined variable var2, initial assignment are character string " ABCD ";#var3 (k1:s:k2) is fixed
Adopted variable var3 is from k1 to k2, and step-length is the array of s;#var4 (max (x, y)+1.5) defined variable var4, numerical value etc.
In the result of expression formula (max (x, y)+1.5).
The embodiment of the present invention includes: from label sending the data in data text and calculating with transfer functionl 1To labell 2
Byte length calculate function $ LEN (k, XF, l 1, l 2), whereinkFor byte number shared by length data, XF is for being arranged
Communication low byte is sent in preceding (LF) or high byte at preceding (HF), and XF is defined identical in subsequent function;From labell 1To labell 2's
Check code calculating function $ CHECK (type, l 1, l 2), whereintypeCorresponding checking algorithm type;By character stringstr_hexMake
For 16 systems indicate send data type conversion function $ BYTE (str_hex);By dataxIt is converted intokByte is whole without symbol
Number, signed integer, single precision floating datum, double-precision floating points data type conversion function $ NUM (k, XF, x)、$INT
(k, XF, x)、$FLOAT(LF/HF, x) and $ DOUBLE (LF/HF,x);MonocasexBe converted to the data of 1 transmission byte
Type trans form function $ CHAR (x);Character stringxBeing converted to length iskThe data type conversion function $ of the transmission data of byte
STRING(k, XF, x)。
The embodiment of the present invention includes recycling and jumping control function, time sending the transmission control function in data text
It triggers control function and condition triggers function.Wherein, recycling and jump control function includes: to skip to label from current locationl 1Cyclical function $ LOOP that the byte location at place cycles through (l 1);Cycling jump function $ WHILE (x1, CMP, x2,l 1), i.e., if inputx1 Hex2 meet according to the CMP manner of comparison Rule of judgment specified, then skip to label from current locationl 1Institute
Byte location circulation hair execute;Or jump directly to labell 1The byte location at place directly jumps function $ JMP
(l 1).Time trigger control function include: Time-delayed trigger control function $ DELAY (time), send control sent the function it
After preceding data, it will be delayedtimeIt is further continued for sending after the set time;Regularly send control function $ WTTST (str_test_ time), arrival will be waited by sending controlstr_test_timeThe testing time of setting, subsequent supervention was sent.Condition triggers function packet
It includes: waiting to be comparedx1 Hex2, which meet subsequent supervention according to the CMP manner of comparison Rule of judgment specified, send or stops the condition sending
Transmission function $ TILL (x1, CMP, x2) and condition stop function $ STOP (x1, CMP, x2);Serial ports is waited to have reception number
According to rear delaytimeAgain triggering following send control function $ WRXQ (time);Serial ports is waited to have receptionkA byte data is touched again
Send out transmission subsequent control function $ WRXN (k);Waiting serial ports, which receives, includesstr_hexSpecified data again send out by triggering following
Send control function $ WRXS (str_hex)。
The embodiment of the present invention includes three classes in the test parameter setting function sent in data text.First kind test parameter
It includes serial port setting function $ COMSET (...) that function, which is arranged, can be used for selecting serial port, setting baud rate, byte bit long
It spends, stop position is various, verification mode.Second class testing parameter setting function is for being arranged test environment parameter, such as test mark
Topic setting function $ TEST_TITLE (str_title) (str_titleFor input character string), send and receive byte counter
Reset function $ CLR_BYTE_COUNTER (), setting testing time function $ SET_TEST_TIME (h1, m1, s1) (h1,m1, s1Respectively correspond setting when, minute, second numerical value), the $ such as maximum delay setting function between the reception byte of complete receiving frame
SET_RX_FM_GAP(v1) (v1For millisecond time-delay numerical value).Third class testing parameter setting function is used for sending and receiving number
According to processing, statistics, measurement and display, such as: return recently send frame and frames received evidence function $ TXFRAME () and $
RXFRAME (), statistics send byte quantity and receive the function $ TX_BYTE_NUM () and $ RX_BYTE_NUM of byte quantity
The previous transmission frame of (), measurement completes the last byte and is sent to the time interval for receiving the first character section for replying frame
Function $ TXRXGAP (), test result display pattern setting function $ SET_DISPMOD (str_m1,val1) (str_m1For
Display pattern attribute,val1For display pattern, numerical value is set) and reception window printout report function REPORT (str_ format,#a1,#a2...) (str_formatFor report output format,a1、a2Forstr_formatVariable ginseng in character string
Number numerical value) etc..
Text resolution of the embodiment of the present invention in processing step 1 is handled according to above-mentioned transmission data, label, variable and letter
Several format definition decomposites and sends data, label, variable, data calculating and transfer function, sends control function and survey
Try parameter setting function.
In step 2, it sends control processing and sends control function according to provided by text resolution processing, executing includes following
Ring and the transmission jumped including control, time trigger control and condition triggering control control;Test parameter is arranged function and handles
Provided test parameter is handled according to text resolution, and function, the parameter that setting communication protocol is tested are set.
In step 3, in the case where recycling and jumping control, data, label, variable and data is sent and calculate and convert letter
Number is input to data calculating and conversion process, obtains data and calculates and the output result of transfer function and the current number of variable
Value.
In step 4, the output result for sending data, the current value of variable and data calculating and transfer function is defeated
Enter to data generation processing is sent, generates outgoing data.
In steps of 5, outgoing data caused by data generation processing is sent to be saved by caching process.
In step 6, when the trigger condition of time trigger control and condition triggering control meets, data sending processing will
The outgoing data of caching is sent from communication transmission interface.
When the embodiment of the present invention is applied to the test of computer based serial communication protocol, transmission number is write by test man
According to text, neatly test process can be controlled, to realize to protocol conformance, call duration time parameter measurement, lead to
The statistics of performances such as letter success rate flexibly control display window, provide test function abundant, convenient for examining communication equipment string
The performance indicator of mouth.