Code generation method and device under AutoSar framework, electronic equipment and storage medium

Through the code generation method under the AutoSar framework, communication protocol files and routing forwarding tables are automatically updated to generate new communication file codes, which solves the problem of low code update efficiency in vehicle software development and achieves fast and efficient code generation and updates. .

CN118778934APending Publication Date: 2024-10-15CHONGQING CHANGAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410849074.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

During the entire vehicle software development process, frequent updates of communication protocol files lead to low code update efficiency. The existing technology requires engineers to manually rewrite or adjust the code, which is time-consuming and error-prone.

Method used

Provides a code generation method under the AutoSar framework. By obtaining communication protocol files and routing forwarding tables, verifying and extracting message information and signal information, registering to the interface layer, routing layer and communication layer, a new communication file code is generated. Implement automatic updates.

Benefits of technology

It greatly improves the efficiency of communication protocol file code generation, reduces engineer intervention, reduces the probability of manual errors, and shortens the code update time from minutes to seconds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118778934A_ABST
    Figure CN118778934A_ABST
Patent Text Reader

Abstract

The invention relates to a code generation method and device under an AutoSar framework, electronic equipment and a storage medium. The method comprises the steps that a communication protocol file and a routing forwarding table used for generating codes are acquired; verifying the communication protocol file and the route forwarding table through a verification module; under the condition that verification is passed, message information and signal information of the communication protocol file are extracted through an extraction module; registering the message information to an interface layer, a routing layer and a communication layer through a registration module, and registering the signal information to the communication layer to obtain sub-message information and sub-signal information; extracting routing information of a routing forwarding table through a routing registration module; and generating a communication file code of the communication protocol file according to the sub-message information, the sub-signal information and the routing information. The updating efficiency of the file code of the communication protocol file can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of vehicle software development, and specifically to a code generation method, device, electronic device and storage medium under the AutoSar framework. Background Art

[0002] In the prior art, in the process of vehicle software development, the communication protocol file is usually converted into a code file, and then the code file is used to provide the vehicle software service. Since the vehicle software is updated quickly and the functions are updated quickly, the communication protocol file is frequently updated. The frequent update of the communication protocol file will directly affect the code, and the code must also be updated frequently.

[0003] In the prior art, after a communication protocol file is updated, engineers are required to rewrite or adjust the code file based on the updated communication protocol file and the framework of vehicle software development. This method results in low efficiency in updating the file code of the communication protocol file. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a code generation method, device, electronic device and storage medium under the AutoSar framework.

[0005] In the first aspect, the present application provides a code generation method under the AutoSar framework, characterized in that the method includes: obtaining a communication protocol file and a routing table for generating code; verifying the communication protocol file and the routing table through a verification module; if the verification passes, extracting the message information and signal information of the communication protocol file through an extraction module; registering the message information to the interface layer, routing layer and communication layer through a registration module, and registering the signal information to the communication layer to obtain sub-message information and sub-signal information; extracting the routing information of the routing table through a routing registration module; generating a communication file code of the communication protocol file according to the sub-message information, the sub-signal information and the routing information.

[0006] In the second aspect, the present application provides a code generation device under the AutoSar framework, characterized in that the above-mentioned device includes: an acquisition module, used to acquire a communication protocol file and a routing table for generating code; a verification module, used to verify the above-mentioned communication protocol file and the above-mentioned routing table through the verification module; a first extraction module, used to extract the message information and signal information of the above-mentioned communication protocol file through the extraction module when the verification passes; a registration module, used to register the above-mentioned message information to the interface layer, routing layer and communication layer through the registration module, and register the above-mentioned signal information to the above-mentioned communication layer to obtain sub-message information and sub-signal information; a second extraction module, used to extract the routing information of the above-mentioned routing table through the routing registration module; a generation module, used to generate the communication file code of the above-mentioned communication protocol file according to the above-mentioned sub-message information, the above-mentioned sub-signal information and the above-mentioned routing information.

[0007] In a third aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0008] Memory, used to store computer programs;

