Summary of the invention
In view of this, main purpose of the present invention is to provide a kind of method of the AT of simulation command report, can simulate the processing procedure of various related services between UE and mobile communications network, simulative debugging and test, thus accelerate research and development speed.
For achieving the above object, technical scheme of the present invention is achieved in that
A kind of method of simulating the AT command report, the computer-side application program with open serial ports after portable terminal is connected, set up the communication port between the AT order of computer and portable terminal, this method comprises the steps:
A, computer-side application program issue the AT order by serial ports to portable terminal, and wait for mobile terminal reporting command response result;
B, the AT that selects the computer-side application program to issue order pairing command response result, selected command response result is write configuration file, and configuration file is kept in the computer-side respective storage areas;
C, computer-side application program are obtained AT command response result, each AT command response result is cut apart, extract the response word string among the command response result, after handling result put into the command response formation, and the selected command response result of step b is inserted in the command response formation;
D, computer-side application program are handled the command response result in the command response formation.
This method further comprises: the simulation softward that has copying in the computer-side setting;
Described step b is realized by the simulation softward that computer-side is provided with.
Wherein, the pairing command response result of the described selection computer-side of step b application program transmitting order to lower levels, be specially: read the AT command response result who edits in advance, and described command result is presented in the tabulation, change the current AT command result that needs simulation by in tabulation, directly choosing.
The pairing command response result of order that the described selection computer-side of step b application program issues further comprises: revise selected order.
The described AT of the obtaining command response of step c result is: regularly read the AT command response result who reports by serial ports, or regularly read the command response result that the AT command response result that reports and portable terminal initiatively report by serial ports.
Described each the AT command response result of cutting apart of step c is: the data of taking out the response word string that comprises among the AT command response result.
After handling described in the step c result being put into the command response formation is specially: read the AT command response result of configuration file, select to replace the command result that portable terminal reported; If the result that simulation initiatively reports then is put into the AT command response result in the configuration file after the command result that portable terminal reports, as the part of command response formation.
Step c is described to be put into the command response formation with result and is specially: if do not set up the command response formation, then with the head of the queue of described result as the command response formation; If have the command response formation, then described result is joined the tail of the queue of formation or any position in the insertion formation.
Step c is described to be inserted into the selected command response result of step b in the command response formation, is specially: any position that the selected command response result of step b is inserted into the command response formation.
This method further comprises: the computer-side application program is added the debugging code that simulation receives order in reading the code of serial ports, the code that is added is controlled by macro switch; And when the computer-side application program was formally issued, described simulation received selected the closing of code function of order.
The method of simulation AT command report provided by the present invention, have the simulation softward of AT order copying in the setting of PC side, simulate the response results after UE carries out the AT order, and report PC side application program and further handle, therefore, the present invention has the following advantages and characteristics:
1) PC side application program can be developed and debug to the inventive method under the incomplete situation of network function, can also simulate various possible results, make the test and the debugging more comprehensively, complete, can as often as possible find the problem that PC side application program may exist, and application programs improves and perfect, thereby makes PC side function of application more perfect and stable.For example, can select response results arbitrarily when debugging, repeat the result that some are difficult to reproduction, in the time of as incoming call, come a note again, make test process more convenient, test result is more reliable.
2) method of the present invention is when test and debugging software, and UE can not rely on the support of mobile network signals, has therefore reduced the communication cost cost in the test processs such as conversation, note.
Embodiment
Below in conjunction with accompanying drawing and embodiments of the invention method of the present invention is described in further detail.
Fig. 1 is PC side application program and UE connected mode schematic diagram, and as shown in Figure 1, PC can pass through serial communication interface (COM) or usb mode and connect by serial communication mode and UE devices communicating, and wherein, described serial communication interface is called for short serial ports.Store the response data packet of AT order among the UE, each command execution success or not all has corresponding return results.
The AT command processing module of PC side application program utilization inside communicates by serial ports and UE, after PC side application program is opened serial ports, sends the AT order to UE; UE resolves after receiving the AT order, then the execution result of ordering to PC side application response AT; PC side application program is handled after receiving this response results, and can the identification mode display result with the user.In this way, the user can realize functions such as setting, conversation, transmission/reception short message to UE.
Fig. 2 is the method flow diagram that PC side application program cooperates with AT order simulation softward in the embodiment of the invention, and used TE in the present embodiment is typically wireless network card and mobile phone, below is referred to as UE; Used main frame is typically PC; Be provided with in the PC and operation has two kinds of softwares: a kind of is the PC side application program that is used for management terminal device, another kind be have copying, can simulate the AT command execution results and report the software of PC side application program, be called simulation softward.As shown in Figure 2, the method for simulation AT command report of the present invention mainly comprises the steps:
Step 201: start PC side application program and be connected, open the AT command communication passage that serial ports is set up PC and UE with UE.
Through this step, make PC side application program and terminal equipment can carry out proper communication.
Step 202:PC side application program issues the AT order by serial ports to UE, and waits for that UE reports the command response result.
Described response results is that the form with character string reports to the PC side, and for example, the response format that the AT order is returned is:<CR〉<LF〉<instruction is correlated with AT character string〉<CR〉<LF 〉.
For instance, simulation once sends a telegram here/go into to call out the indication incident: when UE receives an incoming call, UE will initiatively report an AT command response result, be r nRING r n r nOK r n, wherein: r represent<CR, being the character of carriage return, also is the termination character of every order; N represent<LF, i.e. Huan Hang character also is to respond the format character;
The basic format that the result is responded in above-mentioned AT order is:<CR〉<LF〉<the response word string〉<CR〉<LF〉<OK/ERROR〉[ERROR information].In the present embodiment, the response word string is RING;<OK/ERROR〉status report be OK.
Wherein, the status report (OK, ERROR) of AT order has following several situation usually:
If AT command format mistake then can be returned " ERROR " character string;
If enabled the extended error report (+CMEE), then can return string "+CME ERROR:<Err〉" or "+CMS ERROR:<SmsErr〉" and different error codes;
If the success of AT command execution then can return string " OK ".
Step 203: the AT that selects PC side application program to issue by simulation softward orders pairing command response result, by simulation softward selected command response result is write configuration file, and configuration file is kept in the corresponding memory block of PC side.
Such as, in order to simulate an incoming call incident, prepared the AT command option of what a incoming call in simulation softward in advance, ordering is: r nNG r n r nOK r n, and write configuration file by simulation softward with this command response result this moment.
Described configuration file is meant a kind of text of single file, operate on the windows platform, carry out the interface of data communication as simulation softward and PC side application program, can read each item number certificate in the configuration file by Windows standard application program interface (API) function.The present invention uses the ini formatted file as configuration file, can certainly use forms such as txt, xml.Usually, configuration file comprises following content:
[AT_SIM_CONFIG]
AT_SIM_ON=0
AT_SIM_INSERT_HEAD=0
AT_SIM_OUTPUT=\r\n+CMTI:“SM”,1\r\n。
Here, [AT_SIM_CONFIG] expression configuration section (SECTION); AT_SIM_ON, AT_SIM_INSERT_HEAD, AT_SIM_OUTPUT are configuration item.Wherein, the AT_SIM_ON item represents whether analog functuion is opened, if AT_SIM_ON=0 represents that then this analog functuion is for closing; If AT_SIM_ON=1 represents that then this analog functuion is an open state.The AT_SIM_INSERT_HEAD item represents whether the AT result of simulation to be inserted into the foremost of AT command result formation.The command response result that the AT_SIM_OUTPUT item indicates to simulate is that this result produces for simulation softward, be that the user needs Simulation result.The user selects a command response result in simulation softward after, simulation softward can be write the command response result that the user selects in this configuration item, PC side application program can read this configuration item, and the command response result who selects is inserted in the AT command response result queue.
The described pairing command response result of order who selects PC side application program to issue by simulation softward, be meant that simulation softward can read the AT command response result who edits in advance, the command response result who reads is presented in the tabulation, and the user directly chooses in tabulation just can change the current AT command result that needs simulation.Here, the user also can revise immediately to the order of selecting.
Step 204:PC side application program is obtained AT command response result, the AT command response result that each is complete is cut apart, extract the response word string among the command response result, after handling result put into the command response formation, and the selected command response result of step 203 is inserted in the command response formation, wait for that PC side application program handles.
Here, the described AT of obtaining command response result can be that PC side application program regularly reads the AT command response result that simulation softward reports by serial ports, wherein also can comprise the AT command response result that UE initiatively reports.
Can judge by the value of AT_SIM_ON item in the configuration file whether simulation softward opens the simulation reporting functions, for simulation softward, whether this reporting functions is opened does not have difference, and for PC side application program, if the unlatching reporting functions is attended school and is got Simulation result; If close reporting functions, then do not read Simulation result.
Generally, PC side application program is added one section debugging code and is finished the function that simulation receives order in reading the code of serial ports, and this partial code can when formal PC side application issued, can be closed this analog functuion by a macro switch control.Described macro switch is meant that in code one of definition is grand, and the code in this macrodefinition can be compiled, if not definition then can not compile.Purpose is when formal releasing software, can remove the code of analog functuion by the cancellation macrodefinition, and not influence formal edition code.
Described reporting functions is meant the configuration item in configuration file, as AT_SIM_ON=1, if reading this configuration item is, represents that then reporting functions opens at 1 o'clock; If be 0, represent that then reporting functions closes.In addition, by add new item at configuration file, can also control other function, thereby realize function expansion.
Be exactly to extract to respond word string from AT command response result described AT command response result is cut apart, specifically, AT command response result's form is:<CR〉<LF<respond word string<CR<LF, be exactly taking-up<CR described cutting apart〉<LF between the data of response word string.
After described the processing result is put into the command response formation specifically: read the AT command response result of configuration file, select to replace the command response result that UE reported; If the command response result that simulation initiatively reports then is put into the AT command response result in the configuration file after the command response result that UE reports, as of command response formation.Described command response formation is meant the set with one or more command response results of the form tissue of data structures such as array or chained list in internal memory of PC side application program.
Wherein, describedly result is put into the command response formation be specially:, then this is handled the head of the queue of result as the command response formation if this fashion is not set up the command response formation; If there has been the command response formation, then this handled the result and join the tail of the queue of formation or any position in the insertion formation.
Wherein, the described selection replacement command response result that UE reported replaces as required.Because the situation of the response results that has is difficult to take place in practice, for example, in the time of incoming call, come note again, this moment is when needing to verify whether the response results that UE reports has done correct processing in PC side application program, perhaps when need test receive a mistake as a result the time, whether PC side application program can carry out correct processing is fault-tolerance, if the command response result who replaces UE and reported this moment, can verify the robustness of PC side application program.
Described the selected command response result of step 203 being inserted in the command response formation, can be that the command response result that needs insert is placed on any position in the command response formation, receives the command response result that different sequential are sent with simulation.Such as: when the semaphore of inquiry terminal, can simulate and before obtaining the semaphore Query Result, come the note or the situation of note afterwards.
Step 205:PC side application program is handled the command response result in the command response formation.
Here, because PC side application program is handled the processing procedure that belongs to upper layer software (applications) to the command response result, and different PC side application program processing modes is also different, as long as the AT designator standardization in the formation of AT command response, upper layer software (applications) can both be made correct processing.
For example, PC side application program is carried out the timing inquiry to terminal equipment, on needing, the command response result gives the correct time, PC side application program can read the data of serial ports and the data in the configuration file, merges then, reports the upper strata again and handles, when the upper strata handle r nRING r n r nOK r n when order, will think has incoming call, and pop-up window prompting or play sound and carry out voice suggestion under software interface, thereby finishes the overall process of simulate incoming call.
According to above step, can also simulate incidents such as note, come being reported as of AT order of short message event correspondence: r n+CMTI: " SM ", 2 r n; The AT of short message state report correspondence is: r n+CDSI: " SM ", 1 r n; Simulation the other side is hung up being reported as of corresponding AT order: r nHANGUP:0 r n etc.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention.