22 service implementation method of UDS protocol and related device
By generating data callback functions and verifying, the problems of large amount of data access workload and waste of code resources in the UDS protocol 22 service implementation solution in the AUTOSAR architecture are solved, which enables data access to be fast and efficient and reduces the amount of code.
Patent Information
- Application Number
- CN202411739482.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-28
AI Technical Summary
The existing UDS protocol 22 service implementation solution based on the standard AUTOSAR architecture has problems such as large data access workload and waste of code resources.
By obtaining the data identifiers of the data to be read, a data callback function is generated based on these data identifiers, and the data variable value is checked according to the preset verification rules, and the data variable value is checked by the data callback function callback.
This method records the data information of the data to be accessed through the data information table, and generates a data callback function corresponding to the data identifier of each data to be read, realizing the fast and efficient data access, reducing the amount of code, and saving code resources.
Smart Images

Figure CN119718328A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a UDS protocol 22 service implementation method and related devices. Background Art
[0002] AUTOSAR (Automotive Open System Architecture) is a development cooperation alliance of major OEMs, suppliers, and tool and software service providers in the global automotive industry. AUTOSAR aims to simplify the joint development of automotive electronic software, reduce costs and accelerate product time to market, improve software quality, and provide the mechanisms required for safety system design. AUTOSAR redefines the way embedded automotive software is written, thereby enabling the reuse, exchange, upgrade and integration of software components. RTE (Run-Time Environment) is the core of the AUTOSAR architecture. The UDS (Unified Diagnostic Services) protocol is a standardized standard for diagnostic services. The 22 services of the UDS protocol, namely the ReadDataByIdentifier service, allow the client to request to read the data record values identified by one or more DIDs (dataIdentifiers) in the server. Each DID can also map one or more data record values. In actual engine control system applications, the number of DIDs is often large, reaching hundreds or thousands.
[0003] The existing UDS protocol 22 service implementation scheme based on the standard AUTOSAR architecture is also implemented through the mainstream AUTOSAR architecture implementation tool. This method is suitable for a newly developed control software system. For a system with a large number of DID configuration requirements, it will consume a lot of time and cost, and for a traditional software that has already implemented some UDS protocol 22 service functions, it will also cause a lot of redundant work and waste of code resources.
[0004] It can be seen that the existing UDS protocol 22 service implementation solution based on the standard AUTOSAR architecture has the problems of large data access workload and waste of code resources. Summary of the invention
[0005] In view of this, it is necessary to provide a UDS protocol 22 service implementation method and related devices to solve the problems of large data access workload and waste of code resources in the existing UDS protocol 22 service implementation scheme based on the standard AUTOSAR architecture.
[0006] In order to solve the above problems, the present invention provides a method for implementing 22 services of the UDS protocol, comprising: Acquire a data identifier of the data to be read, and based on the data identifier, acquire a data callback function generated based on a data information table storing the data identifier, wherein the data information of the data to be stored is stored in the data information table; Acquire the data variable value of the data to be read based on the data identifier, and fill the data variable value into the data callback function; The data variable value is verified based on a preset verification rule, and the verified data variable value is called back through the data callback function.
[0007] In a possible implementation manner, the data information table includes a data identifier and a valid data length of the data to be read, and the data callback function generated based on the data information table storing the data identifier includes: Based on the data identifier of the data to be read and the valid data length, a data callback function corresponding to the data identifier is generated according to a preset architecture rule, and the data callback function is used to call back the data variable value of the data to be read.
[0008] In a possible implementation manner, acquiring the data variable value of the to-be-read data based on the data identifier, and filling the data variable value into the data callback function includes: Acquire the data initial variable value of the data to be read based on the data identifier; Performing precision conversion on the initial data variable value according to a preset precision conversion rule to obtain a target data variable value; Fill the first address of the target data variable value into the sending buffer of the callback function according to the quantity and type of the target data variable value.
[0009] In a possible implementation, performing precision conversion on the initial data variable value according to a preset precision conversion rule to obtain a target data variable value includes: Determine whether the variable corresponding to the data identifier is a historical variable according to the data variable name corresponding to the data identifier and the configuration information inheritance identifier stored in the data information table; When the variable corresponding to the data identifier is a historical variable, the historical precision conversion function corresponding to the historical variable is used to perform precision conversion on the initial data variable value to obtain the target data variable value; Otherwise, the precision conversion of the initial data variable value is performed according to the precision conversion function corresponding to the data identifier recorded in the data information table to obtain the target data variable value.
[0010] In a possible implementation manner, filling the first address of the target data variable value into the sending buffer of the callback function according to the number and type of the target data variable value includes: When the target data variable value corresponds to a variable, determining the cache head address and cache byte number of the target data variable based on the data length of the target data variable value; When the target data variable value corresponds to multiple variables, the cache starting addresses and cache byte numbers of the data variable values corresponding to the multiple variables are determined in sequence based on the positional relationship of the multiple variables in the data information table, wherein the cache tail address of the data variable value of the first variable is adjacent to the cache starting address of the data variable value of the second variable, the first variable is before the second variable, and the first variable is adjacent to the second variable.
[0011] In a possible implementation, the verifying the data variable value based on a preset verification rule includes: Determine a verification method for the data variable value based on a verification identifier stored in the data information table and corresponding to the data identifier; The verification method is used to verify the data variable value to obtain a verification result.
[0012] In a possible implementation manner, the data variable value after verification by the data callback function callback includes: The data variable value is called back through the data callback function, and the verification result is returned, and the verification result is used to indicate whether the data reading is successful.
[0013] The present invention also provides a UDS protocol 22 service implementation device, comprising: A callback function generating module, used for obtaining a data identifier of the data to be read, and obtaining, based on the data identifier, a data callback function generated based on a data information table storing the data identifier; A data acquisition module, used for acquiring a data variable value of the data to be read based on the data identifier, and filling the data variable value into the data callback function; The data callback module is used to verify the data variable value based on a preset verification rule, and to call back the verified data variable value through the data callback function.
[0014] The present invention also provides an electronic device, comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the service implementation method of the UDS protocol 22 described in any of the above claims.
[0015] The present invention also provides a computer-readable storage medium for storing a computer-readable program or instruction, which, when executed by a processor, can implement the steps in the 22 service implementation method of the UDS protocol described in any of the above claims.
[0016] The beneficial effects of the present invention are as follows: the 22 service implementation method of the UDS protocol provided by the present invention records the data information of the data to be accessed through the data information table, and generates a data callback function corresponding to the data identifier of each data to be read according to the data information, and after obtaining the data variable value of the data to be read, fills the data variable value into the data callback function, and verifies the data variable value according to the verification rule, and calls back the verified data variable value through the data callback function. When applied to the UDS protocol 22 service based on the standard AUTOSAR architecture, the operator can directly perform maintenance operations on the data information table, which can realize data maintenance, which is convenient and fast, data access is faster, and the amount of code can be reduced, saving code resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A flowchart of a method for implementing a 22-service of a UDS protocol provided in an embodiment of the present invention; Figure 2 A flowchart of a method for filling in a callback function provided by an embodiment of the present invention; Figure 3 A flowchart of a precision conversion method provided by an embodiment of the present invention; Figure 4 A precision conversion logic diagram provided by an embodiment of the present invention; Figure 5 A flowchart of a method for implementing S203 provided in an embodiment of the present invention; Figure 6 A backfill function filling step diagram provided by an embodiment of the present invention; Figure 7 A schematic diagram of a variable address provided by an embodiment of the present invention; Figure 8 A schematic diagram of a flow chart of a verification method provided by an embodiment of the present invention; Fig. 9A schematic diagram of the structure of a 22 service implementation device of a UDS protocol provided in an embodiment of the present invention; Fig.10 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of the present invention and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0020] The descriptions of "first", "second", etc. involved in the embodiments of the present invention are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the technical features defined as "first" and "second" may explicitly or implicitly include at least one of the features.
[0021] Reference to an "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0022] A specific embodiment of the present invention, as Figure 1 As shown, a method for implementing a 22 service of a UDS protocol is disclosed, including: S101, obtaining a data identifier of data to be read, and obtaining, based on the data identifier, a data callback function generated based on a data information table storing the data identifier, wherein the data information of the data to be stored is stored in the data information table; S102, obtaining a data variable value of the data to be read based on the data identifier, and filling the data variable value into the data callback function; S103, verifying the data variable value based on a preset verification rule, and calling back the verified data variable value through a data callback function.
[0023] In an embodiment of the present invention, the data access method provided is applicable to the UDS protocol 22 service based on the standard AUTOSAR architecture. For the data to be accessed that needs to configure the 22 service, a data information table is used to record the data information of the data to be accessed. The data information table can be an EXCEL table. The data information includes but is not limited to data variable name, DID, data type, data type size, variable data length, effective data length, whether precision conversion is required, precision conversion relationship, whether to inherit traditional software information, the precision conversion function name of the traditional software, whether verification is required, verification type and other information. Based on the data information, an empty callback function corresponding to each DID can be generated. When data access is required according to the DID, the empty callback function corresponding to the DID is obtained, and the corresponding data variable value is obtained in the on-board computer based on the DID, the data variable value is filled in the empty callback function, and then the data variable value is checked, and the data variable value after verification is called back by the data callback function. When it is necessary to add, modify or delete the UDS protocol 22 service DID, the developer only needs to update the data information table and then call the relevant module to complete the update of the relevant code of the UDS protocol 22 service function of the AUTOSAR architecture.
[0024] The data access method provided by the present invention records the data information of the data to be accessed through the data information table, and generates a data callback function corresponding to the data identifier of each data to be read according to the data information. After the data variable value of the data to be read is obtained, the data variable value is filled into the data callback function, and the data variable value is verified according to the verification rule, and the verified data variable value is called back by the data callback function. When applied to the UDS protocol 22 service based on the standard AUTOSAR architecture, the operator can directly perform maintenance operations on the data information table, so as to realize data maintenance, which is convenient and fast, and data access is faster, and the amount of code can be reduced, saving code resources.
[0025] As a possible implementation mode of the present invention, in this implementation mode, the data information table includes a data identifier and a valid data length of the data to be read, and the data callback function generated based on the data information table storing the data identifier includes: Based on the data identifier and the effective data length of the data to be read, a data callback function corresponding to the data identifier is generated according to a preset architecture rule. The data callback function is used to call back the data variable value of the data to be read.
[0026] In the embodiment of the present invention, when generating a data callback function according to a DID, first obtain the valid data length and other information corresponding to the DID in the data information table, and generate an ARXML file of an empty callback function corresponding to each DID based on the AUTOSAR architecture according to the relevant provisions of AUTOSAR. The format of this file can be recognized by mainstream AUTOSAR architecture implementation tools (such as Isolar). Secondly, call the interface API of the Isolar software to convert the ARXML file into a C language source file based on the AUTOSAR architecture with an empty callback function corresponding to each DID. The function input parameter is the address of the send buffer, and the return value is the response code.
[0027] Further, such as Figure 2 As shown, the data variable value of the data to be read is obtained based on the data identifier, and the data variable value is filled into the data callback function, including: S201, obtaining the data initial variable value of the data to be read based on the data identifier; S202, performing precision conversion on the initial data variable value according to a preset precision conversion rule to obtain a target data variable value.
[0028] S203, filling the first address of the target data variable value into the sending buffer of the callback function according to the number and type of the target data variable value.
[0029] In an embodiment of the present invention, due to the special rules of the UDS protocol, the data variable value of the data to be read corresponding to the data identifier needs to be precision converted to adapt to the precision requirements of the UDS protocol. Specifically, the initial data variable value can be precision converted according to the precision conversion rule corresponding to the DID recorded in the data information table to obtain the target data variable value, and the first address of the target data variable value will be filled into the sending buffer of the callback function according to the number and type of the target data variable value.
[0030] Further, such as Figure 3 As shown, the initial data variable value is converted according to the preset precision conversion rule to obtain the target data variable value, including: S301, judging whether the variable corresponding to the data identifier is a historical variable according to the data variable name corresponding to the data identifier stored in the data information table and the configuration information inheritance identifier; S302, when the variable corresponding to the data identifier is a historical variable, the historical precision conversion function corresponding to the historical variable is used to perform precision conversion on the initial data variable value to obtain the target data variable value; S303: Otherwise, perform precision conversion on the initial data variable value according to the precision conversion function corresponding to the data identifier recorded in the data information table to obtain the target data variable value.
[0031] In the embodiment of the present invention, Figure 4 As shown, for the precision conversion of data variable values, three judgments are required. Judgment 1: Read the data variable name, DID, and data information configuration identifier in the data information table to determine whether the variable in the DID inherits the relevant configuration information of the traditional software. In the 22 services of the UDS protocol, each DID can map the data of global variables, calibration quantities, or constants in one or more software. Except for some special DIDs (such as 0xF4XX, X represents any number from 0 to 9 or any letter from AF) that need to map fixed-meaning data according to regulations, other numbered DIDs can customize mapping objects according to specific needs (such as diagnostic instrument development, Routine test development). In traditional software, the mapping relationship between DID and variables has been implemented through C code. Here, the three parameters of data variable name, DID, and data information configuration identifier in the data information table are read to confirm whether the implementation of this mapping relationship is directly inherited from the traditional software to improve code utilization. Judgment 2: If inheritance is required, then determine whether the variables defined in DID need to call the conversion function implemented in the traditional software. If so, call the conversion function implemented in the traditional software according to the "precision conversion function name of the traditional software" in the data information table to perform precision conversion on each variable associated in DID. If not required, skip and output the data variable value after precision processing. Judgment 3: If inheritance is not required, then determine whether the variables defined in DID need to be converted for precision. If so, generate and call a new conversion function according to the "precision conversion relationship" information in the data information table. If not required, skip and output the data variable value after precision processing.
[0032] The embodiment of the present invention ensures that the accuracy requirement of the UDS protocol is met by performing precision conversion on the data variable value of the data to be read.
[0033] As a possible implementation mode of the present invention, in this implementation mode, Figure 5 As shown, according to the number and type of target data variable values, the first address of the target data variable value is filled into the send buffer of the callback function, including: S501, when the target data variable value corresponds to a variable, determining the cache head address and cache byte number of the target data variable based on the data length of the target data variable value; S502, when the target data variable value corresponds to multiple variables, the cache starting addresses and cache byte numbers of the data variable values corresponding to the multiple variables are determined in sequence based on the positional relationship of the multiple variables in the data information table, wherein the cache tail address of the data variable value of the first variable is adjacent to the cache starting address of the data variable value of the second variable, the first variable is before the second variable, and the first variable is adjacent to the second variable.
[0034] In an embodiment of the present invention, when filling the data variable value of the data to be read into the callback function, the data variable name, DID, data type, data type size, variable data length, etc. in the data information table can be combined with the precision-processed data variable value output in the previous step, and the precision-processed data variable can be filled into the sending cache of the callback function according to the UDS specification.
[0035] Specifically, Figure 6 As shown in the figure, the specific steps to fill in the callback function include: (1) Decision 4: Determine whether the DID maps only one variable. (2) If a DID maps only one variable, then determine whether the mapped data is a single value or an array based on the length of the corresponding variable data, that is, judgment 5.
[0036] (3) If the variable data length is 1, it is single-value data. Read the data type and data type size corresponding to the single-value data variable to confirm how many bytes of cache a single data element takes up. According to the UDS specification: for multi-byte data types (such as unsigned 32 bits, unsigned 16 bits), the high-order byte is stored in the low-order index position, such as Figure 7 As shown in variable A or variable C. The data variable corresponding to the variable after precision processing is placed in the sending buffer of the DID callback according to the UDS specification.
[0037] (4) If the variable data length is greater than 1, it is array data. Read the data type and data type size corresponding to the array data variable, confirm how many bytes of cache a single array element takes up according to the UDS specification, and then put the precision-processed data variable corresponding to the variable into the send cache of the DID callback in the order of the array index from small to large. Figure 7 Variable B.
[0038] (5) If a DID number maps to multiple variables, a list is made according to the order in which the variables appear in the DID information table, and this list is used as input. Variable data is extracted according to the list index, the list index is initialized to 0, and judgment 6 is executed, that is, whether the current list index is less than the list length.
[0039] (6) If the current list index is less than the list length, enter the loop and determine whether the variable data length corresponding to each variable in the list is 1 according to judgment 7 to determine whether the corresponding variable in the list is a single value or an array. Then fill the precision-processed data corresponding to the variable into the sending buffer corresponding to the DID callback function in the order of the list. For the specific steps of filling in each variable data, refer to steps (7) and (8); (7) If the data length corresponding to the variable in the list is 1, it is single-value data. First, determine how many bytes of cache a single data element will occupy based on the data type and data type size corresponding to the single-value data variable. Then, according to the UDS specification, put the precision-processed data variable corresponding to the variable into the send cache of the DID callback. If there is already a variable stored in the cache, start storing it at the index after the cache, such as Figure 7 The relationship between variables A, B, and C is shown.
[0040] (8) If the variable data length in the list is greater than 1, it is array data. After confirming how many bytes of cache a single array element needs to occupy based on the data type and data type size corresponding to the array data variable, the precision-processed data variables corresponding to the variable are placed in the send cache of the DID callback in order from small to large array indexes. Each array element is stored according to the UDS specification. If there are variables stored in front of the cache, they are stored starting from the index after the cache, such as Figure 7 The relationship between variables A, B, and C is shown.
[0041] (9) After completing a single loop, the index is increased by 1 and the process returns to step 6. If the current list index is not less than the list length, the loop is exited.
[0042] (10) After completing the cache filling of all variables, the callback function is completed.
[0043] The embodiment of the present invention completes filling of the callback function through the data information of the data to be read, thereby ensuring that the data reading complies with the provisions of the UDS protocol.
[0044] As a possible implementation mode of the present invention, in this implementation mode, Figure 8 As shown, the data variable value is verified based on the preset verification rules, including: S801, determining a verification method for a data variable value based on a verification identifier stored in a data information table and corresponding to a data identifier; S802, using a verification method to verify the data variable value to obtain a verification result.
[0045] In an embodiment of the present invention, when verifying the data variable value, first read the DID in the data information table, whether verification is required, and the verification type information to determine whether the DID needs special verification. If verification is not required, the response code of the callback function is directly returned. If verification is required, the corresponding verification function that has been implemented in the traditional software is determined according to the verification type. Then the verification result (response code, that is, the return value of the verification function) is assigned to the return value of the callback, overwriting the default response code.
[0046] Furthermore, the data variable values after verification are called back by the data callback function, including: The data variable value is called back through the data callback function, and the verification result is returned. The verification result is used to indicate whether the data reading is successful.
[0047] The data access method provided by the present invention records the data information of the data to be accessed through the data information table, and generates a data callback function corresponding to the data identifier of each data to be read according to the data information. After the data variable value of the data to be read is obtained, the data variable value is filled into the data callback function, and the data variable value is verified according to the verification rule, and the verified data variable value is called back by the data callback function. When applied to the UDS protocol 22 service based on the standard AUTOSAR architecture, the operator can directly perform maintenance operations on the data information table, so as to realize data maintenance, which is convenient and fast, and data access is faster, and the amount of code can be reduced, saving code resources.
[0048] In order to better implement the 22 service implementation method of the UDS protocol in the embodiment of the present invention, based on the 22 service implementation method of the UDS protocol, correspondingly, Fig. 9 As shown, the embodiment of the present invention further provides a UDS protocol 22 service implementation device, and the UDS protocol 22 service implementation device 900 includes: The callback function generating module 901 is used to obtain a data identifier of the data to be read, and obtain a data callback function generated based on the data information table storing the data identifier based on the data identifier; A data acquisition module 902 is used to acquire the data variable value of the data to be read based on the data identifier, and fill the data variable value into the data callback function; The data callback module 903 is used to verify the data variable value based on the preset verification rule, and call back the verified data variable value through the data callback function.
[0049] The UDS protocol 22 service implementation device 900 provided in the above embodiment can implement the technical solution described in the above UDS protocol 22 service implementation method embodiment. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above UDS protocol 22 service implementation method embodiment, which will not be repeated here.
[0050] like Fig.10 As shown, the present invention also provides an electronic device 1000. The electronic device 1000 includes a processor 1001, a memory 1002 and a display 1003. Fig.10 Only some components of the electronic device 1000 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0051] In some embodiments, the processor 1001 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 1002, such as the 22 service implementation method of the UDS protocol in the present invention.
[0052] In some embodiments, processor 1001 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, processor 1001 may be local or remote. In some embodiments, processor 1001 may be implemented in a cloud platform. In some embodiments, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, a multi-cloud, etc., or any combination thereof.
[0053] In some embodiments, the memory 1002 may be an internal storage unit of the electronic device 1000, such as a hard disk or memory of the electronic device 1000. In other embodiments, the memory 1002 may also be an external storage device of the electronic device 1000, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 1000.
[0054] Furthermore, the memory 1002 may include both an internal storage unit of the electronic device 1000 and an external storage device. The memory 1002 is used to store application software installed in the electronic device 1000 and various data.
[0055] In some embodiments, the display 1003 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 1003 is used to display information of the electronic device 1000 and to display a visual user interface. The components 1001-1003 of the electronic device 1000 communicate with each other via a system bus.
[0056] In some embodiments, when the processor 1001 executes the data reading program in the memory 1002, the following steps may be implemented: Obtaining a data identifier of the data to be read, and obtaining, based on the data identifier, a data callback function generated based on a data information table storing the data identifier, wherein the data information of the data to be stored is stored in the data information table; Get the data variable value of the data to be read based on the data identifier, and fill the data variable value into the data callback function; The data variable value is verified based on the preset verification rules, and the verified data variable value is called back through the data callback function.
[0057] It should be understood that: when the processor 1001 executes the data reading program in the memory 1002, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.
[0058] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 1000 mentioned, and the electronic device 1000 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 1000 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0059] Correspondingly, an embodiment of the present invention also provides a computer-readable storage medium, which is used to store computer-readable programs or instructions. When the program or instructions are executed by a processor, it can implement the steps or functions in the 22 service implementation methods of the UDS protocol provided in the above-mentioned method embodiments.
[0060] Those skilled in the art can understand that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0061] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A method for implementing 22 services of a UDS protocol, characterized in that: include: Acquire a data identifier of the data to be read, and based on the data identifier, acquire a data callback function generated based on a data information table storing the data identifier; Acquire the data variable value of the data to be read based on the data identifier, and fill the data variable value into the data callback function; The data variable value is verified based on a preset verification rule, and the verified data variable value is called back through the data callback function.
2. The method for implementing the 22 services of the UDS protocol according to claim 1, characterized in that: The data information table contains the data identifier and the valid data length of the data to be read, and the data callback function generated based on the data information table storing the data identifier includes: Based on the data identifier of the data to be read and the valid data length, a data callback function corresponding to the data identifier is generated according to a preset architecture rule, and the data callback function is used to call back the data variable value of the data to be read.
3. The method for implementing the 22 services of the UDS protocol according to claim 2, characterized in that: The step of acquiring the data variable value of the data to be read based on the data identifier, and filling the data variable value into the data callback function includes: Acquire the data initial variable value of the data to be read based on the data identifier; Performing precision conversion on the initial data variable value according to a preset precision conversion rule to obtain a target data variable value; Fill the first address of the target data variable value into the sending buffer of the callback function according to the quantity and type of the target data variable value.
4. The method for implementing the 22 services of the UDS protocol according to claim 3, characterized in that: The step of performing precision conversion on the initial data variable value according to a preset precision conversion rule to obtain a target data variable value includes: Determine whether the variable corresponding to the data identifier is a historical variable according to the data variable name corresponding to the data identifier and the configuration information inheritance identifier stored in the data information table; When the variable corresponding to the data identifier is a historical variable, the historical precision conversion function corresponding to the historical variable is used to perform precision conversion on the initial data variable value to obtain the target data variable value; Otherwise, the precision conversion of the initial data variable value is performed according to the precision conversion function corresponding to the data identifier recorded in the data information table to obtain the target data variable value.
5. The method for implementing the 22 services of the UDS protocol according to claim 4, characterized in that: The step of filling the first address of the target data variable value into the sending buffer of the callback function according to the number and type of the target data variable value comprises: When the target data variable value corresponds to a variable, determining the cache head address and cache byte number of the target data variable based on the data length of the target data variable value; When the target data variable value corresponds to multiple variables, the cache starting addresses and cache byte numbers of the data variable values corresponding to the multiple variables are determined in sequence based on the positional relationship of the multiple variables in the data information table, wherein the cache tail address of the data variable value of the first variable is adjacent to the cache starting address of the data variable value of the second variable, the first variable is before the second variable, and the first variable is adjacent to the second variable.
6. The method for implementing the 22 services of the UDS protocol according to claim 1, characterized in that: The verifying the data variable value based on a preset verification rule includes: Determine a verification method for the data variable value based on a verification identifier stored in the data information table and corresponding to the data identifier; The verification method is used to verify the data variable value to obtain a verification result.
7. The method for implementing the 22 services of the UDS protocol according to claim 6, characterized in that: The data variable value after verification by the data callback function callback includes: The data variable value is called back through the data callback function, and the verification result is returned, and the verification result is used to indicate whether the data reading is successful.
8. A 22-service implementation device of the UDS protocol, characterized in that: include: A callback function generating module, used for obtaining a data identifier of the data to be read, and obtaining, based on the data identifier, a data callback function generated based on a data information table storing the data identifier; A data acquisition module, used for acquiring a data variable value of the data to be read based on the data identifier, and filling the data variable value into the data callback function; The data callback module is used to verify the data variable value based on a preset verification rule, and to call back the verified data variable value through the data callback function.
9. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the 22 service implementation method of the UDS protocol as described in any one of claims 1 to 7 above.
10. A computer-readable storage medium, characterized in that: Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps in the 22 service implementation method of the UDS protocol as described in any one of claims 1 to 7 above.