Data storage method based on two-dimensional array and related device
Patent Information
- Application Number
- CN202510773577.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2045-06-11
AI Technical Summary
[0002]目前,车辆诊断数据通常采用线性列表或非结构化存储,导致存储冗余,车辆诊断仪需要按ECU响应顺序进行存储解析诊断数据,并将解析结果直接显示出来,若诊断仪未对ECU响应的数据进行重新组合解析,可能会导致数据解析异常,从而,导致解析效率低下,因此,如何提升诊断数据的解析效率的问题亟待解决
[0022] As can be seen, the data storage method based on a two-dimensional array described in this application includes: sending a first request data frame to an ECU; receiving a first response data frame from the ECU in response to the first request data frame, and storing the first response data frame in a preset diagnostic UDS data array; determining whether the diagnostic UDS data array meets a first preset condition; if the first preset condition is met, it indicates that the target diagnostic data includes multiple frames of data, and determining the target valid data frame number based on the first response data frame; copying m bytes from the nth byte of the first response data frame to the 0th row of the preset two-dimensional array; sending a first flow control frame to the ECU; receiving the target diagnostic data based on the target valid data frame number, and storing the target diagnostic data... By storing the data in a two-dimensional array, when it is determined that the target diagnostic data contains multiple frames, the diagnostic device can store the data in the two-dimensional array according to the predetermined number and order of frames. This allows subsequent parsing of the multi-frame data to be performed in a unified and standardized manner, reducing errors and repeated verification time during the parsing process, thereby improving the overall parsing efficiency. In addition, compared with linear or unstructured storage, two-dimensional arrays are more organized in searching and managing multi-frame data, greatly improving the speed of data retrieval and processing. For example, when it is necessary to parse specific bytes of data in a frame, the corresponding row and column of the two-dimensional array can be quickly located, rather than searching in messy data, thereby improving the parsing efficiency of diagnostic data.
Smart Images