[0009] The processor is used to implement the steps of the code generation method under the AutoSar framework mentioned above in any embodiment of the first aspect when executing the program stored in the memory.

[0010] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the code generation method under the AutoSar framework as described in any one of the embodiments of the first aspect.

[0011] Beneficial effects of this application:

[0012] The method provided by the embodiment of the present application obtains a communication protocol file and a routing table for generating a code; verifies the communication protocol file and the routing table through a verification module; extracts the message information and signal information of the communication protocol file through an extraction module when the verification passes; registers the message information to the interface layer, the routing layer and the communication layer through a registration module, and registers the signal information to the communication layer to obtain sub-message information and sub-signal information; extracts the routing information of the routing table through a routing registration module; generates a communication file code of the communication protocol file according to the sub-message information, the sub-signal information and the routing information, so that when the communication protocol file changes, the data in the communication protocol file and the routing table can be automatically verified according to the changed communication protocol file, so that when the verification passes, the message information and signal information are extracted, and the sub-message information and sub-signal information are registered, and a new communication file code is generated according to the sub-message information, the sub-signal information and the routing information in the routing table, thereby achieving the purpose of automatically generating the communication file code according to the communication protocol file and improving the generation efficiency of the file code of the communication protocol file. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0014] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0015] Figure 1 A system architecture diagram of a code generation method under the AutoSar framework provided in one embodiment of the present application;

[0016] Figure 2 A flowchart of a code generation method under the AutoSar framework provided in one embodiment of the present application;

[0017] Figure 3 A flowchart of another code generation method under the AutoSar framework provided in one embodiment of the present application;

[0018] Figure 4 A schematic diagram of the structure of a code generation device under the AutoSar framework provided in one embodiment of the present application;

[0019] Figure 5A schematic diagram of the structure of an electronic device provided for one embodiment of the present application. DETAILED DESCRIPTION

[0020] The following will describe the implementation methods of the present application with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, not for limiting the scope of protection of the present application.

[0021] In the prior art, in the process of vehicle software development, the communication protocol file is usually converted into a code file, and then the code file is used to provide the service of the vehicle software. Since the vehicle software is updated quickly and the functions are updated quickly, the communication protocol file will be updated frequently. The frequent updates of the communication protocol file will directly affect the code, and the code must also be updated frequently. After the communication protocol file is updated, engineers need to rewrite or adjust the code file according to the updated communication protocol file and the framework of vehicle software development. This method results in low efficiency in updating the file code of the communication protocol file.

[0022] If the software is written manually by engineers, this method is time-consuming and laborious, and is only suitable for small projects, and few people choose it. If the configuration software is used, the communication file is imported into the software, and the corresponding layers of code are automatically generated, there are several issues to consider: 1. The software is large in size. In addition to the communication files to be generated (If layer, PduR layer, Com layer), it also includes a full set of modules under the Autosar framework (more than 50 in number). Therefore, in actual use, it takes three to four minutes to open the software each time, two to three minutes to re-import the communication file, and three to four minutes to regenerate the code, which is very time-consuming. When using the configuration software, each time the communication file is re-imported, the code will only be generated according to the default configuration. For example, some specific messages will be defined as diagnostic messages and network management messages (such messages are different in the specific attributes of the message and the routing path of the PduR layer). In the configuration software, they will be defaulted to ordinary messages, and engineers need to intervene and configure them on demand. If the code template generated by the configuration software is fixed, some code templates need to be adjusted according to the needs of the development process. Therefore, the code generated by the configuration software cannot directly replace the engineering code, and engineers need to intervene and merge it as needed. In summary, the time for generating communication file codes in the prior art is measured in hours, and it involves the intervention of many engineers, which greatly increases the probability of errors caused by human intervention.

[0023] In order to solve the problem of low update efficiency of communication file code of communication protocol file, the first embodiment of the present application provides a code generation method under the AutoSar framework, which can be applied to Figure 1 The system architecture shown includes at least a vehicle 101 and a server 102 , and the vehicle 101 and the server 102 establish a communication connection.

