Message transmission method, device, electronic device and computer-readable storage medium
By analyzing the DBC file of the CAN network and generating callback function templates, the problem of low handwriting of callback function during message transmission in the AUTOSAR architecture is solved, and rapid generation and efficient transmission are achieved.
Patent Information
- Application Number
- CN202211650900.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-21
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2042-12-21
AI Technical Summary
In the AUTOSAR architecture, the handwritten callback function is used to implement the problem of large time consumption, low development efficiency and high error risk during the transmission of packets.
By obtaining the DBC file of the CAN network, analyzing the message information under the target network node, and generating a callback function based on the callback function template file to realize message transmission.
It realizes the rapid generation of callback functions, saves development time, improves development efficiency, and reduces the risk of errors.
Smart Images

Figure CN115967604B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a message transmission method, and also to a message transmission device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Currently, in the AUTOSAR architecture (AUTomotive Open Systems Architecture), the underlying layer provides corresponding callback functions for the sending and receiving of each message, and the function declaration is provided by the Com module in the BSW module (AUTOSAR basic software layer). In order to be more flexibly scheduled by multiple systems, these callback functions have not been implemented, and developers are required to implement corresponding functions for each interface. For example, when a certain signal needs special processing, the callback function can be used to implement the processing. However, under the same network node, the number of messages is generally not small. Handwriting code to implement callback functions will cause serious time occupancy, low development efficiency, and the risk of errors.
[0003] Therefore, how to realize the rapid generation of callback functions during message transmission, save development time, and improve development efficiency is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0004] The purpose of the present application is to provide a message transmission method, which can realize the rapid generation of callback functions during the message transmission process, save development time and improve development efficiency; another purpose of the present application is to provide a message transmission device, electronic device and computer-readable storage medium, all of which have the above-mentioned beneficial effects.
[0005] In a first aspect, the present application provides a message transmission method, the method comprising:
[0006] Get the DBC file of the CAN network and determine the target network node;
[0007] Parsing the DBC file to obtain message information under the target network node, wherein the message information includes message data information and message signal information;
[0008] Based on each callback function template file, generate each callback function using each message information;
[0009] The message transmission in the target network node is realized by using each of the callback functions.
[0010] Optionally, after parsing the DBC file to obtain the message information under the target network node, the method further includes:
[0011] The message information is written into a preset area according to a preset message sorting rule.
[0012] Optionally, generating each callback function based on each callback function template file and using each message information includes:
[0013] Parsing the callback function template file to determine the target message corresponding to the callback function template file;
[0014] Traversing and obtaining message information of the target message in the preset area;
[0015] Fill the message information into the callback function template file to obtain the callback function.
[0016] Optionally, before using each of the callback functions to implement message transmission in the target network node, the method further includes:
[0017] Parse the arxml configuration file to obtain the target message information;
[0018] Matching the target message information with the preset area, and determining a target callback function corresponding to the target message information;
[0019] Fill the interface name of the target callback function into the arxml configuration file.
[0020] Optionally, the method further comprises:
[0021] Obtaining a diagnostic event table about the target network node;
[0022] Parsing the diagnostic event table to obtain information about each diagnostic event;
[0023] Using keyword matching technology to write each of the diagnostic event information into the preset area;
[0024] In the preset area, generating a diagnostic event monitoring code for the message using message information and diagnostic event information of the same message;
[0025] The message monitoring in the target network node is implemented by utilizing each of the diagnostic event monitoring codes.
[0026] Optionally, the method further comprises:
[0027] Storing the definition part of the callback function and the definition part of the diagnostic event monitoring code in a code file area;
[0028] The declaration part of the callback function and the declaration part of the diagnostic event monitoring code are stored in the header file area.
[0029] Optionally, the message data information includes one or more of a message name, a message identifier, a message period, a message length, and a message sending and receiving node; the message signal information includes one or more of a signal name, LSB, MSB, signal length, signal byte order, signal symbol flag, signal factor, signal offset, signal maximum value, signal minimum value, signal enumeration value, and signal unit.
[0030] In a second aspect, the present application further discloses a message transmission device, the device comprising:
[0031] The acquisition module is used to obtain the DBC file of the CAN network and determine the target network node;
[0032] A parsing module, used to parse the DBC file to obtain the message information under the target network node, wherein the message information includes message data information and message signal information;
[0033] A generation module, used to generate each callback function based on each callback function template file and using each message information;
[0034] A transmission module is used to realize message transmission in the target network node by using each of the callback functions.
[0035] In a third aspect, the present application further discloses an electronic device, comprising:
[0036] Memory for storing computer programs;
[0037] A processor is used to implement the steps of any one of the message transmission methods described above when executing the computer program.
[0038] In a fourth aspect, the present application further discloses a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the message transmission methods described above are implemented.
[0039] The present application provides a message transmission method, including: obtaining a DBC file of a CAN network and determining a target network node; parsing the DBC file to obtain message information under the target network node, wherein the message information includes message data information and message signal information; based on each callback function template file, generating each callback function using each message information; and using each callback function to realize message transmission in the target network node.
[0040] By applying the technical solution provided in the present application, the DBC file in the CDN network is first obtained. For any network node in the CDN network, all message information under the network node can be parsed from the DBC file, including its own data information and signal information. Therefore, based on these message information and in combination with the pre-set callback function template file, various callback functions can be automatically generated, and then the message transmission in the corresponding network node can be realized based on these callback functions. Obviously, based on this implementation method, the automatic generation of callback functions during message transmission is realized, manual handwritten code is avoided, development time can be effectively saved, development efficiency can be improved, and the risk of errors caused by manual handwritten code can also be avoided to a certain extent.
[0041] The message transmission device, electronic device and computer-readable storage medium provided in this application also have the above-mentioned technical effects, which will not be elaborated in this application. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the prior art and the embodiments of the present application, the drawings required for use in the description of the prior art and the embodiments of the present application are briefly introduced below. Of course, the drawings described below in relation to the embodiments of the present application are only part of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work, and the obtained other drawings also belong to the protection scope of the present application.
[0043] Figure 1 A flowchart of a message transmission method provided by this application;
[0044] Figure 2 A flowchart of another message transmission method provided by the present application;
[0045] Figure 3 A schematic diagram of the structure of a message transmission device provided by the present application;
[0046] Figure 4 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0047] The core of the present application is to provide a message transmission method, which can realize the rapid generation of callback functions during the message transmission process, save development time and improve development efficiency; another core of the present application is to provide a message transmission device, electronic device and computer-readable storage medium, all of which have the above-mentioned beneficial effects.
[0048] In order to describe the technical solutions in the embodiments of the present application more clearly and completely, the technical solutions in the embodiments of the present application will be introduced below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0049] An embodiment of the present application provides a message transmission method.
[0050] Please refer to Figure 1 , Figure 1 This is a flow chart of a message transmission method provided in the present application. The message transmission method may include the following S101 to S104.
[0051] S101: Obtain the DBC file of the CAN network and determine the target network node.
[0052] This step aims to achieve the acquisition of DBC file (DatabaseCan, database file in CAN) and the determination of target network node. Among them, DBC file is a database file in CAN network (ControllerArea Network), which defines the message and signal information of CAN communication and can be provided by the user; the target network node is a node device in CAN network, which can be any network node in CAN network, and the user can select it according to actual needs. In the implementation process, the user can input the DBC file and select the target network node through the user terminal.
[0053] S102: Parse the DBC file to obtain message information under the target network node, where the message information includes message data information and message signal information.
[0054] This step aims to implement the parsing of the DBC file to obtain all the message information under the target network node, and the message information is used to realize the automatic generation of the callback function. As mentioned above, the DBC file is a database file in the CAN network, which defines the message and signal information of the CAN communication. Therefore, the DBC file contains the message information of all network nodes in the CAN network. Therefore, according to the relevant information of the target network node (such as node name, node address, node identification, etc.), the message information under the target network node can be parsed from the DBC file.
[0055] Among them, the message information includes message data information and message signal information. In a possible implementation, the message data information may include one or more of the message name, message identifier, message period, message length, and message transceiver node; the message signal information may include one or more of the signal name, LSB (Least Significant Bit), MSB (Most Significant Bit), signal length, signal byte order, signal symbol flag, signal factor, signal offset, signal maximum value, signal minimum value, signal enumeration value, and signal unit. It should be noted that since the message information has the byte order of Motorola (big endian mode, high bit in low byte, low bit in high byte) and Intel (little endian mode, low bit in low byte, high bit in high byte) format, the above MSB and LSB can be obtained by parsing according to the byte order format of the signal.
[0056] S103: Generate each callback function based on each callback function template file and using each message information.
[0057] This step aims to realize the automatic generation of callback functions based on message information. Specifically, callback function template files corresponding to various types of messages can be pre-configured. After obtaining the message information of various types of messages, for each type of message, the corresponding callback function can be automatically generated using its message information and the corresponding callback function template file, thereby realizing the automatic generation of callback functions corresponding to each type of message without manual handwriting of code.
[0058] S104: Utilize each callback function to realize message transmission in the target network node.
[0059] This step aims to realize message transmission. After obtaining the callback functions corresponding to various messages, that is, after completing the development of various callback functions under the target network node, each callback function can be applied to the message transmission process, that is, using each callback function to realize message transmission in the target network node.
[0060] It can be seen that the message transmission method provided in the embodiment of the present application first obtains the DBC file in the CDN network. For any network node in the CDN network, all message information under the network node can be parsed from the DBC file, including its own data information and signal information. Therefore, based on these message information, combined with the pre-set callback function template file, various callback functions can be automatically generated, and then based on these callback functions, the message transmission in the corresponding network node is realized. Obviously, based on this implementation method, the automatic generation of callback functions in the message transmission process is realized, and manual handwritten code is avoided, which can effectively save development time and improve development efficiency. At the same time, it can also avoid the risk of errors caused by manual handwritten code to a certain extent.
[0061] Based on the above embodiments:
[0062] In one embodiment of the present application, after parsing the DBC file to obtain the message information under the target network node, the method may further include: writing each message information into a preset area according to a preset message sorting rule.
[0063] In an embodiment of the present application, after obtaining all message information under the target network node, each message information can be written into a pre-created storage area according to a preset message sorting rule. In a possible implementation, the preset area can be in a table form, such as an Excel table, and each row in the Excel table corresponds to recording the message information of a class of messages, and each column records the same type of information indicators (such as the message name, message period, etc. as described above). Among them, the preset message sorting rule can be customized by the user according to the actual situation. For example, it can be written in sequence according to the message name of the message, or in sequence according to the identifier of the message (such as ID information), etc., and this application does not limit this.
[0064] It is understandable that by recording the message information in the form of a table, it is easier to search and traverse the required target information when various data messages are used later.
[0065] In one embodiment of the present application, the above-mentioned generation of each callback function based on each callback function template file and using each message information may include the following steps:
[0066] Parse the callback function template file to determine the target message corresponding to the callback function template file;
[0067] Traverse and obtain message information of the target message in the preset area;
[0068] Fill the message information into the callback function template file to obtain the callback function.
[0069] The embodiment of the present application provides a method for generating a callback function. It is understandable that the callback function template file is a pre-set template file that does not contain message information, and the callback function needs to be filled with message information to realize the generation of the callback function. Based on this, the callback function template file can be parsed first to determine the target message corresponding to the callback function template file, that is, to determine which type of message the callback function template file is used to generate, and then query and traverse from the preset area to obtain the message information corresponding to the target message, thereby filling the message information of the target message into the corresponding position in the callback function template file corresponding to the target message, and then obtaining the callback function corresponding to the target message, thereby realizing the automatic generation of the callback function.
[0070] In one embodiment of the present application, before the above-mentioned use of each callback function to implement message transmission in the target network node, the following steps may also be included:
[0071] Parse the arxml configuration file to obtain the target message information;
[0072] Match the target message information with the preset area, and determine the target callback function corresponding to the target message information;
[0073] Fill the interface name of the target callback function into the arxml configuration file.
[0074] It should be noted that if the automatically generated callback function is to be used to perform the message transmission operation in the target network node, it needs to be further configured. In the existing implementation, since various callback functions are not defined in the AUTOSAR specification, the developer needs to manually configure the function name in the tool chain, which is inefficient. Therefore, in order to solve this technical problem, the message transmission method provided in the embodiment of the present application can also realize the automatic configuration of the callback function.
[0075] First, obtain the arxml configuration file in the AUTOSAR architecture. The arxml configuration file is a common configuration file in the AUTOSAR architecture and is used to implement the configuration of the callback function. Then, parse the arxml configuration file to obtain the target message information, that is, the message information of the message corresponding to the arxml configuration file. Thus, the target message information can be matched with various message information in the preset area, and then the callback function corresponding to the message information in the preset area that matches the target message information is determined, thereby realizing the determination of the target callback function corresponding to the target message information. Finally, fill the interface name of the target callback function into the corresponding position of the arxml configuration file to realize the automatic configuration of the callback function.
[0076] Obviously, this implementation method realizes the automatic configuration of the callback function without manual operation, which can effectively improve the configuration efficiency of the callback function and further improve the development efficiency.
[0077] In one embodiment of the present application, the message transmission method may further include the following steps:
[0078] Obtain a diagnostic event table about a target network node;
[0079] Parse the diagnostic event table to obtain information about each diagnostic event;
[0080] Using keyword matching technology to write each diagnostic event information into a preset area;
[0081] In the preset area, a diagnostic event monitoring code for the message is generated using the message information and the diagnostic event information of the same message;
[0082] Utilize each diagnostic event monitoring code to implement message monitoring in the target network node.
[0083] The message transmission method provided in the embodiment of the present application can also realize the automatic generation of diagnostic event monitoring code, so as to realize message monitoring in the target network node by using the diagnostic event monitoring code.
[0084] In the implementation process, first obtain the diagnostic event table under the target network node, which records various diagnostic events that have occurred in various messages under the target network node. By parsing it, the relevant information of various diagnostic events can be obtained, that is, the above-mentioned diagnostic event information, which may include but is not limited to event type, event name, and message to which it belongs. Further, using keyword matching technology, each diagnostic event information is written to the corresponding position of the preset area, wherein the keyword can be the message name. Taking the Excel table as an example, for a certain diagnostic event information, the message name of the message to which the diagnostic event belongs can be determined from the diagnostic event information, and then the table row where the corresponding message is located is matched in the Excel table according to the message name, and then the diagnostic event information is written to the table row. Finally, in the Excel table, the message information and diagnostic event information of the corresponding message are recorded in each table row, thereby, the two can be used to realize the automatic generation of the diagnostic event monitoring code corresponding to the message, and the diagnostic event monitoring code is used to realize the message monitoring during the message transmission process in the target network node. Among them, message monitoring mainly includes monitoring the timeout and signal validity of the corresponding message, which can be implemented based on the checksum signal and rollingcounter signal in the message signal information respectively.
[0085] In one embodiment of the present application, the message transmission method may further include the following steps:
[0086] Store the definition part of the callback function and the definition part of the diagnostic event monitoring code in the code file area;
[0087] The declaration part of the callback function and the declaration part of the diagnostic event monitoring code are stored in the header file area.
[0088] The message transmission method provided in the embodiment of the present application can further realize the automatic storage of program code, that is, the definition parts of the callback function and the diagnostic event monitoring code are stored in the code file area, such as the cpp file, and the declaration parts of the callback function and the diagnostic event monitoring code are stored in the header file area, such as the h file, so that they can be directly called in the code file area and the header file area when used.
[0089] Based on the above embodiments, an embodiment of the present application provides another message transmission method.
[0090] Please refer to Figure 2 , Figure 2 A schematic diagram of a flow chart of another message transmission method provided in the present application. The implementation process of the message transmission method may include:
[0091] Step 1: According to the DBC file provided by the customer and the selected network node to be parsed (target network node), parse the message information under the network node, such as the message name, identifier ID, cycle, length, sending and receiving nodes and other message data information, signal name, LSB, MSB, length, byte order, symbol flag, factor, offset, maximum value, minimum value, enumeration value, unit and other message signal information, organize all the parsed information into an array, sort them by message name and store them in an Excel table.
[0092] Step 2: parse the diagnostic event table provided by the diagnostic department. Use the message name and signal name as keywords to match the information. Match the parsed diagnostic event information with the message information one by one and store them in an Excel table.
[0093] Step 3. At this time, the content of the Excel table is complete. According to the Excel table, traverse all the messages, generate callback functions one by one according to the corresponding callback function template files, and generate diagnostic event monitoring code at the same time. Store the definition part of the callback function and the diagnostic event monitoring code in the cpp file, and store the external declaration of the callback function and the diagnostic event monitoring code in the h file.
[0094] Step 4: Parse the com-related arxml configuration file, traverse all the messages according to the excel table, find the corresponding message information and signal information in the arxml file, and fill in the callback function name. At the same time, the AUTOSAR tool chain will also be updated in real time to complete the configuration of the callback function.
[0095] So far, the automatic generation and automatic configuration of callback functions for message transmission in the CAN network and the automatic generation of diagnostic event monitoring codes have been realized. Therefore, the callback functions can be used to implement message transmission operations, and the diagnostic event monitoring codes can be used to implement message monitoring operations during message transmission.
[0096] It can be seen that the message transmission method provided in the embodiment of the present application first obtains the DBC file in the CDN network. For any network node in the CDN network, all message information under the network node can be parsed from the DBC file, including its own data information and signal information. Therefore, based on these message information, combined with the pre-set callback function template file, various callback functions can be automatically generated, and then based on these callback functions, the message transmission in the corresponding network node is realized. Obviously, based on this implementation method, the automatic generation of callback functions in the message transmission process is realized, and manual handwritten code is avoided, which can effectively save development time and improve development efficiency. At the same time, it can also avoid the risk of errors caused by manual handwritten code to a certain extent.
[0097] An embodiment of the present application provides a message transmission device.
[0098] Please refer to Figure 3 , Figure 3 A schematic diagram of the structure of a message transmission device provided in the present application, the message transmission device may include:
[0099] Acquisition module 1, used to acquire the DBC file of the CAN network and determine the target network node;
[0100] Parsing module 2 is used to parse the DBC file to obtain the message information under the target network node, the message information includes message data information and message signal information;
[0101] A generating module 3, used for generating each callback function based on each callback function template file and using each message information;
[0102] The transmission module 4 is used to realize the message transmission in the target network node by using each callback function.
[0103] It can be seen that the message transmission device provided in the embodiment of the present application first obtains the DBC file in the CDN network. For any network node in the CDN network, all message information under the network node can be parsed from the DBC file, including its own data information and signal information. Therefore, based on these message information, combined with the pre-set callback function template file, various callback functions can be automatically generated, and then based on these callback functions, the message transmission in the corresponding network node is realized. Obviously, based on this implementation method, the automatic generation of callback functions in the message transmission process is realized, and manual handwritten code is avoided, which can effectively save development time and improve development efficiency. At the same time, it can also avoid the risk of errors caused by manual handwritten code to a certain extent.
[0104] In one embodiment of the present application, the message transmission device may further include a writing module for writing each message information into a preset area according to a preset message sorting rule after parsing the DBC file as described above and obtaining the message information under the target network node.
[0105] In one embodiment of the present application, the above-mentioned generation module 3 can be specifically used to parse the callback function template file, determine the target message corresponding to the callback function template file; traverse the preset area to obtain the message information of the target message; fill the message information into the callback function template file to obtain the callback function.
[0106] In one embodiment of the present application, the message transmission device may also include a configuration module, which is used to parse the ARXML configuration file to obtain the target message information before using each callback function to realize the message transmission in the target network node; match the target message information with the preset area to determine the target callback function corresponding to the target message information; and fill the interface name of the target callback function into the ARXML configuration file.
[0107] In one embodiment of the present application, the message transmission device may also include a monitoring module for obtaining a diagnostic event table about a target network node; parsing the diagnostic event table to obtain information about each diagnostic event; using keyword matching technology to write each diagnostic event information into a preset area; in the preset area, using the message information and diagnostic event information of the same message to generate a diagnostic event monitoring code about the message; and using each diagnostic event monitoring code to implement message monitoring in the target network node.
[0108] In one embodiment of the present application, the message transmission device may also include a storage module for storing the definition part of the callback function and the definition part of the diagnostic event monitoring code in the code file area; and storing the declaration part of the callback function and the declaration part of the diagnostic event monitoring code in the header file area.
[0109] In one embodiment of the present application, the message data information may include one or more of the message name, message identifier, message period, message length, and message sending and receiving nodes; the message signal information may include one or more of the signal name, LSB, MSB, signal length, signal byte order, signal symbol flag, signal factor, signal offset, signal maximum value, signal minimum value, signal enumeration value, and signal unit.
[0110] For an introduction to the device provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.
[0111] An embodiment of the present application provides an electronic device.
[0112] Please refer to Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in this application, and the electronic device may include:
[0113] Memory for storing computer programs;
[0114] A processor, which is used to implement the steps of any one of the above-mentioned message transmission methods when executing a computer program.
[0115] like Figure 4 , which is a schematic diagram of the composition structure of an electronic device, the electronic device may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13. The processor 10, the memory 11 and the communication interface 12 all communicate with each other through the communication bus 13.
[0116] In the embodiment of the present application, the processor 10 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic devices, etc.
[0117] The processor 10 may call a program stored in the memory 11. Specifically, the processor 10 may execute operations in the embodiment of the message transmission method.
[0118] The memory 11 is used to store one or more programs, which may include program codes, and the program codes include computer operation instructions. In the embodiment of the present application, the memory 11 at least stores programs for implementing the following functions:
[0119] Get the DBC file of the CAN network and determine the target network node;
[0120] Parse the DBC file to obtain the message information under the target network node, which includes message data information and message signal information;
[0121] Based on each callback function template file, each callback function is generated using each message information;
[0122] Each callback function is used to realize message transmission in the target network node.
[0123] In a possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.
[0124] In addition, the memory 11 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.
[0125] The communication interface 12 may be an interface of a communication module, and is used to connect to other devices or systems.
[0126] Of course, it should be noted that Figure 4 The structure shown does not constitute a limitation on the electronic device in the embodiment of the present application. In actual applications, the electronic device may include Figure 4 More or fewer components than shown, or combinations of certain components.
[0127] An embodiment of the present application provides a computer-readable storage medium.
[0128] The computer-readable storage medium provided in the embodiment of the present application stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned message transmission methods can be implemented.
[0129] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0130] For an introduction to the computer-readable storage medium provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.
[0131] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0132] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0133] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0134] The technical solution provided by the present application is described in detail above. The principle and implementation method of the present application are described in detail using specific examples herein, and the description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
Claims
1. A message transmission method, characterized in that: The method comprises: Obtaining a DBC file of a CAN network and determining a target network node; the target network node is any network node in the CAN network, and the DBC file contains message information of all the network nodes in the CAN network; Parsing the DBC file to obtain message information under the target network node, wherein the message information includes message data information and message signal information; Writing each of the message information into a preset area according to a preset message sorting rule; Based on each callback function template file, generate each callback function using each message information; Using each of the callback functions to implement message transmission in the target network node; Obtaining a diagnostic event table about the target network node; Parsing the diagnostic event table to obtain information about each diagnostic event; Using keyword matching technology to write each of the diagnostic event information into the preset area; In the preset area, generating a diagnostic event monitoring code for the message using message information and diagnostic event information of the same message; Each of the diagnostic event monitoring codes is used to implement message monitoring in the target network node; the message monitoring includes message timeout monitoring and message signal validity monitoring.
2. The method according to claim 1, characterized in that The method of generating each callback function based on each callback function template file and using each message information comprises: Parsing the callback function template file to determine the target message corresponding to the callback function template file; Traversing and obtaining message information of the target message in the preset area; Fill the message information into the callback function template file to obtain the callback function.
3. The method according to claim 1, characterized in that Before the use of each of the callback functions to realize the message transmission in the target network node, the method further includes: Parse the arxml configuration file to obtain the target message information; Matching the target message information with the preset area, and determining a target callback function corresponding to the target message information; Fill the interface name of the target callback function into the arxml configuration file.
4. The method according to claim 1, characterized in that: Also includes: Storing the definition part of the callback function and the definition part of the diagnostic event monitoring code in a code file area; The declaration part of the callback function and the declaration part of the diagnostic event monitoring code are stored in the header file area.
5. The method according to claim 1, characterized in that The message data information includes one or more of a message name, a message identifier, a message period, a message length, and a message sending and receiving node; the message signal information includes one or more of a signal name, an LSB, an MSB, a signal length, a signal byte order, a signal symbol flag, a signal factor, a signal offset, a signal maximum value, a signal minimum value, a signal enumeration value, and a signal unit.
6. A message transmission device, characterized in that: include: An acquisition module is used to acquire a DBC file of a CAN network and determine a target network node; the target network node is any network node in the CAN network, and the DBC file contains message information of all the network nodes in the CAN network; A parsing module, used to parse the DBC file to obtain the message information under the target network node, wherein the message information includes message data information and message signal information; A writing module, used to write each message information into a preset area according to a preset message sorting rule; A generation module, used to generate each callback function based on each callback function template file and using each message information; A transmission module, used for implementing message transmission in the target network node by using each of the callback functions; A monitoring module, used for obtaining a diagnostic event table about the target network node; Parsing the diagnostic event table to obtain information about each diagnostic event; Using keyword matching technology to write each of the diagnostic event information into the preset area; In the preset area, generating a diagnostic event monitoring code for the message using message information and diagnostic event information of the same message; Each of the diagnostic event monitoring codes is used to implement message monitoring in the target network node; the message monitoring includes message timeout monitoring and message signal validity monitoring.
7. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the message transmission method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the message transmission method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Method and device for automatically generating CAN communication protocol code
CN106603482A