Figure CN120744184B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data storage technology, and in particular to a data storage method and related apparatus based on a two-dimensional array. Background Technology
[0002] Currently, vehicle diagnostic data is typically stored in linear lists or unstructured formats, leading to storage redundancy. Vehicle diagnostic tools need to store and parse diagnostic data according to the ECU response order and display the parsing results directly. If the diagnostic tool does not reassemble and parse the ECU response data, it may cause data parsing abnormalities, resulting in low parsing efficiency. Therefore, the problem of how to improve the parsing efficiency of diagnostic data urgently needs to be solved. Summary of the Invention
[0003] This application provides a data storage method and related apparatus based on a two-dimensional array, which improves the parsing efficiency of diagnostic data.
[0004] In a first aspect, embodiments of this application provide a data storage method based on a two-dimensional array, applied to a diagnostic device. The diagnostic device is connected to an ECU in a target vehicle, and the diagnostic device and the ECU transmit data using the UDS protocol. The method includes:
[0005] A first request data frame is sent to the ECU, the first request data frame being used to request target diagnostic data of the target vehicle;
[0006] The system receives a first response data frame from the ECU in response to the first request data frame, and stores the first response data frame in a preset diagnostic UDS data array; the diagnostic UDS data array is a one-dimensional array.
[0007] Determine whether the diagnostic UDS data array meets the first preset condition;
[0008] If the first preset condition is met, it means that the target diagnostic data includes multiple frames of data, and the number of valid target data frames is determined according to the first response data frame.
[0009] Starting from the nth byte of the first response data frame, copy m bytes to the 0th row of a preset two-dimensional array; where n is the starting number of valid bytes of the first response data frame, and m is the longest number of valid bytes in the UDS protocol;
[0010] A first flow control frame is sent to the ECU, the first flow control frame being used to control the ECU to start sending the target diagnostic data;
[0011] The target diagnostic data is received based on the number of valid target data frames, and the target diagnostic data is stored in the two-dimensional array.
[0012] Secondly, embodiments of this application provide a data storage device based on a two-dimensional array, applied to a diagnostic device. The diagnostic device is connected to an ECU in a target vehicle, and the diagnostic device and the ECU transmit data using the UDS protocol. The device includes: a request unit, a control unit, and a storage unit, wherein:
[0013] The request unit is used to send a first request data frame to the ECU, the first request data frame being used to request target diagnostic data of the target vehicle;
[0014] The control unit is configured to receive a first response data frame from the ECU in response to the first request data frame, and store the first response data frame in a preset diagnostic UDS data array; the diagnostic UDS data array is a one-dimensional array; determine whether the diagnostic UDS data array meets a first preset condition; if the first preset condition is met, it indicates that the target diagnostic data includes multiple frames of data, and determine the number of target valid data frames based on the first response data frame;
[0015] The storage unit is used to copy m bytes from the nth byte of the first response data frame to the 0th row of a preset two-dimensional array; where n is the starting number of valid data bytes in the first response data frame, and m is the longest number of valid data bytes in the UDS protocol.
[0016] The control unit is further configured to send a first flow control frame to the ECU, the first flow control frame being configured to control the ECU to start sending the target diagnostic data;
[0017] The storage unit is also used to receive the target diagnostic data based on the number of target valid data frames, and to store the target diagnostic data in the two-dimensional array.
[0018] Thirdly, embodiments of this application provide an electronic device, including: a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for performing the steps in the first aspect of embodiments of this application.
[0019] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform some or all of the steps described in the first aspect of embodiments of this application.
[0020] Fifthly, embodiments of this application provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program being operable to cause a computer to perform some or all of the steps described in the first aspect of embodiments of this application. The computer program product may be a software installation package.
[0021] Implementing this application will have the following beneficial effects:
[0022] As can be seen, the data storage method based on a two-dimensional array described in this application includes: sending a first request data frame to an ECU; receiving a first response data frame from the ECU in response to the first request data frame, and storing the first response data frame in a preset diagnostic UDS data array; determining whether the diagnostic UDS data array meets a first preset condition; if the first preset condition is met, it indicates that the target diagnostic data includes multiple frames of data, and determining the target valid data frame number based on the first response data frame; copying m bytes from the nth byte of the first response data frame to the 0th row of the preset two-dimensional array; sending a first flow control frame to the ECU; receiving the target diagnostic data based on the target valid data frame number, and storing the target diagnostic data... By storing the data in a two-dimensional array, when it is determined that the target diagnostic data contains multiple frames, the diagnostic device can store the data in the two-dimensional array according to the predetermined number and order of frames. This allows subsequent parsing of the multi-frame data to be performed in a unified and standardized manner, reducing errors and repeated verification time during the parsing process, thereby improving the overall parsing efficiency. In addition, compared with linear or unstructured storage, two-dimensional arrays are more organized in searching and managing multi-frame data, greatly improving the speed of data retrieval and processing. For example, when it is necessary to parse specific bytes of data in a frame, the corresponding row and column of the two-dimensional array can be quickly located, rather than searching in messy data, thereby improving the parsing efficiency of diagnostic data. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of this application or the background art, the accompanying drawings used in the embodiments of this application or the background art will be described below.
[0024] Figure 1 This is a schematic diagram of the structure of a diagnostic device provided in an embodiment of this application;
[0025] Figure 2 This is a schematic diagram illustrating an application scenario of a data storage method based on a two-dimensional array provided in an embodiment of this application.
[0026] Figure 3 This is a flowchart illustrating a data storage method based on a two-dimensional array provided in an embodiment of this application;
[0027] Figure 4 This is a schematic diagram of normal data in a UDS protocol 22 service frame provided in an embodiment of this application;
[0028] Figure 5 This is a schematic diagram of abnormal data in a UDS protocol 22 service frame provided in an embodiment of this application;
[0029] Figure 6 This is a flowchart illustrating a method for determining the number of valid data frames provided in an embodiment of this application;
[0030] Figure 7 This is a functional unit block diagram of a data storage device based on a two-dimensional array provided in an embodiment of this application;
[0031] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0032] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0033] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0034] It should be understood that the term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this document indicates that the preceding and following related objects are in an "or" relationship. In the embodiments of this application, "multiple" refers to two or more.
[0035] In the embodiments of this application, "at least one item" or its similar expression refers to any combination of these items, including any combination of a single item or a plurality of items. "One or more" means one or more, while "multiple" means two or more. For example, "at least one item" of a, b, or c can represent the following seven cases: a, b, c; a and b; a and c; b and c; a, b, and c. Each of a, b, and c can be an element or a set containing one or more elements.
[0036] In this application, the term "connection" refers to various connection methods, such as direct connection or indirect connection, to achieve communication between devices. This application does not impose any limitations on this.
[0037] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0038] The electronic devices described in this application embodiment may include smartphones (such as Android phones, iOS phones, Windows Phones, etc.), tablet computers, PDAs, laptops, video matrices, monitoring platforms, mobile internet devices (MIDs), or wearable devices, etc. The above are merely examples and not exhaustive, and include but are not limited to the above devices.
[0039] Of course, the aforementioned electronic devices can also be servers, such as cloud servers.
[0040] The following describes the relevant content, concepts, meanings, technical issues, technical solutions, and beneficial effects involved in the embodiments of this application.
[0041] First, let me explain some of the technical terms used in this application:
[0042] Diagnostic equipment: In the embodiments of this application, "diagnostic equipment" refers to vehicle diagnostic equipment, which is a specialized tool used to detect and diagnose the status and faults of vehicle systems and components. It can establish a communication connection with the vehicle's electronic system, acquire relevant data, and analyze it to determine whether the vehicle has a fault and the specific location and cause of the fault.
[0043] Electronic Control Unit (ECU): Also known as "vehicle computer" or "on-board computer," it is the core component of a vehicle's electronic control system.
[0044] The UDS (Unified Diagnostic Services) protocol is an application-layer protocol defined by the ISO 14229 standard developed by the International Organization for Standardization (ISO). It provides a unified specification and interface for communication between diagnostic equipment and vehicle ECUs. The UDS protocol specifies how diagnostic equipment sends diagnostic requests to the ECU (such as requests to read fault codes, read real-time data, and execute diagnostic session control), and how the ECU responds to these requests. By adhering to this protocol, diagnostic equipment from different manufacturers can communicate with ECUs in various vehicles, achieving standardized diagnostic functions and ensuring the universality and compatibility of the diagnostic system.
[0045] CAN (Controller Area Network) bus: It is a serial data communication bus that supports distributed control and is one of the most widely used network buses internationally.
[0046] Please see Figure 1 , Figure 1 This is a schematic diagram of the structure of a diagnostic device provided in an embodiment of this application. As can be seen, the diagnostic device may include: a controller, a communication module, a data storage module, etc., which are not limited here.
[0047] The control module, acting as the "brain" of the diagnostic equipment, is responsible for coordinating and managing the operation of the entire device. It can schedule the work of various modules, ensuring smooth collaboration between them. For example, when data about a target vehicle is needed, the control module will control the communication module to send a request message to obtain the required vehicle data.
[0048] The communication module is responsible for establishing a communication link with the ECU in the target vehicle. Based on the communication protocol used (such as the UDS protocol based on the CAN bus), it configures the corresponding parameters (such as baud rate, data bits, stop bits, etc.) to ensure accurate and stable data transmission between the diagnostic equipment and the ECU. For example, in CAN bus-based communication, the communication module sets the relevant CAN bus parameters, enabling the diagnostic equipment to access the vehicle's CAN network and communicate with the ECU.
[0049] The data storage module stores raw data received during communication between the diagnostic device and the ECU, including request frames, response frames, and other related data. This raw data forms the basis for subsequent analysis and diagnosis, allowing diagnostic personnel or programs to perform retrospective and detailed analysis when needed.
[0050] Please see Figure 2 , Figure 2 This is a schematic diagram of an application scenario for a data storage method based on a two-dimensional array provided in an embodiment of this application. It can be seen that the diagnostic device communicates and / or physically connects with the target vehicle. The bidirectional arrows in the figure indicate that there is bidirectional data communication between the diagnostic device and the target vehicle.
[0051] When a diagnostic device needs to perform vehicle diagnostics, it can send a diagnostic request to the target vehicle, for example by sending a specific request data frame (such as a request frame in the UDS protocol) to request certain diagnostic data of the vehicle, such as fault codes and vehicle operating parameters (such as engine speed, temperature, etc.).
[0052] After receiving a diagnostic request, the ECU in the target vehicle responds according to the request content, returning relevant diagnostic data to the diagnostic device via a response data frame. Upon receiving this data, the diagnostic device stores and processes it using the "data storage method based on a two-dimensional array" provided in this application embodiment, for subsequent analysis of whether the target vehicle has a fault and the specific nature of the fault.
[0053] Please see Figure 3 , Figure 3 This is a flowchart illustrating a data storage method based on a two-dimensional array provided in an embodiment of this application. The method is applied to a diagnostic device connected to an ECU in a target vehicle. The diagnostic device and the ECU transmit data using the UDS protocol. The method may include, but is not limited to, the following steps:
[0054] S301. Send a first request data frame to the ECU, the first request data frame being used to request target diagnostic data of the target vehicle.
[0055] In this embodiment of the application, the target diagnostic data may include at least one of the following: vehicle identification number (VIN), powertrain-related data, electrical system data, chassis and driving system data, etc., which are not limited here.
[0056] In a specific embodiment, during the process of the diagnostic device requesting target diagnostic data from the target vehicle, the diagnostic device can first determine the request data format of the request data frame, then determine the data identifier corresponding to the target diagnostic data, and then generate the corresponding frame data, i.e., the first request data frame, according to the data identifier and request data format of the target diagnostic data. Specifically, since the diagnostic device and the ECU use the UDS protocol for data transmission, the request data format can be determined according to the UDS protocol specification. Then, the data identifier corresponding to the target diagnostic data can also be determined. For example, assuming the target diagnostic data is the VIN code, the data identifier corresponding to the VIN code in the UDS protocol is "0xF190". Finally, the first request data frame can be generated according to the data identifier and request data format of the target diagnostic data.
[0057] Please see Figure 4 , Figure 4 This is a schematic diagram of normal data for a UDS protocol 22 service frame provided in an embodiment of this application; it can be seen that the normal data for a UDS protocol 22 service frame is as follows:
[0058] 7E0(FC00): 08FC 00 03 22F1 90 00 00 00 00---UDS Protocol 22 Service;
[0059] 7E8(FD00): 08FD 00 10 14 62F1 90 4C 4D 56 --- UDS protocol multi-frame positive response;
[0060] 7E0(FC00): 08FC 00 30 00 19 00 00 00 00 00---Flow control frame;
[0061] 7E8(FD00): 08FD 00 21 48 46 42 47 5A 35 52 --- Data area;
[0062] 7E8(FD00): 08FD 00 22 41 32 35 30 30 38 35 --- Data area;
[0063] Taking the first line as an example, the first line is a 22 service request frame, where:
[0064] 7E0 (FC00): This is generally part of the CAN bus identifier, representing the request ID of a diagnostic message. In a car's CAN network, each ECU (Electronic Control Unit) has its own diagnostic request ID and response ID, which usually start with 7. For example, the diagnostic request ID of the engine ECU is often 0x7E0, used to identify on the CAN bus that the request frame is sent to a specific ECU.
[0065] 08: This indicates the length of the frame, meaning there are 8 bytes of subsequent valid data.
[0066] FC 00: Function addressing or session control field. Specifically, it represents the diagnostic request CAN ID. In CAN bus communication, the CAN ID is used to identify the source and destination of the message. It plays a key role in identifying the diagnostic request message in the CAN network. Other nodes (such as ECUs) can determine whether to receive and process the message based on the CAN ID.
[0067] 03: Functional addressing parameters (such as physical addressing). Specifically, it indicates the effective length of the data in the request instruction. That is, the three bytes "22F1 90" following the "03" byte also belong to the request instruction.
[0068] 22: This explicitly indicates that this is service 22 in the UDS protocol, namely the read data identifier service.
[0069] F1 90: Data Identifier (DID), which specifies the data object to be read.
[0070] 00 00 00 00: Reserved bytes or used for padding to ensure the frame length meets requirements.
[0071] It needs to be explained that, Figure 4 The ellipsis in the text indicates that subsequent data of the normal data in the UDS protocol 22 service frame has been omitted.
[0072] Combination Figure 4 It can be seen that if we assume the target diagnostic data is a VIN code, and the data identifier corresponding to the VIN code in the UDS protocol is "0xF190", then the first request data frame corresponding to the target diagnostic data is "08FC 00 03 22F1 90 00 0000 00".
[0073] Please see Figure 5 , Figure 5 This is a schematic diagram of abnormal data in a UDS protocol 22 service frame provided in an embodiment of this application; it can be seen that the specific abnormal data in the UDS protocol 22 service frame is as follows:
[0074] 7E0(FC00): 08FC 00 03 22F1 90 00 00 00 00---UDS Protocol 22 Service;
[0075] 7E8(FD00): 08FD 00 10 14 62F1 90 4C 4D 56 --- UDS protocol multi-frame positive response;
[0076] 7E0(FC00): 08FC 00 30 00 19 00 00 00 00 00---Flow control frame;
[0077] 7E8(FD00): 08FD 00 22 41 32 35 30 30 38 35 --- Data area;
[0078] 7E8(FD00): 08FD 00 21 48 46 42 47 5A 35 52 --- Data area;
[0079] Since the meaning of the data in the abnormal data of the UDS protocol 22 service frame is the same as the meaning of the data in the normal data of the UDS protocol 22 service frame, it will not be repeated here; among them, Figure 5 The data area containing "22, 21" within the dashed box is abnormal data. Figure 4 and Figure 5 By comparing the data, it can be seen that the order of the data areas where "22" and "21" are located in the dashed box is reversed, resulting in a data error. Under normal circumstances, "22" should be in the fifth row and "21" should be in the fourth row. However, in the abnormal data of the UDS protocol 22 service frame, "22" is in the fourth row and "21" should be in the fifth row.
[0080] Optionally, step S301, sending the first request data frame to the ECU, may include the following steps:
[0081] S11. Detect the connection status between the diagnostic device and the ECU to obtain the target connection status; the target connection status includes a connected status or a disconnected status.
[0082] S12. When the target connection state includes the connection state, determine the target data transmission mode;
[0083] S13. Determine the preset transmission speed corresponding to the target data transmission method;
[0084] S14. Obtain the first device parameters corresponding to the diagnostic device;
[0085] S15. Determine the first optimization factor corresponding to the first equipment parameter;
[0086] S16. Optimize the preset transmission speed according to the first optimization factor to obtain the first transmission speed;
[0087] S17. Obtain the second device parameters corresponding to the ECU;
[0088] S18. Determine the second optimization factor corresponding to the second equipment parameter;
[0089] S19. Optimize the preset transmission speed according to the second optimization factor to obtain the second transmission speed;
[0090] S110. Determine the target transmission speed based on the first transmission speed and the second transmission speed;
[0091] S111. Send the first request data frame to the ECU based on the target transmission speed.
[0092] In this application embodiment, the device parameters may include at least one of the following: device model, communication interface type, CPU main frequency, CPU load, MCU main frequency, memory capacity, etc., which are not limited here; the target data transmission method may include at least one of the following: CAN bus transmission method, OBD-II interface transmission method, Bluetooth transmission method, WiFi transmission method, etc., which are not limited here.
[0093] In a specific embodiment, the connection status between the diagnostic device and the ECU can be detected first to obtain the target connection status. Specifically, the diagnostic device periodically sends a "heartbeat frame" of a specific format (such as the 0x3E service of the UDS protocol) and waits for the ECU to respond. If the ECU does not respond or the response times out, the target connection status is determined to be disconnected; otherwise, the target connection status is connected.
[0094] When the target connection is disconnected, the diagnostic device can attempt to reconnect until a successful connection is established, meaning the target connection status is now connected. Once the target connection is connected, the target data transmission method can be determined. Specifically, the connection method between the diagnostic device and the target vehicle can be obtained first to determine the target connection method. Then, the target data transmission method can be determined based on the target connection method. For example, if the connection method between the diagnostic device and the target vehicle is CAN bus, the target data transmission method will be CAN bus transmission. Or, if the connection method is Bluetooth, the target data transmission method will be Bluetooth transmission.
[0095] Next, the preset transmission speed corresponding to the target data transmission method can be determined. Specifically, a mapping relationship between preset data transmission methods and transmission speeds can be stored in advance, and the preset transmission speed corresponding to the target data transmission method can be determined based on this mapping relationship. Then, the first device parameter corresponding to the diagnostic device can be obtained. Specifically, the first device parameter can be the device type. The device manual of the diagnostic device can be obtained, and the device type of the diagnostic device, i.e., the first device parameter, can be found in the device manual. Then, the first optimization factor corresponding to the first device parameter can be determined. For example, a mapping relationship between preset device parameters and optimization factors can be stored in advance, and the first optimization factor corresponding to the first device parameter can be determined based on this mapping relationship. The value range of the first optimization factor can be -0.2 to 0.2. Then, the preset transmission speed can be optimized according to the first optimization factor. The specific calculation formula is as follows:
[0096] First transmission speed = preset transmission speed * (1 + first optimization factor);
[0097] Based on the above formula, the first transmission speed can be obtained. Next, the second device parameter corresponding to the ECU can be obtained. Specifically, the second device parameter can also be the device type, and the method for obtaining the second device parameter can be the same as the method for obtaining the first parameter. Then, the second optimization factor corresponding to the second device parameter can be determined. Specifically, the second optimization factor can be determined based on the mapping relationship between the device parameter and the optimization factor. The value range of the first optimization factor can be -0.3 to 0.3. Then, the preset transmission speed can be optimized based on the second optimization factor. The specific calculation formula is as follows:
[0098] Second transmission speed = preset transmission speed * (1 + second optimization factor);
[0099] According to the above formula, the second transmission speed can be obtained. Then, the target transmission speed can be determined based on the first and second transmission speeds. Specifically, the smaller value between the first and second transmission speeds can be determined and used as the target transmission speed. Alternatively, the first weight corresponding to the first transmission speed and the second weight corresponding to the second transmission speed can be determined. The target transmission speed is obtained by performing a weighted calculation based on the first transmission speed, the second transmission speed, the first weight, and the second weight, where the sum of the first weight and the second weight equals 1. Finally, the diagnostic device sends a first request data frame to the ECU at the target transmission speed.
[0100] In this way, by dynamically adjusting the transmission speed according to the first and second device parameters, precise matching can be achieved, and data transmission efficiency can be improved. For example, the transmission speed can be reduced for ECUs with weak computing power to avoid data backlog leading to response timeouts.
[0101] S302. Receive the first response data frame from the ECU in response to the first request data frame, and store the first response data frame in a preset diagnostic UDS data array; the diagnostic UDS data array is a one-dimensional array.
[0102] In this embodiment of the application, the diagnostic UDS data array can be preset or defaulted. For example, the diagnostic UDS data array can be defined as follows: BYTE szReadBuffer
[256] ; where BYTE is a data type, indicating that each element in the array is a data unit of one byte size; szReadBuffer is the name of the array; 256 indicates the size of the array, that is, this array can hold 256 elements. Combined with the BYTE type mentioned above, it means that this array can store a total of 256 bytes of data.
[0103] It should be noted that the indices of all arrays involved in the embodiments of this application start from 0.
[0104] In a specific embodiment, the diagnostic device can receive a first response data frame from the ECU in response to the first request data frame. Then, the first response data frame can be stored in a preset diagnostic UDS data array. For example, assuming the first response data frame is “08FD 00 10 14 62F1 90 4C 4D 56”, the diagnostic UDS data array szReadBuffer
[256] = [08,FD,00,10,14,62,F1,90,4C,4D,56,…].
[0105] S303. Determine whether the diagnostic UDS data array meets the first preset condition.
[0106] In this embodiment of the application, the data in the diagnostic UDS data array can be analyzed to determine whether the diagnostic UDS data array meets the first preset condition.
[0107] Optionally, step S303, determining whether the diagnostic UDS data array meets the first preset condition, may include the following steps:
[0108] S31. Obtain the value corresponding to the service response code of the first response data frame from the diagnostic UDS data array to obtain the first value;
[0109] S32. Obtain the value corresponding to the frame type of the first response data frame from the diagnostic UDS data array to obtain the second value;
[0110] S33. If the first value is equal to 0x62 and the second value is equal to 0x10, then the diagnostic UDS data array is determined to meet the first preset condition.
[0111] S34. If the first value is not equal to 0x62, or the second value is not equal to 0x10, then it is determined that the diagnostic UDS data array does not meet the first preset condition.
[0112] In this embodiment of the application, the value corresponding to the service response code of the first response data frame can be obtained from the diagnostic UDS data array to obtain the first value. Specifically, since the 6th byte of the first response data frame represents the service response code in the UDS protocol, and the array szReadBuffer
[256] starts from 0, the value of szReadBuffer[5] can be obtained, which is the first value. Then, the value corresponding to the frame type of the first response data frame can be obtained from the diagnostic UDS data array to obtain the second value. Similarly, since the 4th byte of the first response data frame represents the frame type, the value of szReadBuffer[3] can be obtained, which is the second value.
[0113] If the first value is equal to 0x62 and the second value is equal to 0x10, then the diagnostic UDS data array can be considered to meet the first preset condition.
[0114] If the first value is not equal to 0x62, or the second value is not equal to 0x10, it can be considered that the diagnostic UDS data array does not meet the first preset condition. Then, the diagnostic device can resend the request data frame to the ECU to obtain a new response data frame. Next, the diagnostic UDS data array can be cleared, and the new response data frame can be stored in the diagnostic UDS data array until the diagnostic UDS data array meets the first preset condition.
[0115] In the UDS protocol, different service response codes represent different response statuses. 0x62 is a positive response code for Service 22 (Read Data Identifier Service), meaning the ECU has successfully executed the corresponding request sent by the diagnostic device. By checking if the service response code is 0x62, it's easy to quickly determine whether the request was correctly processed by the ECU. If it's not equal to 0x62, such as 0x7F (negative response identifier), it indicates a problem occurred during request execution, such as unmet conditions or an incorrect request format. The diagnostic device can then adjust subsequent operations in a timely manner to avoid further invalid operations.
[0116] S304. If the first preset condition is met, it means that the target diagnostic data includes multiple frames of data, and the number of valid target data frames is determined according to the first response data frame.
[0117] In this embodiment of the application, if the diagnostic UDS data array meets the first preset condition, it indicates that the target diagnostic data contains multiple frames of data. Then, the number of target valid data frames can be determined based on the first response data frame.
[0118] Optional, please refer to Figure 6 , Figure 6 This is a flowchart illustrating a method for determining the number of valid data frames according to an embodiment of this application. Step S304, determining the target number of valid data frames based on the first response data frame, may include... Figure 6 The steps shown are as follows:
[0119] S41. Obtain the value corresponding to the total effective data length of the first response data frame from the diagnostic UDS data array to obtain the third value;
[0120] S42. Determine the target value based on the second value and the third value;
[0121] S43. Perform a bitwise AND operation between the target value and 0x0FFF to obtain the target number of valid data frames.
[0122] In this embodiment, the value corresponding to the total effective data length of the first response data frame can be obtained from the diagnostic UDS data array to obtain the third value. Specifically, since the 5th byte of the first response data frame represents the total effective data length, the value of szReadBuffer[4] can be obtained, which is the third value. Then, the target value can be determined according to the second value and the third value. Specifically, the second value and the third value can be concatenated in order to obtain the target value. For example, assuming the second value is "10", which is the fourth byte, and the third value is "14", which is the fifth byte, the two are concatenated to obtain the target value "1014". Finally, the target value can be ANDed with 0x0FFF to obtain the target effective data frame number. For example, the target value is "1014". Since the data in the diagnostic UDS data array is all hexadecimal, the target value "0x1014" and "0x0FFF" are ANDed to obtain the target effective data frame number "0x14". "0x14" is converted to decimal and equals 20, which means the target effective data frame number is 20.
[0123] In this way, by performing a bitwise AND operation between the target value and 0x0FFF, interference bits can be masked, information unrelated to length (such as protocol version, error code, etc.) can be removed, the effective length field can be accurately extracted, and misjudgment can be avoided.
[0124] S305. Starting from the nth byte of the first response data frame, copy m bytes to the 0th row of a preset two-dimensional array; where n is the starting number of valid bytes of the first response data frame, and m is the longest number of valid bytes in the UDS protocol.
[0125] In this embodiment of the application, the two-dimensional array can be preset or defaulted in advance. For example, the above two-dimensional array can be defined as follows: BYTE szRecvBuffer
[10]
[10] .
[0126] In a specific embodiment, m bytes can be copied from the nth byte of the first response data frame to the 0th row of a preset two-dimensional array. For example, this can be done using the function memcpy(szRecvBuffer[0],szReadBuffer+n,m) to store the nth to n+m-1th bytes of the first response data frame into the 0th row of the two-dimensional array. The memcpy function is a function used for memory copying in the C and C++ standard libraries.
[0127] It should be explained that in the UDS protocol, n equals 5 and m equals 7.
[0128] S306. Send a first flow control frame to the ECU, the first flow control frame being used to control the ECU to start sending the target diagnostic data.
[0129] In this embodiment of the application, the diagnostic device can send a first-stream control frame to the ECU. After the ECU receives the first-stream control frame, the ECU will start sending target diagnostic data to the diagnostic device. For example, the first-stream control frame can be "08FC00 30 00 19 00 00 00 00 00".
[0130] S307. Receive the target diagnostic data based on the number of target valid data frames, and store the target diagnostic data in the two-dimensional array.
[0131] In this embodiment of the application, the diagnostic device can receive target diagnostic data based on the target number of valid data frames. Specifically, the diagnostic device can initialize a counter S, which is initially 0. Whenever a data frame is received, S is incremented by 1 until S equals the target number of valid data frames, indicating that the target diagnostic data reception is complete and reception stops. Then, the target diagnostic data can be stored in a two-dimensional array.
[0132] Optionally, step S307, storing the target diagnostic data in the two-dimensional array, may include the following steps:
[0133] A1. Obtain target frame data; the target frame data is any frame data in the target diagnostic data;
[0134] A2. If the diagnostic UDS data array is empty, store the target frame data into the diagnostic UDS data array;
[0135] A3. Copy the target frame data from the diagnostic UDS data array to the two-dimensional array.
[0136] In this embodiment, target frame data can be acquired. If the diagnostic UDS data array is empty, the target frame data is stored in the diagnostic UDS data array. Specifically, it can be determined first whether the diagnostic UDS data array is empty. If it is empty, the target frame data is directly stored in the diagnostic UDS data array. If it is not empty, the diagnostic UDS data array can be cleared and then the target frame data is stored in the diagnostic UDS data array. Finally, the target frame data can be copied from the diagnostic UDS data array to a two-dimensional array.
[0137] Thus, by using the diagnostic UDS data array as a temporary buffer for the raw data, the raw frame data from the ECU can be directly received and stored, maintaining the integrity and original format of the data. In addition, the two-dimensional array serves as a structured storage area, allowing the raw data to be parsed and categorized by frame (such as the first frame and consecutive frames), facilitating subsequent processing.
[0138] Optionally, step A3, copying the target frame data from the diagnostic UDS data array to the two-dimensional array, may include the following steps:
[0139] B1. Obtain the value corresponding to the service identifier of the target frame data from the diagnostic UDS data array to obtain the fourth value;
[0140] B2. Perform a bitwise AND operation between the fourth value and 0xF0 to obtain the first operation result;
[0141] B3. When the first operation result is equal to 0x20, the fourth value is ANDed with 0x0F to obtain the second operation result; the second operation result represents the row number of the target frame data in the two-dimensional array;
[0142] B4. Based on the second calculation result, copy the target frame data from the diagnostic UDS data array to the two-dimensional array.
[0143] In this embodiment of the application, the value corresponding to the service identifier of the target frame data can be obtained from the diagnostic UDS data array first to obtain the fourth value. Specifically, since the fourth byte of the data frame represents the service identifier in the UDS protocol, the value of szReadBuffer[3] can be obtained, which is the fourth value. Then, the fourth value can be ANDed with 0xF0 to obtain the first operation result. For example, assuming the fourth value is equal to "0x21", "0x21" is ANDed with 0xF0 to obtain the first operation result "0x20".
[0144] When the first operation result is equal to 0x20, the fourth value can be ANDed with 0x0F to obtain the second operation result. Finally, the target frame data can be copied from the diagnostic UDS data array to the two-dimensional array based on the second operation result. For example, assuming the fourth value is equal to "0x21", it is ANDed with 0x0F to obtain the second operation result 0x01, which is 1 in decimal. Therefore, the target frame data should be copied from the diagnostic UDS data array to the first row of the two-dimensional array.
[0145] Thus, by copying the target frame data to a two-dimensional array based on the result of the second operation, it is convenient for subsequent overall processing (such as parsing, display, or storage). For example, the two-dimensional array can store multiple frames of data in rows (such as each row corresponding to one frame). This allows the data of different frames to be stored in rows according to their sequence numbers, making it convenient to access or process in batches by frame. Multiple frames of data may contain multiple subframes, and the two-dimensional array can flexibly accommodate different numbers of frames to adapt to the maximum frame length limit in the protocol.
[0146] Optionally, the two-dimensional array includes j rows of data, where j is a positive integer; the method may further include the following steps:
[0147] C1. Determine the row number corresponding to each row of data in the j rows of data to obtain j row numbers;
[0148] C2. Store the j rows of data into a preset target array in ascending order according to the j row numbers; the target array is a one-dimensional array; determine the target diagnostic data based on the target array.
[0149] In this embodiment of the application, the target array can be preset or defaulted in advance. For example, the target array can be defined as follows: BYTE szBufferTmp
[64] .
[0150] In a specific embodiment, the row number corresponding to each row of data in j rows can be obtained, resulting in j row numbers. Then, the j rows of data can be stored in a preset target array in ascending order according to the j row numbers. For example, assuming that the 0th row of data has 5 bytes and the 1st row of data has 6 bytes, the 0th row of data is stored in the target array first, specifically in the elements corresponding to indices 0 to 4 of the target array. Next, the 1st row of data can be stored in the elements corresponding to indices 5 to 10 of the target array, and so on. Finally, the target array can be parsed to obtain the target diagnostic data.
[0151] To illustrate, suppose the target diagnostic data is VIN, and the target array is as follows:
[0152] [14,62,F1,90,4C,4D,56,48,46,42,47,5A,35,52,41,32,35,30,30,38,35];
[0153] First, find the data identifier corresponding to VIN in the target array. For example, in the UDS protocol, 0xF190 is usually used as the data identifier of VIN. Then, the data after the data identifier of VIN can be converted into characters according to the ASCII code rules, and then combined in order to obtain VIN. It should be explained that since the data in the array is all hexadecimal, "0x" needs to be added before conversion. For example, "0x4C" is converted to the ASCII character "L", "0x4D" is converted to "M", and so on. Thus, VIN can be determined as "LMVHFBGZ5RA250085".
[0154] In summary, the data storage method based on a two-dimensional array described in this application includes: sending a first request data frame to an ECU; receiving a first response data frame from the ECU in response to the first request data frame, and storing the first response data frame in a preset diagnostic UDS data array; determining whether the diagnostic UDS data array meets a first preset condition; if the first preset condition is met, it indicates that the target diagnostic data includes multiple frames of data, and determining the target valid data frame number based on the first response data frame; copying m bytes from the nth byte of the first response data frame to the 0th row of the preset two-dimensional array; sending a first flow control frame to the ECU; receiving the target diagnostic data based on the target valid data frame number, and storing the target diagnostic data... By storing the data in a two-dimensional array, when it is determined that the target diagnostic data contains multiple frames, the diagnostic device can store the data in the two-dimensional array according to the predetermined number and order of frames. This allows subsequent parsing of the multi-frame data to be performed in a unified and standardized manner, reducing errors and repeated verification time during the parsing process, thereby improving the overall parsing efficiency. In addition, compared with linear or unstructured storage, two-dimensional arrays are more organized in searching and managing multi-frame data, greatly improving the speed of data retrieval and processing. For example, when it is necessary to parse specific bytes of data in a frame, the corresponding row and column of the two-dimensional array can be quickly located, rather than searching in messy data, thereby improving the parsing efficiency of diagnostic data.
[0155] Please see Figure 7 , Figure 7 This application provides a functional unit block diagram of a data storage device based on a two-dimensional array, applied to a diagnostic device. The diagnostic device is connected to an ECU in a target vehicle, and the diagnostic device and the ECU transmit data using the UDS protocol. The device 700 includes: a request unit 701, a control unit 702, and a storage unit 703, wherein:
[0156] The request unit 701 is used to send a first request data frame to the ECU, the first request data frame being used to request target diagnostic data of the target vehicle;
[0157] The control unit 702 is configured to receive a first response data frame from the ECU in response to the first request data frame, and store the first response data frame in a preset diagnostic UDS data array; the diagnostic UDS data array is a one-dimensional array; determine whether the diagnostic UDS data array meets a first preset condition; if the first preset condition is met, it indicates that the target diagnostic data includes multiple frames of data, and determine the number of target valid data frames based on the first response data frame;
[0158] The storage unit 703 is used to copy m bytes from the nth byte of the first response data frame to the 0th row of a preset two-dimensional array; where n is the starting number of valid data bytes in the first response data frame, and m is the longest number of valid data bytes in the UDS protocol.
[0159] The control unit 702 is further configured to send a first flow control frame to the ECU, the first flow control frame being configured to control the ECU to start sending the target diagnostic data;
[0160] The storage unit 703 is also used to receive the target diagnostic data based on the number of target valid data frames, and store the target diagnostic data in the two-dimensional array.
[0161] Optionally, in determining whether the diagnostic UDS data array meets the first preset condition, the control unit 702 is specifically used for:
[0162] Obtain the value corresponding to the service response code of the first response data frame from the diagnostic UDS data array to obtain the first value;
[0163] The second value is obtained by retrieving the value corresponding to the frame type of the first response data frame from the diagnostic UDS data array;
[0164] If the first value is equal to 0x62 and the second value is equal to 0x10, then the diagnostic UDS data array is determined to meet the first preset condition.
[0165] If the first value is not equal to 0x62, or the second value is not equal to 0x10, then it is determined that the diagnostic UDS data array does not meet the first preset condition.
[0166] Optionally, in determining the target number of valid data frames based on the first response data frame, the control unit 702 is specifically configured to:
[0167] The third value is obtained by retrieving the value corresponding to the total effective data length of the first response data frame from the diagnostic UDS data array;
[0168] The target value is determined based on the second value and the third value;
[0169] The target value is ANDed with 0x0FFF to obtain the target number of valid data frames.
[0170] Optionally, in storing the target diagnostic data in the two-dimensional array, the storage unit 703 is specifically used for:
[0171] Acquire target frame data; the target frame data is any frame data in the target diagnostic data;
[0172] If the diagnostic UDS data array is empty, the target frame data is stored in the diagnostic UDS data array;
[0173] The target frame data is copied from the diagnostic UDS data array into the two-dimensional array.
[0174] Optionally, in copying the target frame data from the diagnostic UDS data array into the two-dimensional array, the storage unit 703 is specifically used for:
[0175] The fourth value is obtained by retrieving the value corresponding to the service identifier of the target frame data from the diagnostic UDS data array;
[0176] Perform a bitwise AND operation between the fourth value and 0xF0 to obtain the first operation result;
[0177] When the first operation result is equal to 0x20, the fourth value is ANDed with 0x0F to obtain the second operation result; the second operation result represents the row number of the target frame data in the two-dimensional array;
[0178] Based on the second calculation result, the target frame data is copied from the diagnostic UDS data array to the two-dimensional array.
[0179] Optionally, the two-dimensional array includes j rows of data, where j is a positive integer; the device 700 is further specifically used for:
[0180] Determine the row number corresponding to each row of data in the j rows of data to obtain j row numbers;
[0181] The j rows of data are stored in a preset target array in ascending order according to the j row numbers; the target array is a one-dimensional array; the target diagnostic data is determined based on the target array.
[0182] Optionally, in sending the first request data frame to the ECU, the request unit 701 is specifically used for:
[0183] The connection status between the diagnostic device and the ECU is detected to obtain the target connection status; the target connection status includes a connected status or a disconnected status.
[0184] When the target connection state includes the connection state, the target data transmission method is determined;
[0185] Determine the preset transmission speed corresponding to the target data transmission method;
[0186] Obtain the first device parameters corresponding to the diagnostic device;
[0187] Determine the first optimization factor corresponding to the first device parameters;
[0188] The preset transmission speed is optimized based on the first optimization factor to obtain a first transmission speed;
[0189] Obtain the second device parameters corresponding to the ECU;
[0190] Determine the second optimization factor corresponding to the second equipment parameter;
[0191] The preset transmission speed is optimized according to the second optimization factor to obtain the second transmission speed;
[0192] The target transmission speed is determined based on the first transmission speed and the second transmission speed;
[0193] The first request data frame is sent to the ECU based on the target transmission speed.
[0194] In specific implementations, the data storage device 700 based on a two-dimensional array described in the embodiments of the present invention can also execute other implementations described in the data storage method based on a two-dimensional array provided in the embodiments of the present invention, which will not be repeated here.
[0195] Please see Figure 8 , Figure 8This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include a processor, a memory, a communication interface, and one or more programs. The processor, memory, and communication interface can be interconnected via a bus. The one or more programs are stored in the memory and configured to be executed by the processor. This electronic device can be applied to a diagnostic device that is connected to an ECU in a target vehicle. The diagnostic device and the ECU transmit data using the UDS protocol. In this embodiment, the program includes instructions for performing the following steps:
[0196] A first request data frame is sent to the ECU, the first request data frame being used to request target diagnostic data of the target vehicle;
[0197] The system receives a first response data frame from the ECU in response to the first request data frame, and stores the first response data frame in a preset diagnostic UDS data array; the diagnostic UDS data array is a one-dimensional array.
[0198] Determine whether the diagnostic UDS data array meets the first preset condition;
[0199] If the first preset condition is met, it means that the target diagnostic data includes multiple frames of data, and the number of valid target data frames is determined according to the first response data frame.
[0200] Starting from the nth byte of the first response data frame, copy m bytes to the 0th row of a preset two-dimensional array; where n is the starting number of valid bytes of the first response data frame, and m is the longest number of valid bytes in the UDS protocol;
[0201] A first flow control frame is sent to the ECU, the first flow control frame being used to control the ECU to start sending the target diagnostic data;
[0202] The target diagnostic data is received based on the number of valid target data frames, and the target diagnostic data is stored in the two-dimensional array.
[0203] Optionally, in determining whether the diagnostic UDS data array meets the first preset condition, the above procedure includes instructions for performing the following steps:
[0204] Obtain the value corresponding to the service response code of the first response data frame from the diagnostic UDS data array to obtain the first value;
[0205] The second value is obtained by retrieving the value corresponding to the frame type of the first response data frame from the diagnostic UDS data array;
[0206] If the first value is equal to 0x62 and the second value is equal to 0x10, then the diagnostic UDS data array is determined to meet the first preset condition.
[0207] If the first value is not equal to 0x62, or the second value is not equal to 0x10, then it is determined that the diagnostic UDS data array does not meet the first preset condition.
[0208] Optionally, in determining the target number of valid data frames based on the first response data frame, the above procedure includes instructions for performing the following steps:
[0209] The third value is obtained by retrieving the value corresponding to the total effective data length of the first response data frame from the diagnostic UDS data array;
[0210] The target value is determined based on the second value and the third value;
[0211] The target value is ANDed with 0x0FFF to obtain the target number of valid data frames.
[0212] Optionally, in storing the target diagnostic data in the two-dimensional array, the above procedure includes instructions for performing the following steps:
[0213] Acquire target frame data; the target frame data is any frame data in the target diagnostic data;
[0214] If the diagnostic UDS data array is empty, the target frame data is stored in the diagnostic UDS data array;
[0215] The target frame data is copied from the diagnostic UDS data array into the two-dimensional array.
[0216] Optionally, in copying the target frame data from the diagnostic UDS data array into the two-dimensional array, the above procedure includes instructions for performing the following steps:
[0217] The fourth value is obtained by retrieving the value corresponding to the service identifier of the target frame data from the diagnostic UDS data array;
[0218] Perform a bitwise AND operation between the fourth value and 0xF0 to obtain the first operation result;
[0219] When the first operation result is equal to 0x20, the fourth value is ANDed with 0x0F to obtain the second operation result; the second operation result represents the row number of the target frame data in the two-dimensional array;
[0220] Based on the second calculation result, the target frame data is copied from the diagnostic UDS data array to the two-dimensional array.
[0221] Optionally, the two-dimensional array includes j rows of data, where j is a positive integer; the above program includes instructions for performing the following steps:
[0222] Determine the row number corresponding to each row of data in the j rows of data to obtain j row numbers;
[0223] The j rows of data are stored in a preset target array in ascending order according to the j row numbers; the target array is a one-dimensional array; the target diagnostic data is determined based on the target array.
[0224] Optionally, in sending the first request data frame to the ECU, the above procedure includes instructions for performing the following steps:
[0225] The connection status between the diagnostic device and the ECU is detected to obtain the target connection status; the target connection status includes a connected status or a disconnected status.
[0226] When the target connection state includes the connection state, the target data transmission method is determined;
[0227] Determine the preset transmission speed corresponding to the target data transmission method;
[0228] Obtain the first device parameters corresponding to the diagnostic device;
[0229] Determine the first optimization factor corresponding to the first device parameters;
[0230] The preset transmission speed is optimized based on the first optimization factor to obtain a first transmission speed;
[0231] Obtain the second device parameters corresponding to the ECU;
[0232] Determine the second optimization factor corresponding to the second equipment parameter;
[0233] The preset transmission speed is optimized according to the second optimization factor to obtain the second transmission speed;
[0234] The target transmission speed is determined based on the first transmission speed and the second transmission speed;
[0235] The first request data frame is sent to the ECU based on the target transmission speed.
[0236] In specific implementations, the electronic devices described in the embodiments of the present invention may also execute other implementation methods described in the above method embodiments, which will not be repeated here.
[0237] This application also provides a computer-readable storage medium storing a computer program for electronic data interchange, which causes a computer to perform some or all of the steps of any of the methods described in the above method embodiments, wherein the computer includes an electronic device.
[0238] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods described in the above method embodiments. The computer program product may be a software installation package, and the computer may include an electronic device.
[0239] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0240] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0241] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0242] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
[0243] The steps of the methods or algorithms described in the embodiments of this application can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in RAM, flash memory, ROM, EPROM, electrically erasable programmable read-only memory (EEPROM), registers, hard disk, portable hard disk, read-only optical disk (CD-ROM), or any other form of storage medium well known in the art. An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Furthermore, the ASIC can reside in a terminal device or management device. Alternatively, the processor and storage medium can exist as discrete components in the terminal device or management device.
[0244] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in the embodiments of this application can be implemented, in whole or in part, by software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, in the form of a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated.
[0245] The aforementioned computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media.
[0246] The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., digital video discs (DVDs)), or semiconductor media (e.g., solid-state disks (SSDs)).
[0247] The modules / units included in the various devices and products described in the above embodiments can be software modules / units, hardware modules / units, or a combination of both. For example, for devices and products applied to or integrated into a chip, all modules / units can be implemented using hardware methods such as circuits, or at least some modules / units can be implemented using software programs that run on a processor integrated within the chip, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits. For devices and products applied to or integrated into a chip module, all modules / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components of the chip module, or at least some modules / units can be implemented using hardware methods such as circuits. The implementation is achieved through a software program that runs on a processor integrated within the chip module. The remaining modules / units (if any) can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into terminal equipment, each of their modules / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components within the terminal equipment. Alternatively, at least some modules / units can be implemented using a software program that runs on a processor integrated within the terminal equipment, while the remaining modules / units (if any) can be implemented using hardware methods such as circuits.
[0248] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the embodiments of this application. It should be understood that the above descriptions are merely specific embodiments of the embodiments of this application and are not intended to limit the protection scope of the embodiments of this application. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solutions of the embodiments of this application should be included within the protection scope of the embodiments of this application.
Claims
1. A data storage method based on a two-dimensional array, characterized in that, The method, applied to diagnostic equipment connected to an ECU in a target vehicle, wherein the diagnostic equipment and the ECU transmit data using the UDS protocol, includes: A first request data frame is sent to the ECU, the first request data frame being used to request target diagnostic data of the target vehicle; The system receives a first response data frame from the ECU in response to the first request data frame, and stores the first response data frame in a preset diagnostic UDS data array; the diagnostic UDS data array is a one-dimensional array. Determine whether the diagnostic UDS data array meets the first preset condition; If the first preset condition is met, it means that the target diagnostic data includes multiple frames of data, and the number of valid target data frames is determined according to the first response data frame. Starting from the nth byte of the first response data frame, copy m bytes to the 0th row of a preset two-dimensional array; where n is the starting number of valid bytes of the first response data frame, and m is the longest number of valid bytes in the UDS protocol; A first flow control frame is sent to the ECU, the first flow control frame being used to control the ECU to start sending the target diagnostic data; The target diagnostic data is received based on the number of valid target data frames, and the target diagnostic data is stored in the two-dimensional array.
2. The method as described in claim 1, characterized in that, The step of determining whether the diagnostic UDS data array meets the first preset condition includes: Obtain the value corresponding to the service response code of the first response data frame from the diagnostic UDS data array to obtain the first value; The second value is obtained by retrieving the value corresponding to the frame type of the first response data frame from the diagnostic UDS data array; If the first value is equal to 0x62 and the second value is equal to 0x10, then the diagnostic UDS data array is determined to meet the first preset condition. If the first value is not equal to 0x62, or the second value is not equal to 0x10, then it is determined that the diagnostic UDS data array does not meet the first preset condition.
3. The method as described in claim 2, characterized in that, Determining the target number of valid data frames based on the first response data frame includes: The third value is obtained by retrieving the value corresponding to the total effective data length of the first response data frame from the diagnostic UDS data array; The target value is determined based on the second value and the third value; The target value is ANDed with 0x0FFF to obtain the target number of valid data frames.
4. The method according to any one of claims 1-3, characterized in that, The step of storing the target diagnostic data into the two-dimensional array includes: Acquire target frame data; the target frame data is any frame data in the target diagnostic data; If the diagnostic UDS data array is empty, the target frame data is stored in the diagnostic UDS data array; The target frame data is copied from the diagnostic UDS data array into the two-dimensional array.
5. The method as described in claim 4, characterized in that, The step of copying the target frame data from the diagnostic UDS data array to the two-dimensional array includes: The fourth value is obtained by retrieving the value corresponding to the service identifier of the target frame data from the diagnostic UDS data array; Perform a bitwise AND operation between the fourth value and 0xF0 to obtain the first operation result; When the first operation result is equal to 0x20, the fourth value is ANDed with 0x0F to obtain the second operation result; the second operation result represents the row number of the target frame data in the two-dimensional array; Based on the second calculation result, the target frame data is copied from the diagnostic UDS data array to the two-dimensional array.
6. The method according to any one of claims 1-3, characterized in that, The two-dimensional array comprises j rows of data, where j is a positive integer; the method further includes: Determine the row number corresponding to each row of data in the j rows of data to obtain j row numbers; The j rows of data are stored in a preset target array in ascending order according to the j row numbers; the target array is a one-dimensional array; the target diagnostic data is determined based on the target array.
7. The method according to any one of claims 1-3, characterized in that, Sending the first request data frame to the ECU includes: The connection status between the diagnostic device and the ECU is detected to obtain the target connection status; the target connection status includes a connected status or a disconnected status. When the target connection state includes the connection state, the target data transmission method is determined; Determine the preset transmission speed corresponding to the target data transmission method; Obtain the first device parameters corresponding to the diagnostic device; Determine the first optimization factor corresponding to the first device parameters; The preset transmission speed is optimized based on the first optimization factor to obtain a first transmission speed; Obtain the second device parameters corresponding to the ECU; Determine the second optimization factor corresponding to the second equipment parameter; The preset transmission speed is optimized according to the second optimization factor to obtain the second transmission speed; The target transmission speed is determined based on the first transmission speed and the second transmission speed; The first request data frame is sent to the ECU based on the target transmission speed.
8. A data storage device based on a two-dimensional array, characterized in that, This device is used in diagnostic equipment that connects to an ECU in a target vehicle. The diagnostic equipment and the ECU transmit data using the UDS protocol. The device includes: a request unit, a control unit, and a storage unit, wherein: The request unit is used to send a first request data frame to the ECU, the first request data frame being used to request target diagnostic data of the target vehicle; The control unit is configured to receive a first response data frame from the ECU in response to the first request data frame, and store the first response data frame in a preset diagnostic UDS data array; the diagnostic UDS data array is a one-dimensional array; determine whether the diagnostic UDS data array meets a first preset condition; if the first preset condition is met, it indicates that the target diagnostic data includes multiple frames of data, and determine the number of target valid data frames based on the first response data frame; The storage unit is used to copy m bytes from the nth byte of the first response data frame to the 0th row of a preset two-dimensional array; where n is the starting number of valid data bytes in the first response data frame, and m is the longest number of valid data bytes in the UDS protocol. The control unit is further configured to send a first flow control frame to the ECU, the first flow control frame being configured to control the ECU to start sending the target diagnostic data; The storage unit is also used to receive the target diagnostic data based on the number of target valid data frames, and to store the target diagnostic data in the two-dimensional array.
9. An electronic device, characterized in that, include: Processor, memory, communication interface, and one or more programs; The one or more programs are stored in the memory and configured to be executed by the processor, the programs including instructions for performing the steps of the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, A computer program for storing electronic data interchange, wherein the computer program causes a computer to perform the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Freeze frame configuration method and system and motor vehicle
CN111190410A
Test method and device of controller local area network and storage medium
CN119094412A