[0024] The method can be applied to the vehicle 101 or the server 102 in the system architecture, wherein the type of the vehicle 101 is not limited, for example, it can be an electric vehicle (EV), a battery electric vehicle (BEV), a fuel cell electric vehicle (FCEV), a plug-in hybrid electric vehicle (PHEV), and a hybrid electric vehicle (HEV). The vehicle 101 to which the method is applied can be referred to as a target vehicle, and the server 102 can be a local server, a cloud server, or a server cluster.

[0025] If the method is applied in the vehicle 101, the communication protocol file and the routing table can be obtained from the server 102, and the communication file code can be generated according to the above method. If the method is applied in the server 102, the communication protocol file and the routing table can be obtained by the server 102, and the communication file code can be generated according to the above method, and the generated communication file code can be sent to the vehicle 101.

[0026] In this embodiment, (AUTomotive Open System ARchitecture) is a general software framework for vehicle development. Under this framework, CAN communication protocol and LIN communication protocol can be used as the main communication protocol between each sub-device node and the vehicle control unit (VCU). The communication protocol file of this embodiment can be a file generated during the vehicle service development process. Due to the development of vehicle services, the communication protocol file will change frequently. At this time, the code generation method of this embodiment can greatly improve the efficiency of generating communication file code.

[0027] The specific idea is to mark which messages need special processing through the configuration file (configure once, no additional processing is required later); the template for code generation can be customized according to the project. After adaptation once, each generated code can be directly replaced in the project. No engineer intervention is required throughout the process, and the time consumed for one code generation is compressed to less than 10 seconds. And because when the communication file is updated, the sequence number of the message data in each layer will change, and the mapping relationship between the sequence numbers between layers will also change, so the code of each layer can be updated correctly.

[0028] The following is an explanation of the communication protocol file: In the communication protocol file, each node on the CAN bus and LIN bus is defined, such as each sub-device node and VCU node. The communication message ID, frequency, transmission cycle, data parsing format, and communication topology relationships such as the receiver and sender of the communication between each node are also defined.

[0029] The communication protocol file contains three types of files:

[0030] DBC (DataBase Can) file that describes CAN data and corresponding node information.

[0031] LDF (Lin Description File) file that describes LIN data and corresponding node information.

[0032] A routing table that describes the routing and forwarding relationship of messages between nodes.

[0033] In this embodiment, a communication protocol data unit (Protocol Data Unit, PDU) may be used to refer to a message defined in a communication protocol file.

[0034] In this embodiment, under the AutoSar framework, according to the description of PDU in the communication file, the message will be registered in sequence to:

[0035] Interface Layer (If): It is connected to the underlying hardware driver layer downward and the PduR layer upward. The PDU corresponding to this layer can be sent and received directly through the underlying interface. This layer registers each communication message as If_PDU through the communication file, and allocates its corresponding physical channel, message ID, data format, position If_ID in this layer, and the PduR_ID of the PduR_PDU corresponding to the corresponding PduR layer. Subsequent layers access the If_PDU of this layer through If_ID. This layer notifies the PduR layer through PduR_ID for subsequent processing.

[0036] Routing layer (PDU Routing Layer, PduR): It is connected to the If layer downward and the Com layer upward. This layer defines the routing information PduR_PDU based on the description of the topological relationship in the communication file, and determines which layer the message received from the If layer or the message sent by the Com layer flows to. For example, the message received from the If layer can be uploaded to the Com layer to notify the application layer for processing; it can also be transferred back to the message sent by the If layer for a same-layer forwarding without uploading it to the Com layer. This is all determined by PduR_PDU. PduR_PDU defines which layer is called and the ID of the PDU in that layer. It also defines which layers it will call next and the ID of the corresponding PDU in the corresponding layer, as well as its own position PduR_ID in this layer.

