A diagnostic protocol scanning method and diagnostic protocol scanner
Patent Information
- Application Number
- CN202211286635.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-20
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2042-10-20
AI Technical Summary
[0002]随着科学技术的发展,对于车辆安全的要求越来越高,目前主要是对整车或者单个电子控制单元(ECU)通过控制器局域网络(CAN)总线进行诊断信息安全测试,但由于测试人员没有权限或者需要纯黑盒渗透测试时,无法获知ECU中实现了的全部诊断服务功能和数据等的情况,会导致一些规范中定义过且不常用的和主机厂自定义的服务功能被漏测,从而导致诊断信息安全测试不全面,其中可能会漏掉一些可以非授权使用的会威胁到车辆信息安全的诊断服务功能开放给了公众,最终可能被恶意攻击者使用从而导致人员伤亡等情况
[0063]本申请所提供的诊断协议扫描方法,通过获取各功能之间的逻辑关系,并根据逻辑关系以及功能编号范围确定各功能的功能编码,遍历所有功能范围并输出全部扫描结果,提供了一种一键自动化的扫描的机制,并将所有扫描结果输出,结果清晰明了,且很好的给诊断信息安全测试人员搜集出了全部需要测试的诊断信息,使得测试十分全面,并降低了工作人员的工作量,提高了安全性。
Smart Images

