CN103309787B - Detection method of nonstandard USB protocol compatibility - Google Patents

Detection method of nonstandard USB protocol compatibility Download PDF

Info

Publication number
CN103309787B
CN103309787B CN201310264252.0A CN201310264252A CN103309787B CN 103309787 B CN103309787 B CN 103309787B CN 201310264252 A CN201310264252 A CN 201310264252A CN 103309787 B CN103309787 B CN 103309787B
Authority
CN
China
Prior art keywords
test
data
equipment
tested
length
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201310264252.0A
Other languages
Chinese (zh)
Other versions
CN103309787A (en
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201310264252.0A priority Critical patent/CN103309787B/en
Publication of CN103309787A publication Critical patent/CN103309787A/en
Application granted granted Critical
Publication of CN103309787B publication Critical patent/CN103309787B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a detection method of nonstandard USB (Universal Serial Bus) protocol compatibility, and belongs to the field of computers. The method comprises the following steps: looking up to-be-tested equipment, reading configuration information, when satisfying the condition of sending a test request packet, invoking a preset function to send the test request packet to the Hub driving end wherein the to-be-tested equipment in and judging whether the function invoking is successful or not, if the function invoking is not successful, checking whether the reason of the unsuccessfulness is a mistake produced due to the improper process of the equipment, if the function invoking is successful, checking whether the returned data of the to-be-tested equipment is legal or not, generating corresponding error code according to the check result and recording corresponding information, and checking whether the to-be-tested equipment loses response, if yes, finishing the test, and if no, continuing the test. The method has the benefits that the method can discover the problem and the defect related to the equipment in advance through the detection, then prevents the caused problem of USB equipment abnormality due to the sending of the nonstandard USB protocol request by software or a drive, and can improve the robustness of the USB equipment.

Description

The compatible detection method of a kind of non-standard usb protocol
Technical field
The present invention relates to computer realm, relate in particular to the compatible detection method of a kind of non-standard usb protocol.
Background technology
USB device usually can cause equipment cisco unity malfunction even to lose response because receiving the non-standard usb protocol request of some softwares or driving transmission.In prior art, can carry out compatibility detection to USB device, but still there is no corresponding detection method for above-mentioned USB device because of the problem that receives non-standard usb protocol request and cause.
Summary of the invention
The object of the invention is in order to overcome the defect of prior art, in order to solve USB device, because non-standard usb protocol request causes equipment cisco unity malfunction even to lose the problem of response, propose the method for work of the compatible testing tool of a kind of non-standard usb protocol.
The inventive method is achieved through the following technical solutions:
The compatible detection method of non-standard usb protocol, its basic implementation process is as follows:
Steps A: searching equipment to be tested, judge whether to find equipment to be tested, is that the Hub that records equipment to be tested place drives end points, execution step B, otherwise equipment to be tested is not found in prompting, finishes;
Step B: read configuration information;
Step C: judging whether to meet transmission test request bag condition according to described configuration information, is to perform step D, otherwise perform step D after meeting transmission test request bag condition;
Step D: call preset function, the Hub driving end points transmission test request bag according to the current detecting information in described configuration information to described equipment to be tested place, whether discriminant function calls successful, is to perform step E, otherwise execution step F;
Step e: judging that whether the data that described equipment to be tested returns are legal, is to upgrade current detecting information, returns to execution step C, otherwise generates the first error code, according to described the first error code, error description is set, execution step G;
Step F: check the unsuccessful reason of function call, if generate the second error code by the mistake of the improper generation of device processes, according to described the second error code, error description is set, execution step G, otherwise upgrade current detecting information, return to execution step C;
Step G: record corresponding error code, error description and described test request bag;
Step H: check whether equipment to be tested loses response, is to test end, otherwise upgrade current detecting information, return to execution step C.
Wherein, described step C is specially: judging in configuration information whether comprise delayed data, is the corresponding time of time delay, execution step D, otherwise execution step D, and wherein, the described corresponding time equals the value of described delayed data;
Or, between described step B and described step C, also comprise: checking in described configuration information whether comprise filtration drive information, is to perform step C after first loading filtration drive again, otherwise execution step C; Described step C is specially: judging whether to receive the test post that filtration drive sends, is to perform step D, otherwise waits for the test post that receives described filtration drive transmission, after the test post that receives described filtration drive transmission, performs step D;
Or, between described step B and described step C, also comprise: checking in described configuration information whether comprise filtration drive information, is to perform step C after first loading filtration drive again, otherwise execution step C; Described step C is specially:
Step I: judging whether to receive the test post that filtration drive sends, is to perform step ii, otherwise execution step iii;
Step I i: checking in described configuration information whether comprise delayed data, is to perform step D after the corresponding time of time delay, otherwise execution step D, wherein, the described corresponding time equals the value of described delayed data;
Step I ii: wait for and receive the test post that described filtration drive sends, return to execution step ii after the test post that receives described filtration drive transmission.
Current detecting information in described configuration information is current test request bag; The described preset function of calling, Hub driving end points transmission test request bag according to from the current detecting information in described configuration information to described equipment to be tested place, be specially: call preset function, to the Hub at described equipment to be tested place, drive end points to send current test request bag;
Or the current detecting information in described configuration information is current pending test; The described preset function of calling, according to the current detecting information in described configuration information, to the Hub at described equipment to be tested place, drive end points to send test request bag tool to be: according to current pending test, generate test request bag, call preset function, to the Hub at described equipment to be tested place, drive the test request bag of end points transmission generation;
Wherein, describedly according to current pending test, generate test request bag and specifically comprise: initialization test request bag, read the current pending test in described configuration information, according to the type of current pending test, the test-types data in described test request bag are set, according to request length, the testing length data in described test request bag are set;
Described test request bag is comprised of the first data, the second data, described test-types data, the 3rd data and request length data; Described initialization test request bag is specially: initialization the first data are that the first preset data, initialization the second data are that the second preset data, initialization test categorical data are that the first initial value, initialization the 3rd data are that the 3rd preset data and initialization requests length data are the second initial value;
The type of described current pending test comprises: obtain device descriptor test, and/or obtain configuration descriptor and test, and/or obtain character string descriptor and test, and/or obtain interface descriptor and test, and/or obtain the test of test endpoint descriptor, and/or obtain the test of human interface device descriptor;
The described testing length data that arrange in test request bag according to request length specifically comprise: whether judgement request length is less than the 5th preset data, to upgrade described request length, according to the request length after upgrading, the testing length data in test request bag are set, execution step D, otherwise upgrading the current pending test in described configuration information and revising described request length is initial value, return to execution step B, the initial value of wherein said request length is the 4th preset data.
In described step e, whether the data that described judgment device is returned are legal is specially: content and the length of the data of returning from described preset function, obtaining equipment return data, whether legal according to the content of described test-types data judgment device return data, whether legal according to the length of described testing length data judgment device return data, if the content of equipment return data and the length data that all legal equipment returns are legal, otherwise the data that equipment returns are illegal; Wherein, described whether legal being specially of content that judges described equipment return data to be tested according to described test-types data, judge whether described equipment return data to be tested is the corresponding descriptor of type of current pending test, if so the data that, definite described equipment to be tested returns are legal; Otherwise, determine that the data that described equipment to be tested returns are illegal; Described according to whether legal being specially of length of described testing length data judgment device return data, whether the length of judgment device return data is greater than request length, be that the length of equipment return data is illegal, otherwise the length of equipment return data is legal.
Whether described discriminant function calls and is successfully specially, and whether the data discriminant function returning according to described preset function calls successful;
Further, before the unsuccessful reason of described inspection function call, also comprise: obtain system mistake code; The unsuccessful reason of described inspection function call is specially, judge whether described system mistake code is the first default error code, be that the unsuccessful reason of function call is not the mistake by the improper generation of device processes, otherwise the unsuccessful reason of function call is the mistake by the improper generation of device processes.
Before described step G, also comprise the operation system information of obtaining test platform; In described step G, also comprise: in journal file, write described operation system information.
While finding equipment to be tested in described steps A, also comprise: the information that records each equipment on device path to be tested and described path; In described step G, also comprise: to the information that writes each equipment on described device path to be tested and described path in journal file.
Described step H specifically comprises: that calls that preset function drives to the Hub at described equipment to be tested place that end points sends standard obtains device descriptor order, judge whether to receive the response message that equipment to be tested returns, that equipment to be tested does not lose response, return to execution step C, otherwise equipment to be tested loses response, test finishes.
In described step F, when the unsuccessful former because improper generation of device processes of function call wrong, also comprise: whether the mistake that judges the improper generation of described device processes can be ignored, to return to execution step H, otherwise generate the second error code, according to described the second error code, error description is set, execution step G.
In described step F, when the unsuccessful former because improper generation of device processes of function call wrong, also comprise: judge whether described system mistake code is the second default error code, to reopen equipment to be tested, return to execution step D, otherwise generate the second error code, according to described the second error code, error description is set, execution step G.
Between described step B and described step C, also comprise: from described configuration information, select one not by used detecting information, using the detecting information of selecting as current detecting information;
In described step e, when the data returned when equipment are legal, also comprise: judge whether to complete the whole tests in described configuration information, to test end, otherwise from described configuration information, select one not by used detecting information, using the detecting information of selecting as current detecting information, return to execution step C;
In described step F, when the unsuccessful reason of function call is not during by the improper generation of device processes wrong, also comprise: judge whether to complete the whole tests in described configuration information, to test end, otherwise from described configuration information, select one not by used detecting information, using the detecting information of selecting as current detecting information, return to execution step C;
In described step H, when equipment to be tested does not lose response, also comprise: judge whether to complete the whole tests in described configuration information, to test end, otherwise from described configuration information, select one not by used detecting information, using the detecting information of selecting as current detecting information, return to execution step C.
The beneficial effect of the inventive method is, can be by detecting, shift to an earlier date relevant problem and the defect of discovering device, and then prevent because of software or drive the non-standard usb protocol request of transmission to cause the problem that USB device is abnormal, can improve the robustness of USB device, and above-mentioned detection can be carried out in the situation that not affecting upper level applications use.
Accompanying drawing explanation
For the clearer explanation embodiment of the present invention or technical scheme of the prior art, to the accompanying drawing of required use in embodiment or description of the Prior Art be briefly described below, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skills, do not paying under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
The process flow diagram of the compatible detection method of a kind of non-standard usb protocol that Fig. 1 provides for the embodiment of the present invention one;
In the compatible detection method of a kind of non-standard usb protocol that Fig. 2 provides for the embodiment of the present invention one, search the process flow diagram of device procedures to be tested;
The process flow diagram of the compatible detection method of a kind of non-standard usb protocol that Fig. 3 provides for the embodiment of the present invention two.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, those skilled in the art, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
Embodiment mono-
The embodiment of the present invention provides a kind of non-standard usb protocol compatible detection method, and referring to Fig. 1, described method is realized by test platform operation test procedure, specifically comprises the steps:
Step 101: searching equipment to be tested, judge whether to find equipment to be tested, is the Hub(hub that records equipment to be tested place) drive end points, execution step 102, otherwise equipment to be tested is not found in prompting, finishes;
Particularly, referring to Fig. 2, described in search equipment to be tested and specifically comprise:
Step a: search USB HCD(USB master controller), judging whether to also have the USB HCD not detecting, is to perform step b, otherwise search device procedures to be tested, finishes;
Step b: search the Root Hub(Root Hub that current USB HCD is corresponding), judging whether to also have the Root Hub not detecting, is to perform step c, otherwise returns to execution step a;
Step c: inquire about the information of current Root Hub, execution step d;
Particularly, call the information of the current Root Hub of DeviceIoControl functional query;
Steps d: searching the end points of current Root Hub, judge whether to also have the end points not detecting, is to perform step e, otherwise return to execution step b;
Step e: inquire about current Root Hub when the information of forward terminal, execution step f;
Particularly, call the current Root Hub of DeviceIoControl functional query when the information of forward terminal;
Step f: judge current Root Hub when the equipment that forward terminal connects whether be Hub(hub), be to perform step g, otherwise execution step j;
Step g: searching the end points of current Hub, judge whether to also have the end points not detecting, is to perform step h, otherwise return to execution step d;
Step h: inquire about current Hub when the information of forward terminal, execution step i;
Step I: judge that current Hub, when whether the equipment that forward terminal connects is equipment to be tested, is to search device procedures to be tested to finish, otherwise return to execution step g;
Step j: judge that current Root Hub, when whether the equipment that forward terminal connects is equipment to be tested, is to search device procedures to be tested to finish, otherwise return to execution step d;
Further, also comprise after finding equipment to be tested: the information that records each equipment on device path to be tested and this path;
It should be noted that, said process is connected to example by one-level Hub and testing tool at most with equipment to be tested and describes, but the present invention is not restricted to this;
Step 102: read configuration information;
Particularly, described configuration information comprises pending detecting information;
Preferably, in the present embodiment, described pending test comprises: obtain device descriptor test, and/or obtain configuration descriptor and test, and/or obtain character string descriptor and test, and/or obtain character string descriptor (manufacturer's information) and test, and/or obtain character string descriptor (product information) and test, and/or obtain interface descriptor and test, and/or obtain test end points [0] descriptor and test, and/or obtain test end points [1] descriptor and test, and/or obtain test end points [2] descriptor and test, and/or obtain test end points [3] descriptor and test, ..., and/or obtain HID (Human Interface Device, human interface device) descriptor test, and/or obtain other descriptors and test,
Step 103: judging the information that whether comprises filtration drive in configuration information, is to perform step 104, otherwise execution step 105;
Step 104: load filtration drive, execution step 105;
Concrete, in the present embodiment, filtration drive drives the IRP(I/O request bag that sends to bottom layer driving to upper strata) tackle, and the IRP intercepting is identified, if the specific son request of specific IRP sends test post and is transmitted to bsp driver to test procedure and by the IRP intercepting, if not the specific son request of specific IRP is transmitted to bsp driver by the IRP intercepting; Wherein, described specific IRP is as IRP_MJ_WRITE, IRP_MJ_READ, IRP_MJ_DEVICE_CONTROL, IRP_INTERNAL_DEVICE_CONTROL, IRP_MJ_QUERY_INFORMATION or IRP_MJ_SCSI etc.; Described specific son request as: power on, read or write etc.;
Step 105: the operation system information of obtaining the test platform of operation test procedure;
Particularly, described operation system information is as Windows 2000, Windows XP, Windows Vista and Windows 7 etc.;
Step 106: initialization test request bag;
Particularly, described test request bag is comprised of the first data, the second data, test-types data, the 3rd data and request length data, and described initialization test request bag comprises: initialization the first data are that the first preset data, initialization the second data are that the second preset data, initialization test categorical data are that the first initial value, initialization the 3rd data are that the 3rd preset data and initialization requests length data are the second initial value;
Preferably, in the present embodiment, the form of described test request bag is: bmRequest bRequest wValue wlndex wlength, wherein bmRequest represents the first data, bRequest represents the second data, and wValue represents test-types data, and wlndex represents the 3rd data, wlength represents to ask length data, the first preset data is 0x80, and the second preset data is 0x06, and the first initial value is 0x0000, the 3rd preset data is 0x0000, and the second initial value is 0x0000;
Step 107: read current pending test, and according to the type of current pending test, the test-types data in test request bag are set;
In the present embodiment, described in, reading current pending test comprises: from the pending test of configuration information, select one not by used pending test, using the pending test of selecting as current pending test;
Particularly, if the type of current pending test is that to obtain the test-types data that device descriptor arranges in test request packet be the first preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0100;
If the type of current pending test is that to obtain the test-types data that arrange in test request packet of configuration descriptor be the second preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0200;
If the type of current pending test is that to obtain the test-types data that character string descriptor arranges in test request packet be the 3rd preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0300;
If the type of current pending test is the 4th preset value for obtaining the test-types data that character string descriptor (manufacturer's information) arranges in test request packet, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0301;
If the type of current pending test is the 5th preset value for obtaining the test-types data that character string descriptor (product information) arranges in test request packet, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0302;
If the type of current pending test is that to obtain the test-types data that interface descriptor arranges in test request packet be the 6th preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0400;
If the type of current pending test for the test-types data of obtaining test end points [0] descriptor and arranging in test request packet be the 7th preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0500;
If the type of current pending test for the test-types data of obtaining test end points [1] descriptor and arranging in test request packet be the 8th preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0501;
If the type of current pending test for the test-types data of obtaining test end points [2] descriptor and arranging in test request packet be the 9th preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0502;
If the type of current pending test for the test-types data of obtaining test end points [3] descriptor and arranging in test request packet be the tenth preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x0503;
......;
If the type of current pending test is that to obtain the test-types data that HID descriptor arranges in test request packet be the 12 preset value, preferably, in the present embodiment, the wValue arranging in test request bag is 0x2200;
Step 108: whether judgement request length is less than the 5th preset data, is to perform step 109, is initial value otherwise revise described request length, execution step 121;
Wherein, the initial value of described request length is the 4th preset data;
Preferably, in the present embodiment, described the 4th preset data is 0, and described the 5th preset data is 65535;
Step 109: upgrade described request length, according to the request length after upgrading, the request length data in test request packet is set;
Particularly, upgrade described request length for its currency adds default step-length, the request length data arranging in test request packet is sexadecimal number corresponding to request length after described renewal;
Preferably, in the present embodiment, upgrade described request length and add 1 for its currency; For example, if the request length after upgrading is 1, the wlength arranging in test request packet is 0x0001, if the request length after upgrading is 65535, the wlength arranging in test request packet is 0xFFFF;
Step 110: judging whether to meet transmission test request bag condition, is to perform step 111, otherwise perform step 111 after meeting transmission test request bag condition;
Particularly, in the present embodiment, in described configuration information, also can comprise delayed data;
When in step 103, the determination result is NO, step 110 is specially: check in configuration information whether comprise delayed data, not meet the test request bag condition that sends, after the corresponding time of time delay, meet the test request bag condition that sends, otherwise meet the test request bag condition that sends, wherein, the corresponding time equals the value of delayed data;
In step 103, judgment result is that while being, step 110 is specially: check whether receive the test post that filtration drive sends, to meet the test request bag condition that sends, otherwise do not meet, send test request bag condition, after the test post that receives filtration drive transmission, meet the condition that sends test request bag;
In step 103, judgment result is that while being, step 110 can also be specially: check whether receive the test post that filtration drive sends, if receive, check and in configuration information, whether comprise delayed data, not meet the test request bag condition that sends, after the corresponding time of time delay, meet and send test request bag condition, otherwise meet the test request bag condition that sends; If receive, do not meet test request condition, receive (in configuration information, not comprising delayed data) after the test post that filtration drive sends or when receiving the test post that filtration drive sends again after the corresponding time of time delay (in configuration information, comprising delayed data) meet the test request bag condition that sends, wherein, the corresponding time equals the value of delayed data;
Preferably, in step 110, timeout mechanism can be set, if still do not meet, send test request bag condition and finish in Preset Time;
Step 111: call preset function to the Hub driving end points transmission test request bag at equipment to be tested place;
Particularly, described preset function is " DeviceloControl " function of Windows operating system, and described specified endpoint is the end points at equipment to be tested place;
Step 112: whether the data discriminant function returning according to preset function calls successful, is to perform step 113, otherwise execution step 115;
Particularly, the form of the data that preset function is returned is ret=fun (a, b), and ret representative function calls result, the content of a indication equipment return data, and the length of b indication equipment return data, when function call is unsuccessful, the content of a and b is empty;
Preferably, in the present embodiment, the ret in the data that inspection preset function is returned, if ret is function call success of TRUE, if ret is that FALSE function call is unsuccessful;
Step 113: content and the length of obtaining the equipment return data in the data that preset function returns;
Step 114: judge that whether the data that described equipment returns are legal, be to return to execution step 108, otherwise generate the first error code, execution step 117;
Particularly, when the length of the data of returning when equipment is not more than described request length, the length of the data that equipment returns is legal; The content of the data of returning when equipment is during for the corresponding descriptor of the test-types data with test request bag, the content legality of the data that equipment returns, when the length of the data of returning when equipment and content are all legal, the data that equipment returns are legal, otherwise the data that equipment returns are illegal;
Described the first error code is self-defined error code, for example, in the present embodiment, described the first error code comprises-1 and-2, when the content of equipment return data is illegal, the first error code being set is-1, and when the length of equipment return data is illegal, the first error code being set is-2;
Step 115: obtaining system mistake code, whether be mistake by device processes improper generation, be to perform step 116 if calling unsuccessful reason according to the system mistake code discriminant function getting, otherwise execution step 119;
Particularly, by system call GetLastError, obtain system mistake code, when system mistake code is the first default error code, show that the unsuccessful reason of function call is not the mistake by the improper generation of device processes, otherwise show that the unsuccessful reason of function call is the mistake by the improper generation of device processes;
Preferably, in the present embodiment, the described first default error code is 1 or 87;
Step 116: judge whether this mistake by the improper generation of device processes can be ignored, and is to perform step 119, otherwise generate the second error code, execution step 117;
Particularly, described configuration information comprises the negligible mistake by the improper generation of device processes, and for example, system mistake code can be set is 31 or within 995 o'clock, represent can be ignored by the mistake of the improper generation of device processes;
Described the second error code is system mistake code;
Step 117: corresponding error description is set according to corresponding error code;
Step 118: to write operation system information, error code, error description and test request bag in journal file;
Particularly, the error code in this step comprises device Errors code and system mistake code;
Further, this step can also comprise to the information that writes each equipment on device path to be tested and this path in journal file;
Step 119: that calls that preset function drives to the Hub at described equipment to be tested place that end points sends standard obtains device descriptor order;
Step 120: judging whether to receive the response message that equipment to be tested returns, is to return to execution step 108, otherwise execution step 122;
Step 121: judge whether the complete whole pending tests of executed, be to perform step 122, otherwise upgrade current pending test, return to execution step 107;
Particularly, in the present embodiment, the current pending test of described renewal comprises: from the pending test of configuration information, select one not by used pending test, using the pending test of selecting as current pending test;
Step 122: journal file is write to test record file, and test finishes;
Further, in step 116, when the unsuccessful reason of function call is can also comprise during by the improper generation of device processes wrong: judge whether system mistake code is the second default error code, is to perform step A, otherwise execution step 118; Wherein, the described second default error code is 6;
Steps A: reopen equipment to be tested, call preset function and again drive specified endpoint to send test request packet to Hub;
Step B: whether the data discriminant function returning according to preset function calls successful, is to perform step C, otherwise execution step E;
Step C: obtain the content of equipment return data and the length of equipment return data in the data that preset function returns;
Step D: judge that whether described equipment return data is legal, be to return to execution step 108, otherwise generate the first error code, execution step G;
Particularly, when the length of the data of returning when equipment is not more than described request length, the length of the data that equipment returns is legal; The content of the data of returning when equipment is during for the corresponding descriptor of the test-types data with test request bag, the content legality of the data that equipment returns, when the length of the data of returning when equipment and content are all legal, the data that equipment returns are legal, otherwise the data that equipment returns are illegal;
Step e: whether obtain system mistake code, calling unsuccessful reason according to the system mistake code discriminant function getting is the mistake by the improper generation of device processes, is to perform step F, otherwise execution step I;
Step F: judge whether this mistake by the improper generation of device processes can be ignored, be to return to execution step 108, otherwise generate the second error code, execution step G;
Step G: corresponding error description is set according to corresponding system error code;
Step H: to write operation system information, error code, error description and test request bag in journal file;
Step I: that calls that preset function drives to the Hub at described equipment to be tested place that end points sends standard obtains device descriptor order;
Step J: judging whether to receive the response message that equipment to be tested returns, is to return to execution step 108, otherwise execution step K;
Step K: journal file is write to test record file, finish.
Need be at 2 of explanation: one, in the present embodiment, request length is to change from small to large, and what easily expect is to change from big to small; Two, in the present embodiment, while having the information of filtration drive in configuration information, test procedure is carried out a pending test after receiving the test post that filtration drive sends, what easily expect is to receive after the detecting information that filtration drive sends at every turn and send all (or several) pending test, does not repeat them here.
Embodiment bis-,
The embodiment of the present invention provides a kind of non-standard usb protocol compatible detection method, and referring to Fig. 3, described method is realized by testing tool operation trace routine, specifically comprises the steps:
Step 201: searching equipment to be tested, judge whether to find equipment to be tested, is that the Hub that records equipment to be tested place drives end points, execution step 202, otherwise equipment to be tested is not found in prompting, finishes;
Particularly, in the present embodiment, search identical with embodiment mono-of the process of equipment to be tested, do not repeat them here;
Preferably, also comprise after finding equipment to be tested: the information that records each equipment on device path to be tested and this path;
Step 202: read configuration information;
Particularly, in described configuration information, also comprise test request bag;
Step 203: judging the information that whether comprises filtration drive in configuration information, is to perform step 204, otherwise execution step 205;
Step 204: load filtration drive, execution step 205;
Concrete, in the present embodiment, filtration drive drives the IRP(I/O request bag that sends to bottom layer driving to upper strata) tackle, and the IRP intercepting is identified, if the specific son request of specific IRP sends test post and is transmitted to bsp driver to test procedure and by the IRP intercepting, if not the specific son request of specific IRP is transmitted to bsp driver by the IRP intercepting; Wherein, described specific IRP is as IRP_MJ_WRITE, IRP_MJ_READ, IRP_MJ_DEVICE_CONTROL, IRP_INTERNAL_DEVICE_CONTROL, IRP_MJ_QUERY_INFORMATION or IRP_MJ_SCSI etc.; Described specific son request as: power on, read or write etc.;
Step 205: the operation system information of obtaining the test platform of operation test procedure;
Particularly, described operation system information comprises OS name, as Windows 2000, Windows XP, Windows Vista and Windows 7 etc.;
Step 206: judging whether to meet transmission test request bag condition, is to perform step 207, otherwise perform step 207 after meeting transmission test request bag condition;
Particularly, in the present embodiment, in described configuration information, also can comprise delayed data;
When in step 203, the determination result is NO, step 206 is specially: check in configuration information whether comprise delayed data, not meet the test request bag condition that sends, after the corresponding time of time delay, meet the test request bag condition that sends, otherwise meet the test request bag condition that sends, wherein, the corresponding time equals the value of delayed data;
In step 203, judgment result is that while being, step 206 is specially: check whether receive the test post that filtration drive sends, to meet the test request bag condition that sends, otherwise do not meet, send test request bag condition, after the test post that receives filtration drive transmission, meet the condition that sends test request bag;
In step 203, judgment result is that while being, step 206 can also be specially: check whether receive the test post that filtration drive sends, if receive, check and in configuration information, whether comprise delayed data, not meet the test request bag condition that sends, after the corresponding time of time delay, meet and send test request bag condition, otherwise meet the test request bag condition that sends; If receive, do not meet test request condition, receive (in configuration information, not comprising delayed data) after the test post that filtration drive sends or when receiving the test post that filtration drive sends again after the corresponding time of time delay (in configuration information, comprising delayed data) meet the test request bag condition that sends, wherein, the corresponding time equals the value of delayed data;
Preferably, in step 206, timeout mechanism can be set, if still do not meet, send test request bag condition and finish in Preset Time;
Step 207: call preset function to the Hub driving end points transmission test request packet at equipment to be tested place;
Particularly, described preset function is " DeviceloControl " function of Windows operating system, and described specified endpoint is the end points at equipment to be tested place;
Step 208: whether the data discriminant function returning according to preset function calls successful, is to perform step 209, otherwise execution step 211;
Particularly, the form of the data that preset function is returned is ret=fun (a, b), and ret representative function calls result, the content of a indication equipment return data, and the length of b indication equipment return data, when function call is unsuccessful, the content of a and b is empty;
Preferably, in the present embodiment, the ret in the data that inspection preset function is returned, if ret is function call success of TRUE, if ret is that FALSE function call is unsuccessful;
Step 209: content and the length of the data that the equipment in the data that preset function returns that obtains returns;
Step 210: judging that whether the data that described equipment returns are legal, is to perform step 217, otherwise generate the first error code, execution step 213;
Particularly, when the length of the data of returning when equipment is not more than described request length, the length of equipment return data is legal; The content of the data of returning when equipment is during for the corresponding descriptor of the test-types data with test request bag, the content legality of the data that equipment returns, when the length of the data of returning when equipment and content are all legal, the data that equipment returns are legal, otherwise the data that equipment returns are illegal;
Step 211: obtaining system mistake code, whether be mistake by device processes improper generation, be to perform step 212 if calling unsuccessful reason according to the system mistake code discriminant function getting, otherwise execution step 215;
Particularly, by system call GetLastError, obtain system mistake code, when error code is that 0x01 and 0x57 show that the unsuccessful reason of function call is not the mistake by the improper generation of device processes, otherwise show that the unsuccessful reason of function call is the mistake by the improper generation of device processes;
Step 212: judge whether this mistake by the improper generation of device processes can be ignored, and is to perform step 215, otherwise generate the second error code, execution step 213;
Particularly, described configuration information comprises the negligible mistake by the improper generation of device processes, and for example, the mistake by the improper generation of device processes that system mistake code can be set be 0x1F and 0x3E3 can be ignored;
Step 213: corresponding error description is set according to corresponding system error code;
Step 214: to write operation system information, error code, error description and test request bag in journal file;
Particularly, the error code in this step comprises device Errors code and system mistake code;
Further, this step can also comprise to the information that writes each equipment on device path to be tested and this path in journal file;
Step 215: that calls that preset function drives to the Hub at described equipment to be tested place that end points sends standard obtains device descriptor order;
Step 216: judging whether to receive the response message that equipment to be tested returns, is to perform step 217, otherwise execution step 218;
Step 217: judging whether to also have the request bag to be tested not sending, is to return to execution step 206, otherwise execution step 218;
Step 218: journal file is write to test record file, and test finishes;
Further, in step 211, when the unsuccessful reason of function call is that mistake by the improper generation of device processes can also comprise: judge whether system mistake code is the second default error code, is to perform step A ', otherwise execution step 213; Wherein, the described second default error code is 6;
Steps A ': reopen equipment to be tested, call preset function and again drive specified endpoint to send test request packet to Hub;
Step B ': whether the data discriminant function returning according to preset function calls successful, is to perform step C ', otherwise execution step E ';
Step C ': content and the length of obtaining the equipment return data in the data that preset function returns;
Step D ': judging that whether the data that described equipment returns are legal, is to perform step 217, otherwise generate the first error code, execution step G ';
Particularly, when the length of the data of returning when equipment is not more than described request length, the length of equipment return data is legal; The content of the data of returning when equipment is during for the corresponding descriptor of the test-types data with test request bag, the content legality of the data that equipment returns, when the length of the data of returning when equipment and content are all legal, the data that equipment returns are legal, otherwise the data that equipment returns are illegal;
Step e ': whether obtain system mistake code, calling unsuccessful reason according to the system mistake code discriminant function getting is the mistake by the improper generation of device processes, is to perform step F ', otherwise execution step I ';
Step F ': judge whether this mistake by the improper generation of device processes can be ignored, and is to perform step I ', otherwise generate the second error code, execution step G ';
Step G ': corresponding error description is set according to corresponding system error code;
Step H ': to write operation system information, error code, error description and test request bag in journal file;
Step I ': that calls that preset function drives to the Hub at described equipment to be tested place that end points sends standard obtains device descriptor order;
Step J ': judging whether to receive the response message that equipment to be tested returns, is to perform step 217, otherwise execution step K ';
Step K ': journal file is write to test record file, finish.
Need be at 2 of explanation: one, in the present embodiment, request length is to change from small to large, and what easily expect is to change from big to small; Two, in the present embodiment, while having the information of filtration drive in configuration information, test procedure is carried out a pending test after receiving the test post that filtration drive sends, what easily expect is to receive after the detecting information that filtration drive sends at every turn and send all (or several) pending test, does not repeat them here.
Above-described embodiment is more preferably embodiment of the present invention, and the common variation that those skilled in the art carries out within the scope of technical solution of the present invention and replacement all should be included in protection scope of the present invention.

Claims (20)

1. the compatible detection method of non-standard usb protocol, is characterized in that, comprising:
Steps A: searching equipment to be tested, judge whether to find equipment to be tested, is that the Hub that records equipment to be tested place drives end points, execution step B, otherwise equipment to be tested is not found in prompting, finishes;
Step B: read configuration information;
Step C: judging whether to meet transmission test request bag condition according to described configuration information, is to perform step D, otherwise perform step D after meeting transmission test request bag condition;
Step D: call preset function, the Hub driving end points transmission test request bag according to the current detecting information in described configuration information to described equipment to be tested place, whether discriminant function calls successful, is to perform step E, otherwise execution step F;
Step e: judging that whether the data that described equipment to be tested returns are legal, is to upgrade current detecting information, returns to execution step C, otherwise generates the first error code, according to described the first error code, error description is set, execution step G;
Step F: check the unsuccessful reason of function call, if generate the second error code by the mistake of the improper generation of device processes, according to described the second error code, error description is set, execution step G, otherwise upgrade current detecting information, return to execution step C;
Step G: record corresponding error code, error description and described test request bag, execution step H;
Step H: check whether equipment to be tested loses response, is to test end, otherwise upgrade current detecting information, return to execution step C.
2. the method for claim 1, is characterized in that, described step C is specially: judge in configuration information, whether to comprise delayed data, the corresponding time of time delay, execution step D, otherwise execution step D, wherein, the described corresponding time equals the value of described delayed data.
3. the method for claim 1, is characterized in that, between described step B and described step C, also comprises: checking in described configuration information whether comprise filtration drive information, is to perform step C after first loading filtration drive again, otherwise execution step C.
4. method as claimed in claim 3, it is characterized in that, described step C is specially: judge whether to receive the test post that filtration drive sends, to perform step D, otherwise wait for and receive the test post that described filtration drive sends, after the test post that receives described filtration drive transmission, perform step D.
5. method as claimed in claim 3, is characterized in that, described step C is specially:
Step I: judging whether to receive the test post that filtration drive sends, is to perform step ii, otherwise execution step iii;
Step I i: checking in described configuration information whether comprise delayed data, is to perform step D after the corresponding time of time delay, otherwise execution step D, wherein, the described corresponding time equals the value of described delayed data;
Step I ii: wait for and receive the test post that described filtration drive sends, return to execution step ii after the test post that receives described filtration drive transmission.
6. the method for claim 1, is characterized in that, the current detecting information in described configuration information is current test request bag;
The described preset function of calling, Hub driving end points transmission test request bag according to from the current detecting information in described configuration information to described equipment to be tested place, be specially: call preset function, to the Hub at described equipment to be tested place, drive end points to send current test request bag.
7. the method for claim 1, is characterized in that, the current detecting information in described configuration information is current pending test;
The described preset function of calling, according to the current detecting information in described configuration information, to the Hub at described equipment to be tested place, drive end points to send test request bag tool to be: according to current pending test, generate test request bag, call preset function, to the Hub at described equipment to be tested place, drive the test request bag of end points transmission generation.
8. method as claimed in claim 7, it is characterized in that, describedly according to current pending test, generate test request bag and specifically comprise: initialization test request bag, read the current pending test in described configuration information, according to the type of current pending test, the test-types data in described test request bag are set, according to request length, the testing length data in described test request bag are set;
In described step e, described whether legal being specially of data that judges that described equipment to be tested returns: content and the length of obtaining described equipment return data to be tested the data of returning from described preset function, whether the content that judges described equipment return data to be tested according to described test-types data is legal, whether the length that judges described equipment return data to be tested according to described testing length data is legal, if the content of described equipment return data to be tested and the length all legal data that described equipment to be tested returns are legal, otherwise the data that described equipment to be tested returns are illegal.
9. method as claimed in claim 8, is characterized in that, described test request bag is comprised of the first data, the second data, described test-types data, the 3rd data and request length data;
Described initialization test request bag is specially: initialization the first data are that the first preset data, initialization the second data are that the second preset data, initialization test categorical data are that the first initial value, initialization the 3rd data are that the 3rd preset data and initialization requests length data are the second initial value.
10. method according to claim 9, it is characterized in that, the type of described current pending test comprises: obtain device descriptor test, and/or obtain configuration descriptor and test, and/or obtain character string descriptor and test, and/or obtain interface descriptor test, and/or obtain the test of test endpoint descriptor, and/or obtain the test of human interface device descriptor;
Described whether legal being specially of content that judges described equipment return data to be tested according to described test-types data, judge whether described equipment return data to be tested is the corresponding descriptor of type of current pending test, if so the data that, definite described equipment to be tested returns are legal; Otherwise, determine that the data that described equipment to be tested returns are illegal.
11. methods according to claim 9, it is characterized in that, the described testing length data that arrange in test request bag according to request length specifically comprise: whether judgement request length is less than the 5th preset data, to upgrade described request length, according to the request length after upgrading, the testing length data in test request bag are set, execution step D, otherwise upgrading the current pending test in described configuration information and revising described request length is initial value, return to execution step B, the initial value of wherein said request length is the 4th preset data.
12. methods as claimed in claim 9, it is characterized in that, described according to whether legal being specially of length of described testing length data judgment device return data, whether the length of judgment device return data is greater than request length, the length that is equipment return data is illegal, otherwise the length of equipment return data is legal.
13. the method for claim 1, is characterized in that, whether described discriminant function calls and be successfully specially, and whether the data discriminant function returning according to described preset function calls successful.
14. the method for claim 1, is characterized in that, also comprise: obtain system mistake code before the unsuccessful reason of described inspection function call;
The unsuccessful reason of described inspection function call is specially, judge whether described system mistake code is the first default error code, be that the unsuccessful reason of function call is not the mistake by the improper generation of device processes, otherwise the unsuccessful reason of function call is the mistake by the improper generation of device processes.
15. the method for claim 1, is characterized in that, also comprise the operation system information of obtaining test platform before described step G;
In described step G, also comprise: in journal file, write described operation system information.
16. the method for claim 1, is characterized in that, while finding equipment to be tested in described steps A, also comprise: the information that records each equipment on device path to be tested and described path;
In described step G, also comprise: to the information that writes each equipment on described device path to be tested and described path in journal file.
17. the method for claim 1, it is characterized in that, described step H specifically comprises: that calls that preset function drives to the Hub at described equipment to be tested place that end points sends standard obtains device descriptor order, judge whether to receive the response message that equipment to be tested returns, that equipment to be tested does not lose response, return to execution step C, otherwise equipment to be tested loses response, test finishes.
18. the method for claim 1, it is characterized in that, in described step F, when the unsuccessful former because improper generation of device processes of function call wrong, also comprise: whether the mistake that judges the improper generation of described device processes can be ignored, be to return to execution step H, otherwise generate the second error code, according to described the second error code, error description is set, execution step G.
19. methods as claimed in claim 14, it is characterized in that, in described step F, when the unsuccessful former because improper generation of device processes of function call wrong, also comprise: judging whether described system mistake code is the second default error code, is to reopen equipment to be tested, return to execution step D, otherwise generate the second error code, according to described the second error code, error description is set, execution step G.
20. the method for claim 1, is characterized in that,
Between described step B and described step C, also comprise: from described configuration information, select one not by used detecting information, using the detecting information of selecting as current detecting information;
In described step e, when the data returned when equipment are legal, also comprise: judge whether to complete the whole tests in described configuration information, to test end, otherwise from described configuration information, select one not by used detecting information, using the detecting information of selecting as current detecting information, return to execution step C;
In described step F, when the unsuccessful reason of function call is not during by the improper generation of device processes wrong, also comprise: judge whether to complete the whole tests in described configuration information, to test end, otherwise from described configuration information, select one not by used detecting information, using the detecting information of selecting as current detecting information, return to execution step C;
In described step H, when equipment to be tested does not lose response, also comprise: judge whether to complete the whole tests in described configuration information, to test end, otherwise from described configuration information, select one not by used detecting information, using the detecting information of selecting as current detecting information, return to execution step C.
CN201310264252.0A 2013-06-28 2013-06-28 Detection method of nonstandard USB protocol compatibility Expired - Fee Related CN103309787B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310264252.0A CN103309787B (en) 2013-06-28 2013-06-28 Detection method of nonstandard USB protocol compatibility

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310264252.0A CN103309787B (en) 2013-06-28 2013-06-28 Detection method of nonstandard USB protocol compatibility

Publications (2)

Publication Number Publication Date
CN103309787A CN103309787A (en) 2013-09-18
CN103309787B true CN103309787B (en) 2014-12-10

Family

ID=49135037

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310264252.0A Expired - Fee Related CN103309787B (en) 2013-06-28 2013-06-28 Detection method of nonstandard USB protocol compatibility

Country Status (1)

Country Link
CN (1) CN103309787B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103812607A (en) * 2013-12-04 2014-05-21 安徽虹庄微电子有限公司 Method for simulating packet errors in transmission process of USB 3.0
CN109257155B (en) * 2018-11-21 2021-01-05 南京安讯科技有限责任公司 Cluster processing optimization system for 3G and 4G mobile phone internet access signaling
CN113252373B (en) * 2021-04-07 2024-06-21 深圳市飞易通科技有限公司 Bluetooth printer testing method and system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1633198A (en) * 2004-12-31 2005-06-29 大唐微电子技术有限公司 A method and system for compatibility test of subscriber identification module tool kit card
CN101727374A (en) * 2008-10-15 2010-06-09 英业达股份有限公司 Method for testing PS/2 interface
CN102117238A (en) * 2010-01-05 2011-07-06 上海硅知识产权交易中心有限公司 Universal method and platform for verifying compatibility between intellectual property (IP) core and advanced microcontroller bus architecture (AMBA) bus interface

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020104046A1 (en) * 2001-01-31 2002-08-01 Mohammad Saleem C. Method and system for automatically testing a universal serial bus peripheral design
KR100684548B1 (en) * 2005-11-16 2007-02-20 엠텍비젼 주식회사 Self function testable system-on-chip and method for the function test

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1633198A (en) * 2004-12-31 2005-06-29 大唐微电子技术有限公司 A method and system for compatibility test of subscriber identification module tool kit card
CN101727374A (en) * 2008-10-15 2010-06-09 英业达股份有限公司 Method for testing PS/2 interface
CN102117238A (en) * 2010-01-05 2011-07-06 上海硅知识产权交易中心有限公司 Universal method and platform for verifying compatibility between intellectual property (IP) core and advanced microcontroller bus architecture (AMBA) bus interface

Also Published As

Publication number Publication date
CN103309787A (en) 2013-09-18

Similar Documents

Publication Publication Date Title
CN103309709B (en) A kind of firmware upgrade method, device and communication equipment
TWI470420B (en) Dubugging method and computer system using the smae
EP2650781A2 (en) Method for detecting hardware
CN103309787B (en) Detection method of nonstandard USB protocol compatibility
CN102446141B (en) Device and method for realizing write protection control
CN109739769A (en) BOOTROM loads method for automatically testing functions and device
US9720855B2 (en) Virtual device based systems with access to parts other than data storage elements through the virtual device
CN102916741A (en) Optical module hardware online test method
CN108768785B (en) Method and device for building intelligent network card test environment
CN111638916B (en) General android mobile terminal driving system and method for data forensics
WO2018099255A1 (en) Method, device and system for configuring transfer mode and computer storage medium
US7246038B2 (en) Method, system, and article of manufacture for running diagnostics related to a device
CN106484719A (en) A kind of method of extended mobile phone storage and terminal
CN112380078B (en) USB equipment communication test method and test device
CN104750537A (en) Test case execution method and device
CN102305906B (en) Chip testing method and device
CN110990260B (en) Automatic verification method and system for Extended APIC option function
CN110673894A (en) Automatic loading method for BOB module ED of home gateway
CN106776186B (en) Method and system for debugging CPU running state under multi-CPU architecture
CN104615387A (en) Vehicle-mounted equipment based on XPE system and design method of vehicle-mounted equipment
US10922023B2 (en) Method for accessing code SRAM and electronic device
CN112182586B (en) MCU read-write protection test method, device and system
CN111063387B (en) Method, device and equipment for testing performance of solid state disk and storage medium
CN115373922A (en) Device, method, terminal and medium for automatically testing SMR hard disks of different manufacturers
CN110737483B (en) Signaling and data transmission method based on Windows USB MassStorage class

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20141210