[0037] Communication Layer (Com): It is connected to the PduR layer downward and the application layer upward. It obtains the received data from the PduR layer, and according to the data format defined in the communication file, it subdivides the message into various signals (for example, a message may contain 8 bytes of data, the first byte stores the air conditioner temperature, the second byte stores the motor speed, etc. Different variable bodies are used to store data such as air conditioner temperature and motor speed. The AutoSar framework names this body as a signal), and provides the application layer with signal data that can be directly used, updated in real time, and is independent of the bottom layer. At the same time, the application layer can also use the interface provided by the Com layer to directly send related signals to the physical channel corresponding to the message to which the signal belongs. The Com_Pdu of the Com layer defines its own position Com_ID in this layer, the sending and receiving direction of the message, the signal contained in the message, and the corresponding PduR layer PduR_ID.

[0038] Next, based on the system architecture, the code generation method under the AutoSar framework is described in detail. Figure 2 is a flow chart of a code generation method under the AutoSar framework of this embodiment, such as Figure 2 As shown, the code generation method under the above AutoSar framework includes:

[0039] Step 201, obtaining a communication protocol file and a routing table for generating a code;

[0040] In this embodiment, the communication protocol file used to generate the code may be a DBC file or an LDF file, or both files may be included. In addition, the routing table may be located in the communication protocol file and obtained together, or may be obtained separately.

[0041] Step 202, verifying the communication protocol file and the routing table by a verification module;

[0042] After obtaining the communication protocol file and the routing table, the communication protocol file and the routing table need to be verified, and the verification can be performed by a verification module.

[0043] There are many aspects to verifying communication protocol files and routing tables.

[0044] In one embodiment, verifying the communication protocol file by a verification module includes: determining description information of a forwarding message from the communication protocol file; determining the forwarding message from the routing forwarding table; and verifying whether the description information includes the forwarding message.

[0045] When verifying the communication protocol file through the verification module, two aspects are included. This embodiment is the first aspect, which includes checking whether the forwarding message described in the routing forwarding table is defined in the DBC and LDF communication protocol files. In this embodiment, the DBC and LDF communication protocol files can be traversed to find the relevant information of the forwarding message. If the relevant information can be found, the relevant information found is compared with the forwarding message of the routing forwarding table. If the two are consistent, it means that the forwarding message is defined in the DBC and LDF communication protocol files. If the forwarding message is not defined in the DBC and LDF communication protocol files, the communication protocol file verification fails.

[0046] In one embodiment, verifying the communication protocol file by the verification module includes: acquiring variables used by the application layer interface of the pre-engineering code by scanning the pre-engineering code; and verifying whether the variables are correctly defined in the communication protocol file.

[0047] When verifying the communication protocol file through the verification module, two aspects are included. This embodiment is the second aspect, which includes scanning the current project code, traversing and querying the variables used by each application layer interface, and whether they are correctly defined in the communication protocol file. In this embodiment, the current project code is the project code corresponding to the communication protocol file of this time, and the project code is traversed to find the traversal used by the application layer interface, and the communication protocol file is traversed to check whether the variable is correctly defined in the communication protocol file.

[0048] In one embodiment, verifying the routing table through a verification module includes: obtaining node information of forwarding nodes in the routing table; obtaining the topological relationship between nodes in the communication protocol file; and verifying whether the node information matches the topological relationship between nodes.

[0049] When the routing table is verified by the verification module, two aspects are included. This embodiment is the first aspect, which includes checking whether the forwarding node conforms to the node topology relationship defined in DBC and LDF. The routing table includes forwarding nodes and forwarding routes. The defined node topology relationship is obtained from DBC and LDF, and the topology relationship is checked with the forwarding node in the routing table to see if they are consistent. If they are inconsistent, the routing table verification fails.

[0050] In one embodiment, verifying the routing forwarding table by using a verification module includes: obtaining the node-to-node relationship of the forwarding nodes in the routing forwarding table; and verifying whether a closed loop exists in the forwarding nodes by using the node-to-node relationship.

[0051] When the routing table is verified by the verification module, two aspects are included. This embodiment is the second aspect, which includes checking whether there is a closed loop in the forwarding. In a closed loop, a frame message will cause infinite forwarding between a group of messages, resulting in failure to sleep and waste of network resources. In the routing table, if there is a closed loop forwarding path, the message will be forwarded in a loop within the closed loop, which will always waste network resources. Therefore, it is necessary to check whether the routing table contains a closed loop path.