Figure CN115629972B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of diagnostic information scanning, and in particular to a diagnostic protocol scanning method and a diagnostic protocol scanner. Background Technology
[0002] With the development of science and technology, the requirements for vehicle safety are becoming increasingly stringent. Currently, diagnostic information security testing is mainly conducted on the entire vehicle or individual electronic control units (ECUs) via the Controller Area Network (CAN) bus. However, due to the lack of authorization for testers or the need for pure black-box penetration testing, it is impossible to obtain all the diagnostic service functions and data implemented in the ECU. This can lead to the omission of some service functions that are defined in the specifications but are not commonly used, as well as those customized by the OEM. Consequently, the diagnostic information security testing is incomplete. This may result in the omission of some diagnostic service functions that can be used without authorization and threaten vehicle information security, which are open to the public and could ultimately be used by malicious attackers, leading to casualties or other situations. Summary of the Invention
[0003] The purpose of this application is to provide a diagnostic protocol scanning method and a diagnostic protocol scanner, which can obtain the logical relationship between various functions, determine the function code of each function according to the logical relationship and the function number range, traverse all function code ranges and output all scanning results, which can better collect all the diagnostic information that needs to be tested for diagnostic information security testers, making the test very comprehensive, reducing the workload of staff and improving security.
[0004] To address the aforementioned technical problems, this application provides a diagnostic protocol scanning method, comprising:
[0005] Obtain the logical relationships between the various functions;
[0006] The function code corresponding to each function is determined based on the logical relationship and the function number range corresponding to each function.
[0007] Determine whether the function codes corresponding to all functions have been determined;
[0008] If not, return to the step of determining the function code corresponding to each function based on the logical relationship and the function number range corresponding to each function;
[0009] If so, the function code corresponding to the last function will be output as the final scan result. The function code corresponding to the last function also includes the function codes corresponding to the other functions.
[0010] Preferably, all functions include, in sequence: diagnostic ID scanning function, SID scanning function, SF scanning function, and DID scanning function;
[0011] The logical relationship is that the function code determined by the previous scan function serves as the scan range for the current function.
[0012] The diagnostic ID scanning function scans both the function addressing ID and the physical request ID.
[0013] Preferably, when the current function is the diagnostic scan ID function, the function code corresponding to each function is determined based on the logical relationship and the function number range corresponding to each function, including:
[0014] The function code corresponding to the diagnostic ID scanning function is determined based on the range of function addressing ID and physical request ID;
[0015] The function code corresponding to the diagnostic ID scanning function, determined based on the function addressing range and the physical request ID range, includes:
[0016] Control function addressing ID constructs a request frame;
[0017] Get the physical response ID of the response function addressing ID;
[0018] Construct a request frame by randomly traversing the range of physical request IDs;
[0019] Get the physical response ID that responds to the physical request ID;
[0020] Save the function addressing ID and physical request ID with the same physical response ID as the diagnostic ID function code;
[0021] If the physical request ID traversal is complete, proceed to the next function test.
[0022] Preferably, when the current function is SID scanning, determining the function code corresponding to each function based on logical relationships and the function number range corresponding to each function includes:
[0023] The function code corresponding to the SID scanning function is determined based on the diagnostic ID function code and the SID function number range;
[0024] The function code corresponding to the SID scanning function is determined based on the diagnostic ID function code and the SID function number range, including:
[0025] Obtain the range of physical request IDs corresponding to the diagnostic ID function code, and randomly traverse the range of physical request IDs and the range of SID function numbers to construct a request frame;
[0026] Obtain the corresponding physical response ID. If the message with the physical response ID is a positive response, store the SID function number corresponding to the physical response ID and the corresponding diagnostic ID function code into the SID function code.
[0027] If the physical response ID message is a negative response, then determine whether the NRC code of the negative response is the first preset value;
[0028] If so, return to the step of obtaining the physical request ID range corresponding to the diagnostic ID function code, and randomly traversing the range of physical request IDs and the range of SID function numbers to construct the request frame;
[0029] If not, return to the step of storing the SID function number corresponding to the physical response ID and the corresponding diagnostic ID function code into the SID function code;
[0030] Determine if the physical request IDs have been traversed completely;
[0031] If the traversal is not completed, return to the step of obtaining the physical request ID range corresponding to the diagnostic ID function code, and randomly traversing the physical request ID range and the SID function number range to construct the request frame.
[0032] If the traversal is complete, proceed to the next function test.
[0033] Preferably, when the current function is SF scanning, determining the function code corresponding to each function based on logical relationships and the function number range corresponding to each function includes:
[0034] The SF function code corresponding to the SF scanning function is determined based on the SID function code and the SF function number range;
[0035] Based on the SID function code and the SF function number range, the SF function code corresponding to the SF scanning function is determined as follows:
[0036] Randomly traverse the range of physical request IDs in the SID function code, retrieve the physical request IDs and the corresponding SIDs;
[0037] Construct a request frame by randomly traversing the SF function number range using the physical request ID and its corresponding SID.
[0038] Obtain the corresponding physical response ID. If the message with the physical response ID is a positive response, store the SF function number and the corresponding SID function code corresponding to the physical response ID into the SF function code.
[0039] If the message with the physical response ID is a negative response, then determine whether the NRC code of the negative response is the second preset value;
[0040] If so, return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and the corresponding SID;
[0041] If not, return to the step of storing the SF function number and the corresponding SID function code corresponding to the physical response ID into the SF function code;
[0042] Determine if the SID traversal is complete;
[0043] If not completed, return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and the corresponding SID;
[0044] If completed, then determine whether the physical request ID has been traversed.
[0045] If the physical request ID traversal is not completed, return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and the corresponding SID;
[0046] If the physical request ID traversal is complete, proceed to the next function test.
[0047] Preferably, when the current function is the DID scanning function, which is the last function, the function code corresponding to each function is determined based on the logical relationship and the function number range corresponding to each function, including:
[0048] The DID function code corresponding to the DID scanning function is determined based on the SF function code and the function number range corresponding to the DID scanning function.
[0049] Based on the SF function code and the corresponding function number range of the DID scanning function, the DID function code corresponding to the DID scanning function is determined as follows:
[0050] Obtain the physical request ID range corresponding to the SF function code, and randomly traverse within the physical request ID range and the DID function number range to construct a request frame;
[0051] Obtain the corresponding physical response ID. If the message with the physical response ID is a positive response, store the DID function number corresponding to the physical response ID, its corresponding data, and the corresponding SF function code into the DID function code.
[0052] If the physical response ID message is a negative response, then determine whether the NRC code of the negative response is the third preset value;
[0053] If so, return to the step of obtaining the physical request ID range corresponding to the SF function code and randomly traversing within the physical request ID range and the DID function number range to construct the request frame;
[0054] If not, return to the step of storing the DID function number corresponding to the physical response ID, its corresponding data, and the corresponding SF function code into the DID function code;
[0055] Determine if the physical request IDs have been traversed completely;
[0056] If not completed, return to the step of obtaining the corresponding physical request ID range in the SF function code and randomly traversing within the physical request ID range and the DID function number range to construct the request frame;
[0057] If completed, proceed to the step of determining whether the function codes corresponding to all functions have been determined.
[0058] Preferably, the final scan results are displayed in a tree structure.
[0059] Preferably, the final scan result is output in JSON format.
[0060] Preferably, the function number range is either a default range or a user input range.
[0061] To address the aforementioned technical problems, this application also provides a diagnostic protocol scanner, including a memory for storing computer programs;
[0062] A processor is used to implement the steps of the diagnostic protocol scanning method described above when executing a computer program.
[0063] The diagnostic protocol scanning method provided in this application obtains the logical relationships between various functions, determines the function code of each function based on the logical relationships and function number range, traverses all function ranges and outputs all scan results, providing a one-click automated scanning mechanism, and outputs all scan results clearly. It also effectively collects all the diagnostic information that needs to be tested for diagnostic information security testers, making the test very comprehensive, reducing the workload of staff, and improving security.
[0064] The diagnostic protocol scanner provided in this application has the same beneficial effects as the diagnostic protocol scanning method described above. Attached Figure Description
[0065] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0066] Figure 1 This application provides a flowchart of a diagnostic protocol scanning method;
[0067] Figure 2 This application provides a schematic diagram of a diagnostic ID scanning function;
[0068] Figure 3 This application provides a schematic diagram of a SID scanning function;
[0069] Figure 4 This application provides a schematic diagram of an SF scanning function;
[0070] Figure 5 This application provides a schematic diagram of a DID scanning function;
[0071] Figure 6 This application provides a connection diagram for a diagnostic scanning device;
[0072] Figure 7 This application provides a flowchart of the overall operation of a diagnostic protocol scanner;
[0073] Figure 8 A structural diagram of a diagnostic protocol scanner provided in another embodiment of this application;
[0074] Figure 9 for Figure 8 A schematic diagram of the function buttons on the display screen of the diagnostic protocol scanner. Detailed Implementation
[0075] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0076] The core of this application is to provide a diagnostic protocol scanning method and a diagnostic protocol scanner, which is used to obtain the logical relationship between various functions, determine the function code of each function according to the logical relationship and the function number range, traverse all function code ranges and output all scanning results. This can better collect all the diagnostic information that needs to be tested for diagnostic information security testers, making the test very comprehensive, reducing the workload of staff and improving security.
[0077] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0078] This application provides a diagnostic protocol scanning method, such as... Figure 1 , Figure 1 A flowchart of a diagnostic protocol scanning method is provided for embodiments of this application; the method includes:
[0079] S10: Obtain the logical relationships between the functions.
[0080] Diagnostic scans are performed on different functions, which may include, but are not limited to, diagnostic ID scanning, service ID (SID) scanning, sub-function (SF) scanning, and data ID (DID) scanning. Each function may include one or more of these functions during scanning. This application embodiment does not impose specific limitations on these functions. Furthermore, this application does not limit the above logical relationships; the logical relationship can be one-way or bidirectional data transmission between functions, or control of the scanning range between functions. Different functions have certain logical relationships. It should be noted that this application embodiment does not limit the number of included functions or the relationships between them. Furthermore, this application embodiment does not limit the specific manner in which the logical relationships exist.
[0081] S11: Determine the function code corresponding to each function based on the logical relationship and the function number range corresponding to each function.
[0082] When scanning each function, each function should have a corresponding scannable range. It should be noted that this embodiment does not limit the size of the scan range or the data it contains, nor does it limit the method of obtaining the scan range; it can be initially set by the system or manually entered by the user, etc. Furthermore, this embodiment does not limit the method of obtaining the function code corresponding to each function; different functions can have different function code ranges. For example, the function number range corresponding to the SID scanning function is the SID function number range, the function number range corresponding to the SF scanning function is the SF function number range, and the function number range corresponding to the DID scanning function is the DID function number range. Additionally, this embodiment does not limit the scanning order of each function.
[0083] As a preferred approach, a request frame for entering extended session mode can be constructed and sent using the logical relationships between functions and the function numbers within the corresponding function number range. The function number is then determined as a function code based on the response status of the physical response ID of the response request frame. The above steps are performed for each function number within the function number range through a traversal process to determine whether it is to be saved as a function code. Alternatively, other methods can be used to determine the function code corresponding to each function. This application does not impose any specific limitations on this embodiment. Taking the diagnostic ID scanning function as an example, the logical relationship of the diagnostic ID scanning function is as follows: the scanning range of the diagnostic ID scanning function is the function addressing ID. Using the function addressing ID, such as 0x7DF, a request frame to enter the extended session mode is constructed and sent. The extended session mode is UDS 1003, and the request frame is a CAN frame, i.e., 7DF#0210030000000000; the physical response ID of the response request frame is recorded. The function number range of the diagnostic ID scanning function is the physical request ID range. Using the physical request IDs in the physical request ID range, a request frame to enter the extended session mode is constructed and sent. The request frame is a CAN frame, i.e., $ReqID#02100300000000000; the physical response ID of the response CAN frame is recorded, and each physical request ID in the physical request ID range of the response CAN frame is recorded by traversal. The function addressing ID and physical request addressing ID with a common physical response ID are integrated into a pair and determined as the function code corresponding to the diagnostic ID scanning function.
[0084] S12: Determine whether the function codes corresponding to all functions have been determined.
[0085] If not, return to the step of determining the function code corresponding to each function based on the logical relationship and the function number range corresponding to each function;
[0086] It should be noted that a comprehensive scan must be performed for each function to ensure that the corresponding function codes for all functions can be determined. Because all functions of the ECU need to be tested, it is necessary to determine whether the corresponding function codes for all functions have been detected. If the testing is incomplete, the testing continues; if the testing is complete, the corresponding function codes for each function can be saved and output as needed.
[0087] S13: If so, the function code corresponding to the last function will be output as the final scan result.
[0088] It should be noted that if all functions are scanned sequentially, the function code corresponding to the last function should also include the function codes corresponding to all other functions. This embodiment does not limit the storage format of each function code or the output structure.
[0089] As can be seen, the diagnostic protocol scanning method provided in this application, by obtaining the logical relationships between various functions, determining the function codes of each function based on the logical relationships and function number ranges, traversing all function code ranges, and outputting all scan results, can better collect all the diagnostic information that needs to be tested for diagnostic information security testers, making the test very comprehensive, reducing the workload of staff, and improving security.
[0090] Based on the above embodiments, this application provides a preferred embodiment in which the diagnostic scan of the ECU includes, in sequence: diagnostic ID scan function, SID scan function, SF scan function, and DID scan function. The logical relationship is that the function code determined by the previous scan function is used as the scan range of the current function.
[0091] It should be noted that all functions can be defined as including, in sequence, diagnostic ID scanning, SID scanning, SF scanning, and DID scanning, with the scanning order from front to back. The diagnostic ID scanning function is the first function, and the DID scanning function is the last function. Since the diagnostic ID scanning function is the first function, it cannot obtain the function code of the previous scanning function; therefore, the logical relationship between the diagnostic ID scanning function and the previous function is not limited. The scanning range of the diagnostic ID scanning function can be the function addressing ID. The DID function is the last function. Its function code can include the DID's own function number and the data corresponding to that function number, as well as the function codes corresponding to other functions. Each function's function code, in addition to the information mentioned above, can also contain other information, such as the function codes of other functions. Each function code can include the function code of its previous function, and by the time of the last function, its function code includes the function codes of all functions.
[0092] As can be seen, by scanning the included functions sequentially and traversing them, and taking the function code determined by the previous function as the scanning range of the current function, it is only necessary to output the function code and corresponding data of the last function. Furthermore, it will not omit the output of the function code of a certain function or output the function code corresponding to a certain function repeatedly, thus improving the comprehensiveness and accuracy of the scan.
[0093] Based on the above embodiments, this application provides a preferred embodiment in which, when the current function is the diagnostic scan ID function, the function code corresponding to each function is determined according to the logical relationship and the function number range corresponding to each function, including:
[0094] The function code corresponding to the diagnostic ID scanning function is determined based on the range of function addressing ID and physical request ID;
[0095] like Figure 2 As shown, Figure 2This application provides a schematic diagram of a diagnostic ID scanning function, in which the function code corresponding to the diagnostic ID scanning function is determined based on the function addressing range and the physical request ID range, including:
[0096] S20: Control Function Addressing ID Construction Request Frame;
[0097] It should be noted that the function addressing ID is a fixed value, which can be 0x7DF. The constructed request frame can be a CAN frame. The request frame is constructed through the CAN frame, i.e., 7DF#0210030000000000.
[0098] S21: Obtain the physical response ID of the response function addressing ID;
[0099] It should be noted that these physical response IDs and function addressing IDs are corresponding.
[0100] S22: Construct a request frame by randomly traversing the range of physical request IDs;
[0101] It should be noted that before traversing, it is necessary to first determine whether the user has entered a range of physical request IDs. If no input is made, the variable value of the physical request ID range is set to a preset value. However, this embodiment does not limit the specific value of the preset value; the range can be set to be large or small, as long as it ensures comprehensive scanning. If the user has entered a variable value, traversal can proceed directly.
[0102] S23: Obtain the physical response ID of the physical request ID;
[0103] It should be noted that these physical response IDs correspond to physical request IDs. Physical responses may include, but are not limited to, positive and negative responses.
[0104] S24: Save the function addressing ID and physical request ID with the same physical response ID as the diagnostic ID function code;
[0105] It should be noted that the function addressing ID and physical request addressing ID with a common physical response ID are integrated into a pair. The result is then passed as a parameter to the SID scanning engine. The diagnostic ID function encoding may include, but is not limited to, the function addressing ID, physical request ID, and physical response ID.
[0106] S25: If the physical request ID traversal is complete, proceed to the next function detection.
[0107] As can be seen, by using the diagnostic ID scan function to perform a comprehensive scan of the ECU, a more complete and accurate detection can be achieved.
[0108] Based on the above embodiments, this application provides a preferred embodiment in which, when the current function is SID scanning, the function code corresponding to each function is determined according to the logical relationship and the function number range corresponding to each function, including:
[0109] The function code corresponding to the SID scanning function is determined based on the diagnostic ID function code and the SID function number range;
[0110] like Figure 3 As shown, Figure 3 This application provides a schematic diagram of a SID scanning function, wherein the function code corresponding to the SID scanning function is determined based on the diagnostic ID function code and the SID function number range, including:
[0111] S30: Obtain the physical request ID range corresponding to the diagnostic ID function code, and randomly traverse the physical request ID range and the SID function number range to construct a request frame;
[0112] S31: Obtain the corresponding physical response ID. If the message of the physical response ID is a positive response, store the SID function number corresponding to the physical response ID and the corresponding diagnostic ID function code into the SID function code.
[0113] S32: If the message of the physical response ID is a negative response, then determine whether the negative response code (NRC code) of the negative response is the first preset value;
[0114] S33: If so, return the step of obtaining the physical request ID range corresponding to the diagnostic ID function code and randomly traversing the range of physical request ID and SID function number to construct the request frame;
[0115] S34: If not, return to the step of storing the SID function number corresponding to the physical response ID and the corresponding diagnostic ID function code into the SID function code;
[0116] S35: Determine if the physical request ID traversal is complete;
[0117] If the traversal is not complete;
[0118] S36: Then return the step of obtaining the physical request ID range corresponding to the diagnostic ID function code, and randomly traversing the physical request ID range and the SID function number range to construct the request frame.
[0119] If the traversal is complete;
[0120] S37: Then proceed to the next function test.
[0121] It should be noted that the results of the diagnostic ID scanning function are output to the SID scan, where the request frame may be, but is not limited to, a CAN frame, and the physical response may include, but is not limited to, positive and negative responses. This application embodiment does not limit the specific value of the range of NRC codes for negative responses.
[0122] When the current function is SID scanning, and its previous function is diagnostic ID scanning, the logical relationship corresponding to the SID scanning function is the diagnostic ID function code corresponding to the diagnostic ID scanning function. Its corresponding number range is the SID function number range. The physical request ID range in the diagnostic ID function code is obtained, and a request frame is constructed by randomly traversing the physical request ID range and the SID function number range. The format of this frame is: $PhyReqID#0*${SID}************ and
[0123] $PhyReqID#1***${SID}**********; Retrieves the physical response ID returned by the extended session mode, and determines whether the message containing that physical response ID is a positive or negative response. If the physical response ID is positive, it is represented by: $PhyRespID#0*${SID+0x40}************
[0124] When $PhyRespID#1***${SID+0x40}**********, the SID function number corresponding to the physical response ID and the corresponding diagnostic ID function code are stored in the SID function code, and the process proceeds to step S35. When the physical response ID check message is a negative response, i.e., $PhyRespID#037F${SID}${NRC}********, it is necessary to determine whether the NRC value in the negative response is the first preset value, which is generally 0x11. If the NRC value is 0x11, the process returns to step S30, indicating that the SID corresponding to the negative response does not meet the requirements, so it is not saved to the SID function code. If the NRC value is not 0x11, it indicates that the SID corresponding to the negative response and the SID corresponding to the positive response both meet the requirements, and the process returns to step S31. The results that need to be saved are saved according to the above requirements, and the process proceeds to step S35. At the same time, the function code corresponding to the current function needs to save the function code corresponding to the previous function. To determine if the traversal is complete, check if all physical request IDs in the physical request ID range can construct a request frame with the SIDs in the SID function number range. If the traversal is complete, all corresponding SIDs in the corresponding physical request ID range are found, thus ending the SID scanning function and proceeding to the next function scan, i.e., step S37. If the traversal is not complete, return to step S31 until all physical request IDs in all physical request ID ranges have been traversed, thus finding all SIDs in the SID scanning function.
[0125] As can be seen, implementing the SID scanning function through traversal can obtain more comprehensive service ID information, and better avoid over-checking or under-checking by the testing personnel.
[0126] Based on the above embodiments, this application provides a preferred embodiment in which, when the current function is SF scanning, the function code corresponding to each function is determined according to the logical relationship and the function number range corresponding to each function, including:
[0127] The SF function code corresponding to the SF scanning function is determined based on the SID function code and the SF function number range;
[0128] like Figure 4 As shown, Figure 4 This application provides a schematic diagram of an SF scanning function. The SF function code corresponding to the SF scanning function is determined based on the SID function code and the SF function number range, including:
[0129] S40: Randomly traverse the range of physical request IDs in the SID function code, retrieve the physical request IDs and the corresponding SIDs;
[0130] S41: Construct a request frame by randomly traversing the SF function number range using the physical request ID and its corresponding SID;
[0131] It should be noted that the request frame can be a CAN frame, and the SF function number range can be manually entered by the user or a range set by the system. This embodiment does not impose specific limitations on the variable values of the SF function number range.
[0132] S42: Obtain the corresponding physical response ID. If the message with the physical response ID is a positive response, store the SF function number and the corresponding SID function code corresponding to the physical response ID into the SF function code.
[0133] S43: If the message with the physical response ID is a negative response, then determine whether the NRC code of the negative response is the second preset value;
[0134] It should be noted that the embodiments of this application do not limit the specific preset value of the NRC code, and the NRC code can also be limited to a certain range.
[0135] S44: If so, return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and the corresponding SID;
[0136] S45: If not, return to the step of storing the SF function number corresponding to the physical response ID and the corresponding SID function code into the SF function code;
[0137] S46: Determine if the SID traversal is complete;
[0138] If not completed;
[0139] S47: Then return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and the corresponding SID;
[0140] If completed;
[0141] S48: Then determine whether the physical request ID has been traversed completely;
[0142] If the physical request ID traversal is not complete;
[0143] S49: Then return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and the corresponding SID;
[0144] If the physical request ID traversal is complete;
[0145] S50: Then proceed to the next function test.
[0146] Here, SF is a sub-function under SID, and its corresponding logical relationship is the SID function code corresponding to the SID scanning function. Its corresponding function number range is the SID function number range. However, the corresponding SF cannot be found simply by using the physical request ID within the physical request ID range of the SID function code. Therefore, we first find the SID corresponding to each physical request ID within the physical request ID range through traversal. Then, we construct a request frame by traversing the SF function number range using the physical request ID and its corresponding SIDs. The format of this request frame is: $PhyReqID#0*${SID}${SF}********** and
[0147] $PhyReqID#1***${SID}${SF}********. Extended session mode returns the corresponding physical response ID. When the physical response ID check message is a positive response $PhyRespID#0*${SID+0x40}${SF}********* and...
[0148] If $PhyRespID#1***${SID+0x40}${SF}********, it proves that the SF corresponding to the current physical response ID is under this SID. Therefore, this SF, along with the corresponding physical response ID and SID, is stored in the SF's function code. If the check message for the corresponding physical response ID is a negative response, that is...
[0149] For $PhyRespID#037F${SID}${NRC}********, it is also necessary to check whether the NRC value in the negative response is the second preset value, which is generally 0x12. If it is, it proves that this SF is not in this SID, and return to step S40 to check the next SID. If the NRC value is not 0x12, it proves that this SF is still under this SID, and return to step S42 to save it in the same way as above, and enter step S46 to check whether the SF has been traversed. If it has not been completed, select another SID to traverse its own range and enter step S40. If the traversal is completed, enter step S48 to check whether the physical request ID in the physical request ID range has been traversed to its corresponding SID range. If the traversal is completed, proceed to the next function test, that is, enter step S50. If the traversal is not completed, continue to select physical request ID and its corresponding SID, that is, return to step S40.
[0150] As can be seen, completing the SF scanning function through traversal can more comprehensively scan its sub-functions, avoid missing sub-function information, and improve the accuracy and completeness of the scan.
[0151] Based on the above embodiments, this application provides a preferred embodiment in which, when the current function is the DID scanning function, and the DID scanning function is the last function, the function code corresponding to each function is determined according to the logical relationship and the function number range corresponding to each function, including:
[0152] The DID function code corresponding to the DID scanning function is determined based on the SF function code and the function number range corresponding to the DID scanning function.
[0153] like Figure 5 As shown, Figure 5 This application provides a schematic diagram of a DID scanning function. The DID function code corresponding to the DID scanning function is determined based on the SF function code and the corresponding function number range, including:
[0154] S51: Obtain the physical request ID range corresponding to the SF function code, and randomly traverse within the physical request ID range and the DID function number range to construct a request frame;
[0155] It should be noted that the request frame can be a CAN frame, and the SF function number range can be manually entered by the user or a range set by the system. This embodiment does not impose specific limitations on the variable values of the SF function number range.
[0156] S52: Obtain the corresponding physical response ID. If the message of the physical response ID is a positive response, store the DID function number corresponding to the physical response ID, its corresponding data, and the corresponding SF function code into the DID function code.
[0157] S53: If the message with the physical response ID is a negative response, then determine whether the NRC code of the negative response is the third preset value;
[0158] It should be noted that the embodiments of this application do not limit the specific preset value of the NRC code, and the NRC code can also be limited to a certain range.
[0159] S54: If so, return to the step of obtaining the physical request ID range corresponding to the SF function code and randomly traversing within the physical request ID range and the DID function number range to construct the request frame;
[0160] S55: If not, return to the step of storing the DID function number corresponding to the physical response ID, its corresponding data, and the corresponding SF function code into the DID function code;
[0161] S56: Determine if the physical request ID has been traversed completely;
[0162] If not completed;
[0163] S57: Then return to the step of obtaining the physical request ID range corresponding to the SF function code and randomly traversing within the physical request ID range and the DID function number range to construct the request frame;
[0164] If completed;
[0165] S58: Then proceed to the step of determining whether the function codes corresponding to all functions have been determined.
[0166] It should be noted that the DID scanning function is the last function, and its corresponding logical relationship is the SF function code corresponding to the SF scanning function. The function number range corresponding to the DID scanning function is the DID function number range. It constructs a request frame by obtaining each physical request ID in the physical request ID range of the SF function code and combining it with the DID in the DID function number range. The format of this request frame is: $PhyReqID#0322${DID}********. Similarly, for the physical response ID returned by the extended session mode, when the message is checked and it is a positive response, $PhyRespID#0*62${DID}******** and $PhyRespID#1***62$ are returned. When {DID}******, these DIDs correspond to this physical request ID. The DID function number corresponding to the physical response ID, the data corresponding to these function numbers, and the corresponding SF function code are saved in the DID function code. Similarly, when checking a negative response, its NRC value is checked to see if it is the third preset value, which is generally 0x31. If it is, return to step S51 to judge the next DID. If not, proceed to step S52, save the data corresponding to this DID function number and the corresponding SF function code in the above manner, and proceed to step S56. Determine if the physical request IDs have been traversed. If not, return to step S51 to select the next physical request ID and DID to construct a request frame. If the traversal is complete, proceed to step S58, determine that the scanning function has ended, and proceed to step S12. The DID function code should include: function request ID, each physical request ID, each physical response ID, the function number of the SID, the SF function number, the DID function number, and their corresponding data.
[0167] As can be seen, by scanning the included functions sequentially and traversing them, and taking the function code determined by the previous function as the scanning range of the current function, only the function code and corresponding data corresponding to the last function need to be output. Furthermore, the function code of a certain function will not be omitted or the function code corresponding to a certain function will be output repeatedly, thus improving the comprehensiveness and accuracy of the scan.
[0168] Based on the above embodiments, this application provides a preferred embodiment in which the final scanning results are displayed in a tree structure.
[0169] Displaying the final scan results using a tree structure makes the results clearer and more understandable, and also provides better scalability. However, the embodiments of this application are not limited to using only a tree structure; different structures can be used to display the final scan results depending on the situation.
[0170] Based on the above embodiments, this application provides a preferred embodiment in which the final scan result is output in JSON format.
[0171] Outputting data in JSON format is more concise and clear than other formats. However, this application embodiment is not limited to using only JSON format, and other more suitable output formats can be used according to the actual situation.
[0172] This application also provides an embodiment of an application scenario, in which the above-described diagnostic protocol scanning method is applied to a testing machine, such as... Figure 6 As shown, Figure 6 This application provides a diagnostic scanning device connection diagram. The testing unit connects directly to a single ECU via a converter (PCAN) through a CAN bus, or it connects to the entire vehicle via an on-board diagnostic (OBD) interface. This embodiment is not limited to connecting only a single ECU or all ECUs of the vehicle; it can also isolate ECUs that are not intended for testing and connect to only a subset of ECUs.
[0173] A specific example is when it is connected to the vehicle;
[0174] Step 1: Connect the DB9 male connector of the PCAN device to the DB9 female to OBD male adapter cable, then connect the OBD male connector directly to the OBD female connector of the vehicle, and then perform a one-key scan.
[0175] Step 2: Perform a diagnostic ID scan and save the results as {"ECU1": [["0x7DF", "0X732", "0X73A"]], "ECU2": [["", "0X712", "0X71A"]]}. This indicates that ECU1's functional addressing ID is 0x7DF, its physical request ID is 0x732, and its physical response ID is 0x73A. The same applies to ECU2, but ECU2 does not have a functional addressing ID here.
[0176] Step 3: Using the results from Step 2, perform a SID scan. It will first scan the SF with SID 0x10, then scan all specified SIDs individually under each SF of service 10, and save the results as {"ECU1": [["0x7DF", "0x732", "0x73A"], {"0x01": {"0x10", "0x11", "0x27"}, "0x03": {"0x10", "0x11", "0x27"}}] The expression "ECU2": [["", "0X712", "0X71A"], {"0x01": {"0x10", "0x11", "0x27"}, "0x03": {"0x10", "0x11", "0x27"}}]} indicates that when ECU1's service SF is 0x01, its SIDs are 0x10, 0x11, and 0x27; when its service SF is 0x03, its SIDs are 0x10, 0x11, and 0x27. The same logic applies to ECU2 and other ECUs.
[0177] Step 4: Perform an SF scan using the results from Step 3, and save the results as {"ECU1": [["0x7DF", "0X732", "0X73A"], {"0x01": {"0x11": ["0x01", "0x03"], "0x27": ["0x01", "0x19"]}, "0x03": {"0x11": ["0x01", "0x03"], "0x27": ["0x01", "0x19"]}}], "ECU2": [["", "0X7 12”,"0X71A"],{"0x01":{"0x11":["0x01","0x03"],"0x27":["0x01","0x19"]},"0x03":{"0x11":["0x01","0x03"],"0x27":["0x01","0x19"]}}]},This means that when ECU1's SF in service 10 is 0x01, its service 11 has two SFs, 01 and 03, and its service 27 has two SFs, 01 and 19. The same analysis applies to other ECUs.
[0178] Step 5: Perform a DID scan using the results from Step 4, and save the results as follows: {"ECU1": [["0x7DF", "0X732", "0X73A"], {"0x01": {"0x11": ["0x01", "0x03"], "0x27": ["0x01", "0x19"]}, "0x03": {"0x11": ["0x01", "0x03"], "0x27": ["0x01", "0x19"]}}, ["0xF180": "2.01.09", "0xF190": "LFV6A24G9G0000003"]], "ECU2": [["", "0X712", "0X7 The code snippet `1A"], `{"0x01":{"0x11":["0x01","0x03"],"0x27":["0x01","0x19"]}`, `["0xF180":"1.01.01","0xF190":"LFV6A24G9G0000003"]]}` indicates that ECU1 has two DIDs set: 0xF180 and 0xF190. The value for 0xF180 is 2.01.09, and the value for 0xF190 is LFV6A24G9G0000003. The same logic applies to other ECUs.
[0179] The final output is as follows:
[0180]
[0181]
[0182]
[0183] If the specific example is a single ECU;
[0184] The specific example is the same as ECU1 when connecting to the whole vehicle. The scan ends after scanning the ECU, indicating that the result is also the result of a single ECU.
[0185] Specific examples are as follows:
[0186] Step 1: Connect the DB9 male connector of the PCAN terminal on the device to the DB9-open4 terminal, connect the CAN_H terminal on the terminal to the CAN_H pin of the ECU, and connect the CAN_L terminal on the terminal to the CAN_L pin of the ECU, then perform a one-click scan.
[0187] Step 2: First, perform a diagnostic ID scan and save the results as {"ECU1": [["0x7DF",,"0X732","0X73A"]]}, indicating that the ECU's functional addressing ID is 0x7DF, physical request ID is 0x732, and physical response ID is 0x73A.
[0188] Step 3: Using the results of Step 2, perform a SID scan. It will first scan the SF with SID 0x10, and then scan all specified SIDs separately under each SF of the 10 service. The results are saved as {"ECU1": [["0x7DF",,"0X732","0X73A"],,{"0x01":{"0x10","0x11","0x27"},"0x03":{"0x10","0x11","0x27"}}]}. This means that when the SF of the 10 service is 0x01, its SIDs are 0x10, 0x11, and 0x27. When the SF of the 10 service is 0x03, its SIDs are 0x10, 0x11, and 0x27.
[0189] Step 4: Perform an SF scan using the results from Step 3, and save the results as {"ECU1": [["0x7DF", "0X732", "0X73A"], {"0x01": {"0x11": ["0x01", "0x03"], "0x27": ["0x01", "0x19"]}, "0x03": {"0x11": ["0x01", "0x03"], "0x27": ["0x01", "0x19"]}}]}. This indicates that when the SF of the ECU in service 10 is 0x01, its service 11 has two SFs, 01 and 03, and its service 27 has two SFs, 01 and 19. The same analysis applies to the others.
[0190] Step 5: Perform a DID scan using the results from Step 4, and save the results as {"ECU1": [["0x7DF", "0X732", "0X73A"], {"0x01": {"0x11": ["0x01", "0x03"], "0x27": ["0x01", "0x19"]}, "0x03": {"0x11": ["0x01", "0x03"], "0x2 7":["0x01","0x19"]}},["0xF180":"2.01.09","0xF190":"LFV6A24G9G0000003"]]},This indicates that the ECU has two DIDs set, 0xF180 and 0xF190, with 0xF180 corresponding to the value 2.01.09 and 0xF190 corresponding to the value LFV6A24G9G0000003. The same logic applies to other values.
[0191] The final output is as follows:
[0192]
[0193] This application also provides a diagnostic protocol scanner, including a controller, a scanning module, and a display module, applied to the aforementioned diagnostic protocol scanning method. Figure 7 The above, Figure 7 This application provides a flowchart of the overall operation of a diagnostic protocol scanner. The specific workflow of the scanner is as follows: when the user clicks the one-click scan button, the engine starts working and sequentially performs diagnostic ID scan, SID scan, SF scan, DID scan, and SF scan. The operator can manually input the scan range corresponding to the diagnostic ID scan, SID scan, SF scan, DID scan, and SF scan, and only scan the range they want to scan.
[0194] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0195] Figure 8 A structural diagram of a diagnostic protocol scanner provided in another embodiment of this application is shown below. Figure 8 As shown, the diagnostic protocol scanner includes: a memory 20 for storing computer programs;
[0196] The processor 21 is configured to implement the steps of the diagnostic protocol scanning method as described in the above embodiments when executing a computer program.
[0197] The diagnostic protocol scanner provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers.
[0198] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an Artificial Intelligence (AI) processor, which is used to handle computational operations related to machine learning.
[0199] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 20 is used to store at least the following computer program 201, which, after being loaded and executed by the processor 21, is capable of implementing the relevant steps of the diagnostic protocol scanning method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, and the storage method may be temporary or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, function range numbers, function codes, etc.
[0200] In some embodiments, the diagnostic protocol scanner may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.
[0201] The display screen 22 includes, for example, Figure 9As shown, the interface includes: a one-click scan button, scan content description, structure display window, result file download, and function buttons for Diagnostic ID scan number range, SID scan number range, SF scan number range, and DID scan number range. The Diagnostic ID scan number range, SID scan number range, and SF scan number range are for manual input.
[0202] Those skilled in the art will understand that Figure 8 The structure shown does not constitute a limitation on diagnostic protocol scanners and may include more or fewer components than illustrated.
[0203] Finally, this application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the method embodiment described above.
[0204] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0205] The above provides a detailed description of a diagnostic protocol scanning method and a diagnostic protocol scanner provided in this application. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0206] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
Claims
1. A diagnostic protocol scanning method, characterized in that, include: Obtain the logical relationships between the various functions; The function code corresponding to each function is determined based on the logical relationship and the function number range corresponding to each function; Determine whether the function codes corresponding to all functions have been determined; If not, return to the step of determining the function code corresponding to each function based on the logical relationship and the function number range corresponding to each function; If so, the function code corresponding to the last function will be output as the final scan result. The function code corresponding to the last function also includes the function codes corresponding to the other functions. The functions include, in sequence: diagnostic ID scanning function, SID scanning function, SF scanning function, and DID scanning function; The logical relationship is that the function code determined by the previous scanning function serves as the scanning range of the current function; The scanning range of the diagnostic ID scanning function includes both function addressing ID and physical request ID. When the current function is the diagnostic ID scanning function, determining the function code corresponding to each function based on the logical relationship and the function number range corresponding to each function includes: The function code corresponding to the diagnostic ID scanning function is determined based on the range of the function addressing ID and the physical request ID. The step of determining the function code corresponding to the diagnostic ID scanning function based on the range of the function addressing ID and the physical request ID includes: Control function addressing ID constructs a request frame; Obtain the physical response ID in response to the function addressing ID; Construct a request frame by randomly traversing the physical request IDs within the range of physical request IDs; Obtain the physical response ID that responds to the physical request ID; The function addressing ID and the physical request ID with the same physical response ID are stored as diagnostic ID function codes; If the physical request ID traversal is complete, proceed to the next function detection; When the current function is the SID scanning function, determining the function code corresponding to each function based on the logical relationship and the function number range corresponding to each function includes: The function code corresponding to the SID scanning function is determined based on the diagnostic ID function code and the SID function number range; The step of determining the function code corresponding to the SID scanning function based on the diagnostic ID function code and the SID function number range includes: Obtain the physical request ID range corresponding to the diagnostic ID function code, and randomly traverse the physical request ID range and the SID function number range to construct a request frame; Obtain the corresponding physical response ID. If the message of the physical response ID is a positive response, store the SID function number corresponding to the physical response ID and the corresponding diagnostic ID function code into the SID function code. If the message of the physical response ID is a negative response, then determine whether the NRC code of the negative response is a first preset value; If so, return to the step of obtaining the physical request ID range corresponding to the diagnostic ID function code, and randomly traversing the range of physical request IDs and the range of SID function numbers to construct a request frame; If not, return to the step of storing the SID function number corresponding to the physical response ID and the corresponding diagnostic ID function code into the SID function code; Determine whether the physical request ID has been completely traversed; If the traversal is not completed, return to the step of obtaining the physical request ID range corresponding to the diagnostic ID function code, and randomly traversing the physical request ID range and the SID function number range to construct the request frame; If the traversal is complete, proceed to the next function test.
2. The diagnostic protocol scanning method according to claim 1, characterized in that, When the current function is the SF scanning function, determining the function code corresponding to each function based on the logical relationship and the function number range corresponding to each function includes: The SF function code corresponding to the SF scanning function is determined based on the SID function code and the SF function number range; The step of determining the SF function code corresponding to the SF scanning function based on the SID function code and the SF function number range includes: Randomly traverse the range of physical request IDs in the SID function code, retrieve the physical request IDs, and retrieve the SIDs corresponding to the physical request IDs. The request frame is constructed by randomly traversing the range of the SF function number using the physical request ID and its corresponding SID. Obtain the corresponding physical response ID. If the message of the physical response ID is a positive response, store the SF function number corresponding to the physical response ID and the corresponding SID function code into the SF function code. If the message of the physical response ID is a negative response, then determine whether the NRC code of the negative response is a second preset value; If so, return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and the corresponding SID; If not, return to the step of storing the SF function number corresponding to the physical response ID and the corresponding SID function code into the SF function code; Determine whether the SID traversal has been completed; If not completed, return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and the corresponding SID; If completed, then determine whether the physical request ID has been traversed completely; If the physical request ID traversal is not completed, return to the step of randomly traversing the range of physical request IDs in the SID function code to retrieve the physical request ID and retrieve the SID corresponding to the physical request ID; If the physical request ID traversal is complete, proceed to the next function detection.
3. The diagnostic protocol scanning method according to claim 2, characterized in that, When the current function is the DID scanning function, where the DID scanning function is the last function, determining the function code corresponding to each function based on the logical relationship and the function number range corresponding to each function includes: The DID function code corresponding to the DID scanning function is determined based on the SF function code and the function number range corresponding to the DID scanning function; The step of determining the DID function code corresponding to the DID scanning function based on the SF function code and the function number range corresponding to the DID scanning function includes: Obtain the physical request ID range corresponding to the SF function code, and randomly traverse within the physical request ID range and the DID function number range to construct a request frame; Obtain the corresponding physical response ID. If the message of the physical response ID is a positive response, store the DID function number corresponding to the physical response ID, its corresponding data, and the corresponding SF function code into the DID function code. If the message of the physical response ID is a negative response, then determine whether the NRC code of the negative response is a third preset value; If so, return to the step of obtaining the physical request ID range corresponding to the SF function code and randomly traversing within the physical request ID range and the DID function number range to construct a request frame; If not, return to the step of storing the DID function number corresponding to the physical response ID and its corresponding data and the corresponding SF function code into the DID function code; Determine whether the physical request ID has been completely traversed; If not completed, return to the step of obtaining the physical request ID range corresponding to the SF function code and randomly traversing within the physical request ID range and the DID function number range to construct a request frame; If completed, proceed to the step of determining whether the function codes corresponding to all functions have been determined.
4. The diagnostic protocol scanning method according to claim 1, characterized in that, The final scan results are displayed in a tree structure.
5. The diagnostic protocol scanning method according to claim 1, characterized in that, The final scan result is output in JSON format.
6. The diagnostic protocol scanning method according to any one of claims 1 to 5, characterized in that, The range of function numbers is either the default range or the range entered by the user.
7. A diagnostic protocol scanner, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the diagnostic protocol scanning method as described in any one of claims 1 to 6 when executing the computer program.