Summary of the invention
The embodiment of the present invention provides a kind of simulative serial port method of testing and device, for the test of client, makes the exploitation debugging work of client can be supported at any time, promotes whole development progress.
A method of testing, comprising:
Receive the Modem commands language AT instruction that client sends;
Read and resolve each test data file prestoring, obtain the test instruction in test data file;
Confirm whether described test instruction is the result coded message URC instruction of active reporting, if, described URC instruction is sent to described client, if not, confirm whether described AT instruction is included in the test instruction in described test data file, if comprise, the response contents of the test instruction corresponding with described AT instruction is sent to described client, otherwise send the expression information that the match is successful to described client.
Alternatively, described in read and resolve each test data file prestoring, obtain the test instruction in test data file; Confirm whether described test instruction is the result coded message URC instruction of active reporting, if, described URC instruction is sent to described client, if not, confirm whether described AT instruction is included in the test instruction in described test data file, if comprise, the response contents of the test instruction corresponding with described AT instruction is sent to described client, otherwise send, represent that the information that the match is successful comprises to described client:
Read successively each test data file prestoring, and resolve and to obtain the test instruction in test data file, using described test instruction one by one as present node; Confirm whether present node is the result coded message URC instruction of active reporting, if so, described URC instruction is sent to described client, if not, described AT instruction is mated with present node; If it fails to match, send the expression information that the match is successful to described client, if the match is successful, will send to described client with the response contents of the described AT instruction present node that the match is successful; Or,
Read and resolve each test data file prestoring, obtain the test instruction in test data file, then store described test instruction; Whether the test instruction of confirming current memory point is the result coded message URC instruction of active reporting, if, described URC instruction is sent to described client, if not, confirm whether described AT instruction is included in the test instruction of described current memory point, if comprise, the response contents of the test instruction corresponding with described AT instruction is sent to described client, otherwise send the expression information that the match is successful to described client.
Preferably, carrying out: described URC instruction is sent to described client, the response contents with the described AT instruction present node that the match is successful is sent to described client, also comprises before the response contents with test instruction corresponding to described AT instruction is sent to any one in described client:
Delay according to the present node configuring requires to arrange and start timer, after timer overflows, described URC instruction is sent to described client, or, after overflowing, timer will send to described client with the response contents of the described AT instruction present node that the match is successful, or, after timer overflows, the response contents of the test instruction corresponding with described AT instruction is sent to described client.
Preferably, before after timer starts, timer overflows, if receive the interrupt requests from client, also comprise:
Stop timer timing, and use to interrupt success message replace the response contents of described and the described AT instruction present node that the match is successful or replace described in send to described client with the response contents of test instruction corresponding to described AT instruction.
Preferably, described test data file is expandable mark language XML file; Described method also comprises:
Accept the modification of text editor to XML file; Or, receive the XML file update information different from AT instruction encapsulation format, and according to described XML file update information, upgrade the preset XML file of its appointment.
Preferably, described method, also comprises:
Create two or more eavesdropping target, after client terminal start-up, with polling mode, search attachable client, and set up the corresponding relation between eavesdropping target and attachable client;
Describedly send to described client to comprise described URC instruction: to adopt broadcast mode to send to each client described URC instruction, by the client screening URC instruction corresponding with it;
The response contents of the test instruction that the response contents of the described expression information that the match is successful, the described and described AT instruction present node that the match is successful, described and described AT instruction are corresponding and interrupt success message, sends to corresponding client according to described corresponding relation.
A testing apparatus, comprising:
Communication controler, process controller, document parser, memory,
Communication controler, for receiving the Modem commands language AT instruction of client transmission and sending to process controller; The information from process controller receiving is sent to client;
Memory, for store test data file;
Document parser, for reading and resolve each test data file prestoring, obtains the test instruction in test data file;
Process controller, for confirming whether described test instruction is the result coded message URC instruction of active reporting, if, described URC instruction is sent to described communication controler, if not, confirm whether described AT instruction is included in the test instruction in described test data file, if comprise, the response contents of the test instruction corresponding with described AT instruction is sent to described communication controler, otherwise send the expression information that the match is successful to described communication controler.
Alternatively, described document parser, specifically for reading successively each test data file prestoring, and resolves and to obtain the test instruction in test data file, using described test instruction one by one as present node;
Described process controller, specifically for confirming whether present node is the result coded message URC instruction of active reporting, if so, described URC instruction is sent to described communication controler, if not, described AT instruction is mated with present node; If it fails to match, send the expression information that the match is successful to described communication controler, if the match is successful, will send to described communication controler with the response contents of the described AT instruction present node that the match is successful;
Or described document parser, specifically for reading and resolve each test data file prestoring, obtains the test instruction in test data file, then stores described test instruction;
Described process controller, specifically for confirming whether the test instruction of current memory point is the result coded message URC instruction of active reporting, if, described URC instruction is sent to described communication controler, if not, confirm whether described AT instruction is included in the test instruction of described current memory point, if comprise, the response contents of the test instruction corresponding with described AT instruction is sent to described communication controler, otherwise send the expression information that the match is successful to described communication controler.
Preferably, described process controller, also for carrying out: described URC instruction is sent to described communication controler, to send to described communication controler with the response contents of the described AT instruction present node that the match is successful, before the response contents of the test instruction corresponding with described AT instruction is sent to any one in described communication controler, delay according to the present node configuring requires to arrange and start timer, after timer overflows, described URC instruction is sent to described communication controler, or, after overflowing, timer will send to described communication controler with the response contents of the described AT instruction present node that the match is successful, or, after timer overflows, the response contents of the test instruction corresponding with described AT instruction is sent to described communication controler,
Described simulative serial port testing apparatus also comprises: timer, and for carrying out timing according to the indication of process controller.
Preferably, described communication controler, also for receiving the interrupt requests from client, and sends to process controller by interrupt requests;
Process controller, if also receive before overflowing for interrupt requests timer after timer starts, stop timer timing, and use to interrupt success message replace the response contents of described and the described AT instruction present node that the match is successful or replace described in send to described communication controler with the response contents of test instruction corresponding to described AT instruction.
Preferably, described test data file is expandable mark language XML file;
Described simulative serial port testing apparatus also comprises: text editor, for the XML file to memory, modify; Or,
The communication controler of described simulative serial port testing apparatus, also for receiving the XML file update information different from AT instruction encapsulation format from client, and sends to process controller by XML file update information;
Process controller, also for upgrading the preset XML file of its appointment according to described XML file update information.
Preferably, described communication controler comprises: broadcasting equipment, instruction retransmission apparatus, reply transmitter;
Instruction retransmission apparatus, for creating two or more eavesdropping target, after client terminal start-up, with polling mode, search attachable client, information from client is sent to process controller, and the described information from client comprises: at least one item in AT instruction, interrupt requests, XML file update information;
Process controller, specifically for URC instruction is sent to broadcasting equipment, message beyond URC is sent to and replys transmitter, and the message beyond described URC comprises: represent the response contents of the information that the match is successful, the test instruction corresponding with the response contents of the described AT instruction present node that the match is successful, described and described AT instruction, at least one item in interruption success message;
Reply transmitter, for setting up the corresponding relation between eavesdropping target and attachable client, and according to described corresponding relation, the message beyond the described URC receiving is sent to corresponding client;
Described broadcasting equipment, for adopting broadcast mode to send to each client the URC instruction receiving, by the client screening URC instruction corresponding with it.
As can be seen from the above technical solutions, the embodiment of the present invention has the following advantages: adopt the mode of artificial antenna network interface card to test client, can wait for that the exploitation of hardware or base-band software is complete also needn't rely on its support, therefore the exploitation of client can be debugged on stream in time with debugging, thereby improves whole development progress.
Embodiment
In order to make the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, the present invention is described in further detail, and obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making all other embodiment that obtain under creative work prerequisite, belong to the scope of protection of the invention.
The embodiment of the present invention provides a kind of simulative serial port method of testing, and as shown in Figures 2 and 3, the executive agent of the embodiment of the present invention is simulative serial port testing apparatus (simulator), comprising:
201: receive the Modem commands language AT instruction that client sends;
Be understandable that and carrying out before 201, need to be according to establishing a communications link with communication mode and the client of client agreement; Above communication mode possibility is a lot, and the embodiment of the present invention is preferably used flexible bus responder (D-Bus Method Reply) artificial antenna network interface card and client to communicate.
D-Bus is a kind of IPC(Inter-Process Communication, interprocess communication) mechanism.
D-BUS supports one to one the peer to peer communication with multi-to-multi.When man-to-man Direct Communication, two application programs link together.When the communication of multi-to-multi, this just needs one and cries D-BUS daemon(backstage) role go minute to turn; When an application program is sent out message to another one application program, message first arrives ,Zai You backstage, backstage information is sent to object application program.D-BUS serves as on backstage the role of router.D-Bus has the characteristic of avoiding back and forth transmission of information and allowing asynchronous operation.Although therefore realize communication by socket (socket) between application program (Application) and Daemon, removed the circular wait of socket, guaranteed the real-time high-efficiency of operation.D-Bus also provides the API(Application Programming Interface of packaging bottom layer special efficacy, application programming interface function) for analog communication.
202: read and resolve each test data file prestoring, obtain the test instruction in test data file;
Alternatively, above-mentioned 202 can be specifically: read successively each test data file prestoring, and resolve and to obtain the test instruction in test data file, using above-mentioned test instruction one by one as present node; Also can be to read and resolve each test data file prestoring, obtain the test instruction in test data file, then store above-mentioned test instruction; Mode as for storage can adopt the various forms such as chained list, array, and the embodiment of the present invention will not limit this.
Test data file is the file of store test data, in embodiments of the present invention can be with XML(extensible markup language, and, extend markup language) and file is that example describes.The concrete form of file of store test data can have a lot, for example, can be TXT file (Text File, text), database file etc., and the embodiment of the present invention is not restricted this.
It should be noted that, above-mentioned 201 and 202 do not have logic precedence each other, and therefore the numbering of above step should not be construed as in the time and/or has in logic the precedence of carrying out.
203: confirm whether above-mentioned test instruction is the result coded message URC instruction of active reporting, if, above-mentioned URC instruction is sent to above-mentioned client, if not, confirm whether above-mentioned AT instruction is included in the test instruction in above-mentioned test data file, if comprise, the response contents of the test instruction corresponding with above-mentioned AT instruction is sent to above-mentioned client, otherwise send the expression information that the match is successful to above-mentioned client.
Above-mentioned 203 specific implementation has following two kinds at least, is respectively:
Read successively each test data file prestoring, and resolve and to obtain the test instruction in test data file, using above-mentioned test instruction one by one as present node; Confirm whether present node is the result coded message URC instruction of active reporting, if so, above-mentioned URC instruction is sent to above-mentioned client, if not, above-mentioned AT instruction is mated with present node; If it fails to match, send the expression information that the match is successful to above-mentioned client, if the match is successful, will send to above-mentioned client with the response contents of the above-mentioned AT instruction present node that the match is successful;
Or, read and resolve each test data file prestoring, obtain the test instruction in test data file, then store above-mentioned test instruction; Whether the test instruction of confirming current memory point is the result coded message URC instruction of active reporting, if, above-mentioned URC instruction is sent to above-mentioned client, if not, confirm whether above-mentioned AT instruction is included in the test instruction of above-mentioned current memory point, if comprise, the response contents of the test instruction corresponding with above-mentioned AT instruction is sent to above-mentioned client, otherwise send the expression information that the match is successful to above-mentioned client.
The embodiment of the present invention adopts the mode of artificial antenna network interface card to test client, can wait for that the exploitation of hardware or base-band software is complete also needn't rely on its support, therefore the exploitation of client can be debugged on stream in time with debugging, thereby improves whole development progress.
Further, the embodiment of the present invention also provides the response of AT instruction and the implementation of timeout treatment, specific as follows: carrying out: above-mentioned URC instruction is sent to above-mentioned client, the response contents with the above-mentioned AT instruction present node that the match is successful is sent to above-mentioned client, also comprises before the response contents with test instruction corresponding to above-mentioned AT instruction is sent to any one in above-mentioned client:
Delay according to the present node configuring requires to arrange and start timer, after timer overflows, above-mentioned URC instruction is sent to above-mentioned client, or, after overflowing, timer will send to above-mentioned client with the response contents of the above-mentioned AT instruction present node that the match is successful, or, after timer overflows, the response contents of the test instruction corresponding with above-mentioned AT instruction is sent to above-mentioned client.
Further, the embodiment of the present invention also provides the response of AT instruction and Abort(to interrupt) implementation processed, specific as follows: before after timer starts, timer overflows, if receive the interrupt requests from client, also to comprise:
Stop timer timing, and use interruption success message replace the response contents of the above-mentioned and above-mentioned AT instruction present node that the match is successful or replace the response contents of test instruction corresponding to above-mentioned and above-mentioned AT instruction to send to above-mentioned client.
Introduction based on above embodiment, the file that the flow process control documents of AT can be based on XML form, the main keyword that it comprises can have a lot, below provided several for example:
Unknow: during (being also in the test instruction of XML file) do not match with the AT instruction receiving in the node of the test case of XML file AT response, respond this AT instruction (unknow).Adopt the advantage of above-mentioned keyword: because client may issue a lot of AT request, and, only need to be concerned about and the function of current operation can ignore other unconcerned AT request, and unknown designs for this reason during with exploitation as test.
Timeout: do not overflow the time (second) if define AT processing, return immediately.Protocol stack may can cause AT response timeout because of certain reason in actual use, the value of the timeout item in the embodiment of the present invention can be used for starting timer, after timer overflows, just the content of recv_hex (introducing) is sent to client below, thereby simulate the function of AT response timeout.
Type:AT instruction type.
Repeat:AT instruction repeats number of times, advantage: can be for pressure test.
Send_hex: the AT command content from client, can adopt hexadecimal representation mode, for mating customer end A T instruction.
The content of recv_hex:AT response instruction or URC (adopt hexadecimal representation mode), by the decision of type value (0:URC instruction, non-zero: non-URC instruction).
Further, the embodiment of the present invention also provides the implementation of XML file update, specific as follows: above-mentioned test data file is expandable mark language XML file; Said method also comprises:
Accept the modification of text editor to XML file; Or, receive the XML file update information different from AT instruction encapsulation format, and according to above-mentioned XML file update information, upgrade the preset XML file of its appointment.
More specifically, concrete form and the implementation thereof of XML when the embodiment of the present invention gives XML file update, when in use XML file needs modification, upgrading XML configuration file, can be used text editor directly to revise XML file; The present invention also supports client remote upgrade XML configuration file, virtual with USB in order to be designed to | serial ports, flexible bus irrelevant (using identical resolution unit with AT instruction), adopt the encapsulation format of self-defined AT instruction to pass to simulator the content of need upgrading, simulator AT receiving element is passing to XML upgrading unit in parsing to specifying the configuration file of numbering to rewrite.A plurality of XML files and update mode are identified by " No. " field.
The encapsulation format of the AT instruction of XML content, as shown in table 1 below:
Table 1
No.: the numbering (each XML filename comprises a unique numbering section) of configuration XML file.
F.C: function code.As the F.C=1 XML file that represents to upgrade.
Data: the content of renewal.
Further, the embodiment of the present invention gives and realizes a simulative serial port testing apparatus (simulator) and a plurality of clients and connect, for a plurality of clients provide the scheme of test, said method, also comprise: the eavesdropping target who creates two or more, after client terminal start-up, with polling mode, search attachable client, and set up the corresponding relation between eavesdropping target and attachable client;
Above-mentionedly send to above-mentioned client to comprise above-mentioned URC instruction: to adopt broadcast mode to send to each client above-mentioned URC instruction, by the client screening URC instruction corresponding with it;
The response contents of the test instruction that the response contents of the above-mentioned expression information that the match is successful, the above-mentioned and above-mentioned AT instruction present node that the match is successful, above-mentioned and above-mentioned AT instruction are corresponding and interrupt success message, sends to corresponding client according to above-mentioned corresponding relation.
If in the implementation procedure that above the present embodiment simulator and a plurality of client connect, adopt D-Bus to set up the communication connection between simulator and a plurality of client, the embodiment of the present invention can be utilized D-Bus mode to be extended to a simulator to connect a plurality of clients so, realizes a simulator and realizes the test to a plurality of different clients; Be beneficial to that D-Bus self-characteristic (support multi-point, broadcast) is realized a plurality of identical or different clients and simulator communicates.Simulator creates a plurality of monitorings (watch) object while starting, and when each client terminal start-up, with polling mode, removes to search attachable object.When simulator end is received client D-Bus Method(program for the first time) when request, can read XML file present node content corresponding to above-mentioned client, can also be preserved, identical with single client for the response subsequent treatment of AT instruction; And for the indication of URC type, simulator can adopt signal broadcast mode to send, by client signal filtration and screening as required.
The embodiment of the present invention also provides a kind of simulative serial port testing apparatus, as shown in Figure 4, comprising:
Communication controler 401, process controller 402, document parser 403, memory 404;
Communication controler 401, for sending to client by the information from process controller 402 receiving; Receive the Modem commands language AT instruction of client transmission and send to process controller 402;
Above communication mode possibility is a lot, and the embodiment of the present invention is preferably used flexible bus responder (D-Bus Method Reply) artificial antenna network interface card and client to communicate.D-Bus is a kind of IPC(Inter-Process Communication, interprocess communication) mechanism.D-BUS supports one to one the peer to peer communication with multi-to-multi.When man-to-man Direct Communication, two application programs link together.When the communication of multi-to-multi, this just needs one and cries D-BUS daemon(backstage) role go minute to turn; When an application program is sent out message to another one application program, message first arrives ,Zai You backstage, backstage information is sent to object application program.D-BUS serves as on backstage the role of router.D-Bus has the characteristic of avoiding back and forth transmission of information and allowing asynchronous operation.Although therefore realize communication by socket (socket) between application program (Application) and Daemon, removed the circular wait of socket, guaranteed the real-time high-efficiency of operation.D-Bus also provides the API(Application Programming Interface of packaging bottom layer special efficacy, application programming interface function) for analog communication.
Memory 404, for store test data file;
Test data file is the file of store test data, in embodiments of the present invention can be with XML(extensible markup language, and, extend markup language) and file is that example describes.Storage test number.
Document parser 403, for reading and resolve each test data file prestoring, obtains the test instruction in test data file;
Process controller 402, for confirming whether above-mentioned test instruction is the result coded message URC instruction of active reporting, if, above-mentioned URC instruction is sent to above-mentioned communication controler 401, if not, confirm whether above-mentioned AT instruction is included in the test instruction in above-mentioned test data file, if comprise, the response contents of the test instruction corresponding with above-mentioned AT instruction is sent to above-mentioned communication controler 401, otherwise send the expression information that the match is successful to above-mentioned communication controler 401.
Above embodiment, adopt the mode of artificial antenna network interface card to test client, can wait for that the exploitation of hardware or base-band software is complete also needn't rely on it and support, so the exploitation of client can be debugged on stream in time with debugging, thereby improves whole development progress.
Alternatively,
Above-mentioned document parser 403, specifically for reading successively each test data file prestoring, and resolves and to obtain the test instruction in test data file, using above-mentioned test instruction one by one as present node;
Above-mentioned process controller 402, specifically for confirming whether present node is the result coded message URC instruction of active reporting, if so, above-mentioned URC instruction is sent to above-mentioned communication controler 401, if not, above-mentioned AT instruction is mated with present node; If it fails to match, send the expression information that the match is successful to above-mentioned communication controler 401, if the match is successful, the response contents with the above-mentioned AT instruction present node that the match is successful is sent to above-mentioned communication controler 401;
Or above-mentioned document parser 403, specifically for reading and resolve each test data file prestoring, obtains the test instruction in test data file, then stores above-mentioned test instruction;
Above-mentioned process controller 402, specifically for confirming whether the test instruction of current memory point is the result coded message URC instruction of active reporting, if, above-mentioned URC instruction is sent to above-mentioned communication controler 401, if not, confirm whether above-mentioned AT instruction is included in the test instruction of above-mentioned current memory point, if comprise, the response contents of the test instruction corresponding with above-mentioned AT instruction is sent to above-mentioned communication controler 401, otherwise send the expression information that the match is successful to above-mentioned communication controler 401.
Further, as shown in Figure 5:
Above-mentioned process controller 402, also for carrying out: above-mentioned URC instruction is sent to above-mentioned communication controler 401, response contents with the above-mentioned AT instruction present node that the match is successful is sent to above-mentioned communication controler 401, before the response contents of the test instruction corresponding with above-mentioned AT instruction is sent to any one in above-mentioned communication controler 401, delay according to the present node configuring requires to arrange and start timer, after timer overflows, above-mentioned URC instruction is sent to above-mentioned communication controler 401, or, after timer overflows, the response contents with the above-mentioned AT instruction present node that the match is successful is sent to above-mentioned communication controler 401, or, after timer overflows, the response contents of the test instruction corresponding with above-mentioned AT instruction is sent to above-mentioned communication controler 401,
Above-mentioned simulative serial port testing apparatus also comprises: timer 501, and for carrying out timing according to the indication of process controller 402.
Further, above-mentioned communication controler 401, also for receiving the interrupt requests from client, and sends to process controller 402 by interrupt requests;
Process controller 402, if also receive before overflowing for interrupt requests timer 501 after timer 501 starts, stop timer 501 timing, and use interruption success message replace the response contents of the above-mentioned and above-mentioned AT instruction present node that the match is successful or replace the response contents of test instruction corresponding to above-mentioned and above-mentioned AT instruction to send to above-mentioned communication controler 401.
Introduction based on above embodiment, the file that the flow process control documents of AT can be based on XML form, the main keyword that it comprises can have a lot, below provided several for example:
Unknow: when the AT response that there is no coupling, the AT instruction of response.Adopt the advantage of above-mentioned keyword: because client may issue a lot of AT request, and, only need to be concerned about and the function of current operation can ignore other unconcerned AT request, and unknown designs for this reason during with exploitation as test.
Timeout: do not overflow the time (second) if define AT processing, return immediately.Protocol stack may can cause AT response timeout because of certain reason in actual use, the value of the timeout item in the embodiment of the present invention can be used for starting timer, after timer overflows, just the content of recv_hex (introducing) is sent to client below, thereby simulate the function of AT response timeout.
Type:AT instruction type.
Repeat:AT repeats number of times, advantage: can be for pressure test.
Send_hex: the AT content from client, can adopt hexadecimal representation mode, for mating customer end A T instruction.
The content of recv_hex:AT response or URC (adopting hexadecimal representation mode), determines that by type value (0:URC indicates, non-zero: non-URC instruction).
Further, as shown in Figure 6: above-mentioned test data file is expandable mark language XML file;
Above-mentioned simulative serial port testing apparatus also comprises: text editor 601, for the XML file to memory 404, modify; Or,
The communication controler 401 of above-mentioned simulative serial port testing apparatus, also for receiving the XML file update information different from AT instruction encapsulation format from client, and sends to process controller 402 by XML file update information;
Process controller 402, also for upgrading the preset XML file of its appointment according to above-mentioned XML file update information.
When in use XML file needs modification, upgrading XML configuration file, can use text editor directly to revise XML file; The present invention also supports client remote upgrade XML configuration file, in order to be designed to and interface USB| serial ports, flexible bus irrelevant (using identical resolution unit with AT instruction), adopt the encapsulation format of self-defined AT instruction to pass to simulator the content of need upgrading, simulator AT receiving element is passing to XML upgrading unit in parsing to specifying the configuration file of numbering to rewrite.A plurality of XML files and update mode are identified by " No. " field.Concrete form can be consulted table 1.
Preferably, as shown in Figure 7: above-mentioned communication controler 401 comprises: broadcasting equipment 701, instruction retransmission apparatus 702, reply transmitter 703;
Instruction retransmission apparatus 702, for creating two or more eavesdropping target, after client terminal start-up, with polling mode, search attachable client, information from client is sent to process controller 402, and the above-mentioned information from client comprises: at least one item in AT instruction, interrupt requests, XML file update information;
Process controller 402, specifically for URC instruction is sent to broadcasting equipment 701, message beyond URC is sent to and replys transmitter 703, and the message beyond above-mentioned URC comprises: represent the response contents of the information that the match is successful, the test instruction corresponding with the response contents of the above-mentioned AT instruction present node that the match is successful, above-mentioned and above-mentioned AT instruction, at least one item in interruption success message;
Reply transmitter 703, for setting up the corresponding relation between eavesdropping target and attachable client, and according to above-mentioned corresponding relation, the message beyond the above-mentioned URC receiving is sent to corresponding client;
Above-mentioned broadcasting equipment 701, for adopting broadcast mode to send to each client the URC instruction receiving, by the client screening URC instruction corresponding with it.
The embodiment of the present invention has provided one group of applicating example, and previous embodiment is further described, and wherein, simulative serial port testing apparatus (simulator) adopts the simulation of flexible bus responder with the communication mode of client agreement, and test data file adopts XML file.Refer to Fig. 8, it should be noted that, in the present embodiment, each unit can combine and further split according to its function, to this embodiment of the present invention, will not limit, and the function dividing mode in below giving an example also should not be construed as the unique restriction to the embodiment of the present invention.
Example 1: this example realizes AT instruction and response, URC report, specific as follows:
AT command reception processing unit, for adopting D-Bus Method Reply(flexible bus responder), receive and extract the AT instruction from client, and issue AT instruction to AT flow process control unit.
AT flow process control unit, for reading present node information by XML resolver unit from XML file, if present node is URC instruction, transmits URC instruction to AT instruction response processing unit; Otherwise, after receiving the AT instruction that AT command reception processing unit issues, use AT instruction to mate with the expection AT instruction of present node in current XML file, if it fails to match, use unknown delivery of content to respond processing unit to AT instruction; If the match is successful, use the recv_hex(AT response of XML present node) response contents be delivered to AT instruction response processing unit;
XML resolver unit, for read successively the information (as: Unknow, timeout, type, repeat, send_hex, recv_hex etc.) of the test data of pre-configured XML file from XML memory cell, wherein the current information reading is present node (that is to say when pre-treatment position), and correctly match after the AT request from client at AT flow process control unit, mobile when pre-treatment position is in next node or next XML file.AT flow process control unit can read present node information by XML resolution unit so, if URC directly sends to AT instruction response processing unit, otherwise wait for and receive instruction and mate, if the match is successful, send response contents to AT instruction response processing unit, otherwise, send unknown to AT instruction response processing unit.
XML memory cell, for storing the test case of single or multiple XML files, realizes the use of combining of XML file, thus can facilitate test case Classification Management, realize test case and reuse the workload of writing that reduces test case.
AT instruction response processing unit, for by response contents or URC from AT flow process control unit, adopts D-Bus Method Reply to send to the client of appointment.The execution result of AT instruction response processing unit is specially so: if be URC instruction at present node, XML resolver reads above-mentioned command content and sends to AT flow process control unit.AT flow process control unit sends it to AT instruction response processing unit and adopts D-Bus Method Reply the content of URC to be sent to the client of appointment.
Above embodiment, adopt the mode of artificial antenna network interface card to test client, can wait for that the exploitation of hardware or base-band software is complete also needn't rely on it and support, so the exploitation of client can be debugged on stream in time with debugging, thereby improves whole development progress.
Example 2: this example is further realized response and the timeout treatment of AT instruction on the basis of example 1, specific as follows:
AT command reception processing unit, for adopting D-Bus Method Reply to receive and extract the instruction from the AT of client, and issues AT instruction to AT flow process control unit.
AT flow process control unit, for reading present node information by XML resolver unit from XML file, if present node is URC instruction, controls the overtime analogue unit of AT and starts timer; Otherwise, after receiving the AT instruction that AT command reception processing unit issues, use AT instruction to mate with the expection AT instruction of present node in current XML file, if it fails to match, use unknown delivery of content to respond processing unit to AT instruction; If the match is successful, control the overtime analogue unit of AT and start timer;
The overtime analogue unit of AT, according to the delay requirement of the present node of XML configuration file, starts timer, after timer overflows, by recv_hex perhaps URC pass to AT instruction response processing unit.The overtime analogue unit of AT plays the transmission lag of controlling recv_hex.
AT instruction response processing unit, for by the response contents from the overtime analogue unit of AT or URC, adopts D-Bus Method Reply to send to the client of appointment.
XML resolver unit, for read successively the information (as: Unknow, timeout, type, repeat, send_hex, recv_hex etc.) of the test data of pre-configured XML file from XML memory cell, wherein the current information reading is present node (that is to say when pre-treatment position), and correctly match after the AT request from client at AT flow process control unit, mobile when pre-treatment position is in next node or next XML file.
XML memory cell, for storing the test case of single or multiple XML files, realizes the use of combining of XML file, thus can facilitate test case Classification Management, realize test case and reuse the workload of writing that reduces test case.
Example 3: response and Abort that this example is further realized AT instruction on the basis of example 2 process, specific as follows:
AT command reception processing unit, for adopting D-Bus Method Reply to receive and extract the instruction from the AT of client, and issues AT instruction to AT flow process control unit.
AT flow process control unit, after receiving the AT instruction that AT command reception processing unit issues, use AT instruction to mate with the expection AT instruction of present node in current XML file, if it fails to match, use unknown delivery of content to respond processing unit to AT instruction; If the match is successful, control the overtime analogue unit of AT and start timer;
The overtime analogue unit of AT, according to the delay requirement of the present node of XML configuration file, starts timer, after timer overflows, recv_hex delivery of content is responded to processing unit to AT instruction.The overtime analogue unit of AT plays the transmission lag of controlling recv_hex.
Abort analogue unit, for timeout treatment process (be after timer starts and timer overflow before), if receive the Abort interrupt requests (stopping AT instruction carries out) from client, stop AT timer, and the content of revising former recv_hex is " OK ", and be delivered to AT instruction response processing unit.
AT instruction response processing unit, for by the information from Abort analogue unit, adopts D-BusMethod Reply to send to the client of appointment.
XML resolver unit, for read successively the information (as: Unknow, timeout, type, repeat, send_hex, recv_hex etc.) of the test data of pre-configured XML file from XML memory cell, wherein the current information reading is present node (that is to say when pre-treatment position), and correctly match after the AT request from client at AT flow process control unit, mobile when pre-treatment position is in next node or next XML file.
XML memory cell, for storing the test case of single or multiple XML files, realizes the use of combining of XML file, thus can facilitate test case Classification Management, realize test case and reuse the workload of writing that reduces test case.
In above embodiment, the content information of URC all can adopt D-BusMethod Reply to send to the client of appointment by URC radio unit.
The embodiment of the present invention is also served as theme and is provided an embodiment, above-described embodiment can realize simulative serial port testing apparatus (simulator) test to a plurality of clients simultaneously with the use flow process of XML file, specific as follows:
Simulator loads after xml, and current pointer is pointed to article one " AT " node, now, first judges whether whether type equals 0(is URC type); If so, recv_hex content broadcast is arrived to client; If be not equal to the non-URC of 0(), wait for the AT request receiving from client, after AT request arrives, AT request and the send_hex content under present node are compared, if do not mate, use the content of unknown to send to given client end to respond, if coupling is used the content of recv_hex to send to given client end to respond; Then mobile current pointer arrives next " AT " node, and repeats above operation until XML file is all completed.
In above-mentioned flow process, if add overtime, after instruction coupling, according to node delay information, carry out time delay, if receive the AT instruction of abort in time delay process, send OK response, for URC, after decision node response is for URC, directly start time delay, after finishing, time delay sends URC.
Above embodiment, adopt the mode of artificial antenna network interface card to test client, can wait for that the exploitation of hardware or base-band software is complete also needn't rely on it and support, so the exploitation of client can be debugged on stream in time with debugging, thereby improves whole development progress.In addition, add the transmission lag that timeout treatment can effectively control response message, XML file centralized stores has been realized to the use of combining of XML file, thus can facilitate test case Classification Management, realize test case and reuse the workload of writing that reduces test case; Test when adding a plurality of client, can realize multithreading and process, and further improves testing efficiency.
It should be noted that in above-mentioned simulative serial port testing apparatus embodiment, included unit is just divided according to function logic, but be not limited to above-mentioned division, as long as can realize corresponding function; In addition, the concrete title of each functional unit also, just for the ease of mutual differentiation, is not limited to protection scope of the present invention.
In addition, one of ordinary skill in the art will appreciate that all or part of step realizing in above-mentioned each embodiment of the method is to come the hardware that instruction is relevant to complete by program, corresponding program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be read-only memory, disk or CD etc.
These are only preferably embodiment of the present invention; but protection scope of the present invention is not limited to this; anyly be familiar with those skilled in the art in the technical scope that the embodiment of the present invention discloses, the variation that can expect easily or replacement, within all should being encompassed in protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion by the above-mentioned protection range with claim.