Search

CN-121979501-A - Vehicle-mounted controller communication code generation method, device, equipment, medium and product

CN121979501ACN 121979501 ACN121979501 ACN 121979501ACN-121979501-A

Abstract

The application relates to the technical field of vehicle controllers, in particular to a method, a device, equipment, a medium and a product for generating a communication code of a vehicle-mounted controller, wherein the method comprises the steps of obtaining a communication definition file of a target vehicle and an identification of the target vehicle-mounted controller; the method comprises the steps of screening a communication definition file based on the identification of a target vehicle-mounted controller, extracting communication information of at least one communication signal in the target vehicle-mounted controller from the screened communication definition file, wherein the communication information comprises signal nodes and signal parameters, generating corresponding interface signals and signal buffer area interface definitions according to the communication information of the at least one communication signal, judging the signal type of the at least one communication signal based on the signal nodes, calling a corresponding communication code generation template based on the signal type, filling the signal parameters, the interface signals and the signal buffer area interface definitions into the communication code generation template, and writing the filled communication code generation template into an output file to generate a communication code of the target vehicle-mounted controller.

Inventors

  • YAN ZHE
  • AN SHILEI
  • ZHANG ZIYUE
  • CHEN RENCHANG

Assignees

  • 中国第一汽车股份有限公司

Dates

Publication Date
20260505
Application Date
20251212

Claims (10)

  1. 1. The vehicle-mounted controller communication code generation method is characterized by comprising the following steps of: acquiring a communication definition file of a target vehicle and an identification of a target vehicle-mounted controller; Screening the communication definition file based on the identification of the target vehicle-mounted controller, establishing an output file of the target vehicle-mounted controller, and extracting communication information of at least one communication signal in the target vehicle-mounted controller from the screened communication definition file, wherein the communication information comprises signal nodes and signal parameters; Generating corresponding interface signals and signal buffer area interface definitions according to communication information of at least one communication signal; Judging the signal type of at least one communication signal based on the signal node, calling a corresponding communication code generation template based on the signal type, and filling the signal parameters, the interface signals and the signal buffer interface definition into the communication code generation template; and writing the filled communication code generation template, the interface signals and the signal buffer interface definition into the output file to generate the communication code of the target vehicle-mounted controller.
  2. 2. The in-vehicle controller communication code generation method according to claim 1, further comprising, before writing the filled communication code generation template, the interface signal, and the signal buffer interface definition to the output file: Acquiring an interface signal definition table; If the interface signal definition table is acquired, extracting a signal name in the interface signal definition table, and determining an interface variable of a target vehicle-mounted controller corresponding to the interface signal according to the interface signal definition table when the interface signal contains the signal name in the interface signal definition table; if the interface signal definition table is not acquired, generating a signal name of the interface signal based on a preset rule, and determining an interface variable of a target vehicle-mounted controller corresponding to the interface signal based on the signal name; and writing the corresponding relation between the interface signal and the interface variable of the target vehicle-mounted controller into the output file.
  3. 3. The in-vehicle controller communication code generation method according to claim 1, characterized by further comprising, after generating the communication code of the target in-vehicle controller: and writing the communication code into the target vehicle-mounted controller, wherein the target vehicle-mounted controller interacts with the communication network of the target vehicle based on the communication code.
  4. 4. The vehicle-mounted controller communication code generation method according to claim 1, wherein the signal parameters include at least one of a name, an address, a length, a start bit, an offset, and a coefficient, the signal types include a first type and a second type, the first type is a received signal, the second type is a transmitted signal, and the communication code generation template includes a first template and a second template.
  5. 5. The vehicle-mounted controller communication code generation method according to claim 4, wherein the invoking the corresponding communication code generation template based on the signal type includes: if the signal type is the first type, calling the first template; and if the signal type is the second type, calling the second template.
  6. 6. The in-vehicle controller communication code generation method according to claim 5, wherein the first template includes: Clearing a signal buffer zone, circularly traversing communication signals of a signal receiving buffer zone, assigning the communication signals in the signal receiving buffer zone to the signal buffer zone according to the initial bit and the length of the communication signals, calculating to obtain interface signal values of the communication signals according to the offset and the coefficients of the communication signals in the signal buffer zone, and assigning the interface signal values to corresponding interface variables; The second template includes: Clearing the signal buffer zone, circularly traversing the interface signal value of the signal buffer zone, calculating the original value of the communication signal according to the offset of the communication signal, the coefficient and the interface signal value, storing the original value into the signal buffer zone, determining the position of the original value in the signal transmission buffer zone according to the initial position and the length of the communication signal, and assigning the original value of the communication signal in the signal buffer zone to the signal transmission buffer zone according to the bit.
  7. 7. An in-vehicle controller communication code generation apparatus, comprising: The acquisition module is used for acquiring a communication definition file of the target vehicle and an identifier of the target vehicle-mounted controller; The extraction module is used for screening the communication definition file based on the identification of the target vehicle-mounted controller, establishing an output file of the target vehicle-mounted controller and extracting communication information of at least one communication signal in the target vehicle-mounted controller from the screened communication definition file, wherein the communication information comprises signal nodes and signal parameters; the first generation module is used for generating corresponding interface signals and signal buffer area interface definitions according to the communication information of at least one communication signal; The filling module is used for judging the signal type of at least one communication signal based on the signal node, calling a corresponding communication code generation template based on the signal type, and filling the signal parameters, the interface signals and the signal buffer area interface definition into the communication code generation template; And the second generation module is used for writing the filled communication code generation template, the interface signals and the signal buffer area interface definition into the output file so as to generate the communication code of the target vehicle-mounted controller.
  8. 8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the program to implement the vehicle-mounted controller communication code generation method of any one of claims 1-6.
  9. 9. A computer-readable storage medium having stored thereon a computer program or instructions, wherein the computer program or instructions is executed by a processor for implementing the in-vehicle controller communication code generation method according to any one of claims 1 to 6.
  10. 10. A computer program product comprising a computer program or instructions which, when executed, implement the vehicle-mounted controller communication code generation method of any one of claims 1-6.

Description

Vehicle-mounted controller communication code generation method, device, equipment, medium and product Technical Field The application relates to the technical field of vehicle controllers, in particular to a vehicle-mounted controller communication code generation method, device, equipment, medium and product. Background In the field of vehicle-mounted controller software development, a CAN (Controller Area Network ) communication intermediate layer is used as a core link for connecting a controller and a vehicle CAN network, and development efficiency and stability of the vehicle-mounted controller software development intermediate layer directly influence the development period and reliability of a vehicle electric control system. In the related technology, the method for constructing the CAN communication model mainly through handwriting the CAN communication middle layer code and the Simulink has poor flexibility, network changes of different projects or different stages of the same project need to be redeveloped, the complexity is high, mistakes are easy to occur, manual errors are easy to occur in the development stage, project reworking is caused, the development period is long, the code quantity is large, and a great amount of working time is also required for the developed code or model test work. Disclosure of Invention The application provides a method, a device, equipment, a medium and a product for generating a communication code of a vehicle-mounted controller, which are used for solving the problems of poor flexibility, long development period, high complexity, easy error and the like in the related technology. An embodiment of the first aspect of the application provides a vehicle-mounted controller communication code generation method, which comprises the following steps of obtaining a communication definition file of a target vehicle and an identifier of the target vehicle-mounted controller, screening the communication definition file based on the identifier of the target vehicle-mounted controller, establishing an output file of the target vehicle-mounted controller, extracting communication information of at least one communication signal in the target vehicle-mounted controller from the screened communication definition file, wherein the communication information comprises signal nodes and signal parameters, generating corresponding interface signals and signal buffer zone interface definitions according to the communication information of the at least one communication signal, judging the signal type of the at least one communication signal based on the signal nodes, calling a corresponding communication code generation template based on the signal type, filling the signal parameters, the interface signals and the signal buffer zone interface definitions into the communication code generation template, and writing the filled communication code generation template, the interface signals and the signal buffer zone interface definitions into the output file to generate the communication code of the target vehicle-mounted controller. Optionally, before the interface definition of the interface and the interface buffer area of the communication code after filling is written into the output file, the method further comprises the steps of obtaining an interface signal definition table, extracting a signal name in the interface signal definition table if the interface signal definition table is obtained, determining an interface variable of a target vehicle-mounted controller corresponding to the interface signal according to the interface signal definition table when the interface signal contains the signal name in the interface signal definition table, generating the signal name of the interface signal based on a preset rule if the interface signal definition table is not obtained, determining the interface variable of the target vehicle-mounted controller corresponding to the interface signal based on the signal name, and writing the corresponding relation between the interface signal and the interface variable of the target vehicle-mounted controller into the output file. Optionally, after generating the communication code of the target in-vehicle controller, writing the communication code into the target in-vehicle controller, the target in-vehicle controller interacting with a communication network of the target vehicle based on the communication code. Optionally, the signal parameters include at least one of a name, an address, a length, a start bit, an offset, and a coefficient, the signal types include a first type and a second type, the first type is a received signal, the second type is a transmitted signal, and the communication code generation template includes a first template and a second template. Optionally, calling a corresponding communication code generation template based on the signal type comprises calling the first template if the signal type is a first type and calli