[0052] After the above verification, if the routing table and communication protocol files pass the verification, you can proceed to the subsequent steps. If the verification fails, you cannot use the files that fail the verification to generate code.

[0053] Step 203, if the verification is passed, extracting the message information and signal information of the communication protocol file through the extraction module;

[0054] In this embodiment, the message information and signal information of the communication protocol file can be extracted by the extraction module.

[0055] In one embodiment, when the verification is passed, extracting the message information of the communication protocol file through the extraction module includes: obtaining the message identifier, data length, message type, communication rate of the channel where the message is located, the sending node and receiving node of the message, and the sending method of the message in the communication protocol file; and determining the obtained information as the above-mentioned message information.

[0056] In this embodiment, after the communication protocol file is verified, the message information and signal information can be extracted from the communication protocol file. Extracting the message information includes extracting the message information defined in DBC and LDF by using a Pdu extraction module written in Python. Specifically, it may include:

[0057] Get the message ID, data length, and whether it is an extended message (CAN messages are divided into two types: ordinary messages CAN and extended messages CANFD. CANFD messages can accommodate longer data).

[0058] Get the channel where the message is located and the communication rate of the channel;

[0059] Obtain the sending node and receiving node of the message and determine the sending and receiving attributes;

[0060] Get the message sending mode: event-triggered or periodic sending;

[0061] Get the message sending period: You need to determine the sending period of periodic messages.

[0062] In one embodiment, when the verification is passed, extracting the signal information of the communication protocol file through the extraction module includes: obtaining the signal identifier of the signal in the message of the communication protocol file, the starting position of the signal in the message, the length of the signal, the initial value of the signal, and the conversion function parameters of the signal; and determining the obtained information as the above-mentioned signal information.

[0063] In this embodiment, the Pdu extraction module written in Python can be used to sort out the data format in the message and extract the signal information. Specifically, it can include: obtaining the signal body defined in the message:

[0064] Get the name of the signal;

[0065] Get the starting position of the signal in the message;

[0066] Get the length of the signal;

[0067] Get the initial value of the signal;

[0068] Get the function parameters of the signal converted from the actual physical value to the logical physical value (for example, the actual physical value of the temperature signal is 25, and the actual temperature is 2*25-40=10°C, where 2 and -40 are parameters).

[0069] Through the above steps, the signal information and message information of the communication protocol file are obtained.

[0070] Step 204, registering the message information to the interface layer, the routing layer and the communication layer through the registration module, and registering the signal information to the communication layer to obtain sub-message information and sub-signal information;

[0071] In one embodiment, the above-mentioned message information is registered to the interface layer, routing layer and communication layer through a registration module, and the above-mentioned signal information is registered to the above-mentioned communication layer, and the sub-message information and sub-signal information are obtained, including: registering a channel for the above-mentioned interface layer and configuring a channel number; registering an interface layer message at the above-mentioned interface layer, and assigning a channel number to each interface layer body containing message information; registering a communication layer message at the above-mentioned communication layer, and assigning a communication layer identifier to each communication layer body containing message information.

[0072] In this embodiment, a Pdu registration module written in python can be used to register corresponding message information for the If, ​​PduR, and Com layers; and to register corresponding signal information for the Com layer.

[0073] It mainly includes registering the channel in the If layer according to the content extracted from the communication protocol file, generating a body containing channel configuration information, and configuring the channel number; registering the message If_PDU in the If layer according to the content extracted from the communication protocol file, generating a body containing message related information, and assigning the If_ID of the layer to each body, and assigning the corresponding channel number; and registering the message Com_PDU in the Com layer according to the content extracted from the communication protocol file, generating a body containing message information, and assigning Com_ID to each body, registering the body Com_Signal_PDU containing signal related information, and assigning the corresponding Com_Signal_ID, and configuring the Com_Signal_ID contained in each Com_PDU.

[0074] Step 205, extracting the routing information of the routing forwarding table through the routing registration module;

[0075] In one embodiment, after extracting the routing information of the above-mentioned routing forwarding table through the routing registration module, the above-mentioned method also includes: configuring the source end module of the receiving type message at the routing source end as an interface layer module; configuring the source end module of the sending type message at the routing source end as a communication layer module or not configured according to whether to send the message; configuring the destination end module of the receiving type message at the routing destination end as a communication layer module; configuring the destination end module of the sending type message at the routing destination end as an interface layer module; registering unique identifiers for the above-mentioned interface layer messages and the above-mentioned communication layer messages, and establishing a mapping relationship between each layer.

[0076] In this embodiment, the routing registration module written in Python can be used to extract the routing information defined in the routing forwarding table, and assign the corresponding relationship between the upper and lower layers to the Pdus of each level registered above.

[0077] According to the content extracted from the communication protocol file, the routing data body PduR_PDU is registered in the PduR layer. PduR_PDU contains:

[0078] Routing source:

[0079] For receiving messages, the source module parameters are configured as the corresponding module of the If layer, and the source ID is configured as the If_ID of the If_PDU in the corresponding If module;

[0080] For sending messages, first check whether it is a forwarded message: for self-sent messages (non-forwarded messages), the source module parameters are configured as the Com layer, and the source ID is configured as the Com_ID of the Com_PDU in the Com module; for forwarded messages, because the message is sent after the corresponding message is received, there is no separate additional route, so it is not configured.

[0081] Route destination:

[0082] For receiving messages, the destination module parameters are configured as the Com layer, and the destination ID is configured as the Com_ID of the Com_PDU in the Com module; if there is a corresponding forwarding message for the message, add a routing destination configuration corresponding to the forwarding message, the destination module parameters are configured as the corresponding module of the If layer, and the destination ID is configured as the If_ID of the If_PDU in the corresponding If module;

[0083] For sending messages, the destination module parameters are configured as the corresponding module of the If layer, and the destination ID is configured as the If_ID of the If_PDU in the corresponding If module; the PduR_ID of this layer is allocated to the PduR_PDU; the PduR_ID of the corresponding PduR_PDU is registered for the above-registered If_PDU and Com_PDU, and a mapping relationship link is established between the layers.

[0084] Step 206: Generate a communication file code of the communication protocol file according to the sub-message information, the sub-signal information and the routing information.

[0085] In one embodiment, the communication file code for generating the communication protocol file based on the sub-message information, the sub-signal information and the routing information includes: inputting the sub-message information, the sub-signal information and the routing information into a code template to generate a code file; and determining the code file as the communication file code.

[0086] In this embodiment, a template generation module written based on Python can be used to generate each layer of code according to the specifications of the Autosar framework. This step includes filling in the content according to the content extracted from the communication protocol file and the routing table according to the pre-defined template that conforms to the Autosar architecture. The template defines which data structures and functions are defined in the communication file code (c file, h file) in sequence. The specific codes of these data structures and functions are filled with the content extracted from the communication protocol file and the routing table. Then, through the project code replacement step, the generated communication file code (c file, h file) directly replaces the communication file code (c file, h file) in the project intactly.

[0087] Figure 3 It is a flow chart of this embodiment. Take an example in the development process for illustration. In the process of vehicle software development under the AutoSar framework, after a version is developed, the communication protocol file is determined in the file of the current version through step 301, which may include CANwe year or LIN file, and the routing forwarding table is obtained through step 302. Steps 301 and 302 can be executed in parallel or in sequence, and the sequence is not limited. After obtaining the communication protocol file and the routing forwarding table, the communication protocol file and the routing forwarding table can be verified through step 303. The purpose of the verification is to ensure that the communication protocol file and the routing forwarding table are correct, and can be used to generate the communication file code. After the verification is passed, the message information and signal information of the communication protocol file can be extracted through step 304. The extracted information can be registered with the communication file code through step 305, that is, the obtained message information and signal information are registered in the interface layer, the routing layer and the communication layer, and the sub-message information and the sub-signal information are obtained. After that, a data communication link is generated through step 306, that is, the communication link is determined according to the routing information in the routing forwarding table. Then, the communication file code is generated in step 307, that is, the communication file code is generated according to the above-mentioned message information, signal information and routing information. In step 308, the communication file code (c file, h file) is directly replaced with the communication file code (c file, h file) in the project, so that the code of the project is replaced with the code that conforms to the communication protocol file.

[0088] Through the generation process of CAN and LIN communication file codes based on the AutoSar framework provided in this embodiment, error checking can be performed according to the communication protocol file, and codes suitable for each level can be automatically generated. The entire process avoids manual participation, so that the relevant code integration development can be fully automated.

[0089] Based on the same technical concept, the second embodiment of the present application provides a code generation device under the AutoSar framework, such as Figure 4As shown, the device comprises:

[0090] Acquisition module 401, used to acquire a communication protocol file and a routing table for generating a code;

[0091] Verification module 402, used for verifying the communication protocol file and the routing table through the verification module;

[0092] The first extraction module 403 is used to extract the message information and signal information of the communication protocol file through the extraction module when the verification passes;

[0093] The registration module 404 is used to register the message information to the interface layer, the routing layer and the communication layer through the registration module, and register the signal information to the communication layer to obtain the sub-message information and the sub-signal information;

[0094] The second extraction module 405 is used to extract the routing information of the routing forwarding table through the routing registration module;

[0095] The generating module 406 is used to generate the communication file code of the communication protocol file according to the sub-message information, the sub-signal information and the routing information.

[0096] The device provided by the embodiment of the present application obtains a communication protocol file and a routing table for generating a code; verifies the communication protocol file and the routing table through a verification module; extracts the message information and signal information of the communication protocol file through an extraction module when the verification is passed; registers the message information to the interface layer, the routing layer and the communication layer through a registration module, and registers the signal information to the communication layer to obtain sub-message information and sub-signal information; extracts the routing information of the routing table through a routing registration module; generates a communication file code of the communication protocol file according to the sub-message information, the sub-signal information and the routing information, so that when the communication protocol file changes, the data in the communication protocol file and the routing table can be automatically verified according to the changed communication protocol file, so that when the verification is passed, the message information and signal information are extracted, and the sub-message information and sub-signal information are registered, and a new communication file code is generated according to the sub-message information, the sub-signal information and the routing information in the routing table, thereby achieving the purpose of automatically generating the communication file code according to the communication protocol file and improving the generation efficiency of the file code of the communication protocol file.

[0097] like Figure 5 As shown, the third embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0098] Memory 113, used for storing computer programs;

[0099] In one embodiment, the processor 111 is used to implement the code generation method under the AutoSar framework provided by any of the aforementioned method embodiments when executing the program stored in the memory 113.

[0100] The memory and processor in the above electronic device communicate through the communication bus and the communication interface. The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into an address bus, a data bus, a control bus, etc.

[0101] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0102] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0103] A fourth embodiment of the present application provides a computer-readable medium having a non-volatile program code executable by a processor.

[0104] Optionally, in an embodiment of the present application, a computer-readable medium is configured to store program code for a processor to execute the above method.

[0105] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0106] When the embodiments of the present application are specifically implemented, reference may be made to the above-mentioned embodiments, which have corresponding technical effects.

[0107] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions of the present application, or a combination thereof.

[0108] For software implementation, the technology of this article can be implemented by a unit that performs the functions of this article. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.

[0109] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can 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.

[0110] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0111] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0112] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0113] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0114] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.

[0115] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0116] The above embodiments are only preferred embodiments for fully illustrating the present application, and the protection scope of the present application is not limited thereto. Any equivalent substitution or change made by a person skilled in the art based on the present application is within the protection scope of the present application.

Claims

1. A code generation method under the AutoSar framework, characterized in that: The method comprises: Obtain the communication protocol file and routing table for generating code; Verifying the communication protocol file and the routing table by means of a verification module; If the verification is passed, extracting the message information and signal information of the communication protocol file through the extraction module; Registering the message information to the interface layer, the routing layer and the communication layer through a registration module, and registering the signal information to the communication layer to obtain sub-message information and sub-signal information; Extracting the routing information of the routing forwarding table through a routing registration module; A communication file code of the communication protocol file is generated according to the sub-message information, the sub-signal information and the routing information.

2. The method according to claim 1, characterized in that Verifying the communication protocol file by the verification module includes: Determining description information of the forwarded message from the communication protocol file; Determine a forwarding message from the routing forwarding table; Check whether the description information includes the forwarding message.

3. The method according to claim 1, characterized in that Verifying the communication protocol file by the verification module includes: Obtaining variables used by the application layer interface of the previous engineering code by scanning the previous engineering code; Verify whether the variable is correctly defined in the communication protocol file.

4. The method according to claim 1, characterized in that: Verifying the routing table by the verification module includes: Obtaining node information of the forwarding node in the routing forwarding table; Obtaining the topological relationship between nodes in the communication protocol file; Check whether the node information matches the topological relationship between the nodes.

5. The method according to claim 1, characterized in that Verifying the routing table by the verification module includes: Obtaining the inter-node relationship of the forwarding nodes in the routing forwarding table; The relationship between the nodes is used to verify whether a closed loop exists among the forwarding nodes.

6. The method according to claim 1, characterized in that In the case where the verification is passed, extracting the message information of the communication protocol file by the extraction module includes: Obtaining the message identifier, data length, message type, communication rate of the channel where the message is located, the sending node and receiving node of the message, and the sending method of the message in the communication protocol file; The acquired information is determined as the message information.

7. The method according to claim 1, characterized in that In the case where the verification is passed, extracting the signal information of the communication protocol file by the extraction module includes: Obtaining a signal identifier of a signal in a message of the communication protocol file, a starting position of the signal in the message, a length of the signal, an initial value of the signal, and a conversion function parameter of the signal; The acquired information is determined as the signal information.

8. The method according to claim 1, characterized in that The registering module registers the message information to the interface layer, the routing layer, and the communication layer, and registers the signal information to the communication layer, and obtains the sub-message information and the sub-signal information, including: Register a channel for the interface layer and configure the channel number; Registering interface layer messages at the interface layer and assigning a channel number to each interface layer body containing message information; The communication layer messages are registered in the communication layer, and a communication layer identifier is allocated to each communication layer subject containing message information.

9. The method according to claim 8, characterized in that After extracting the routing information of the routing forwarding table through the routing registration module, the method further includes: The source module of the receiving message at the routing source is configured as an interface layer module; The source module of the sending message at the routing source is configured as a communication layer module or not configured according to whether to send messages; The destination module of the receiving message of the routing destination is configured as a communication layer module; The destination module of the sending message of the routing destination is configured as an interface layer module; Unique identifiers are registered for the interface layer messages and the communication layer messages, and a mapping relationship is established between the layers.

10. The method according to claim 1, characterized in that The communication file code for generating the communication protocol file according to the sub-message information, the sub-signal information and the routing information comprises: Inputting the sub-message information, the sub-signal information and the routing information into a code template to generate a code file; The code file is determined as the communication file code.

11. A code generation device under the AutoSar framework, characterized in that: The device comprises: An acquisition module, used to acquire a communication protocol file and a routing table for generating codes; A verification module, used for verifying the communication protocol file and the routing table through a verification module; A first extraction module, used to extract the message information and signal information of the communication protocol file through the extraction module when the verification passes; A registration module, used to register the message information to the interface layer, the routing layer and the communication layer through the registration module, and register the signal information to the communication layer to obtain sub-message information and sub-signal information; A second extraction module, used for extracting the routing information of the routing forwarding table through the routing registration module; A generation module is used to generate a communication file code of the communication protocol file according to the sub-message information, the sub-signal information and the routing information.

12. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-10 when executing a program stored in a memory.

13. 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 method according to any one of claims 1 to 10 is implemented.