Code generation method and device, equipment, storage medium and program product
By acquiring device description files and business logic, a code converter is used to generate code files suitable for the target device, and testing is performed in a continuous integration environment. This solves the problem of insufficient development capabilities of existing tools and achieves efficient code generation and complex logic transformation.
Patent Information
- Application Number
- CN202410424192.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-09
- Publication Date
- 2025-10-17
Smart Images

Figure CN120803415A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a code generation method, apparatus, device, storage medium, and program product. Background Art
[0002] Today, automotive electronic controllers are increasingly used in vehicles and have become a crucial component influencing vehicle performance. As part of the overall vehicle development cycle and quality, the development cycle and quality of automotive electronic controller programs are gaining increasing attention from automotive developers. Controller Area Network (CAN) communication is currently the most common communication method in automotive networks. Within the vehicle software development cycle, CAN communication is typically developed using code based on database files (DBC). For example, in the development of autonomous driving systems, multiple sensors need to acquire CAN information from the vehicle in real time as input to ensure a close match to the vehicle's actual conditions, laying a solid foundation for its normal and accurate operation.
[0003] During the development process, users must either write code based on the basic library, Makefile examples, and DBC files, or configure conversion signals through the interface and then develop code based on the DBC files. Existing automatic or semi-automatic communication configuration tools lack development capabilities, impose a high labor burden, and are only suitable for simple business logic, not for more complex scenarios.
[0004] Therefore, there is a need to provide a simpler and more efficient code generation solution. Summary of the Invention
[0005] The embodiments of the present application provide a code generation method, apparatus, device, storage medium, and program product for automatically generating code files and simply and efficiently implementing code conversion.
[0006] In view of this, the present application provides, on the one hand, a code generation method, including: obtaining a device description file and the business logic of a target device, the device description file being used to describe the communication information corresponding to a general device, and the target device being the application device for which the code file is to be generated by the device description file; calling a code converter to convert the communication information in the device description file to generate a first code file; generating a business logic code file based on the business logic of the target device, the business logic being used to describe the communication information corresponding to the target device; converting the first code file into a second code file based on the business logic code file, and updating the compilation rules of the code file based on the business logic code file, the second code file being a code file applied to the target device; and outputting the second code file.
[0007] Another aspect of the present application provides a code generation apparatus, comprising: an obtaining module, configured to obtain a device description file and service logic of a target device, the device description file being used to describe communication information corresponding to a general device, and the target device being an application device of the device description file for which a code file is to be generated;
[0008] a processing module, configured to generate a first code file based on the device description file, generate a service logic code file based on the service logic of the target device, the service logic being used to describe communication information corresponding to the target device, convert the first code file into a second code file based on the service logic code file, and update a compiling rule of the code file based on the service logic code file, the second code file being a code file applied to the target device;
[0009] an output module, configured to output the second code file.
[0010] In a possible design, in another implementation manner of the another aspect of the embodiment of the present application, the processing module is configured to obtain communication logic corresponding to the target device and the communication information in the device description file;
[0011] determine a conversion signal between the communication logic and the communication information;
[0012] generate the service logic code file according to the conversion signal.
[0013] In a possible design, in another implementation manner of the another aspect of the embodiment of the present application, the processing module is configured to convert bits or bytes in the first code file according to the conversion signal described in the service logic code file, to obtain the second code file.
[0014] In a possible design, in another implementation manner of the another aspect of the embodiment of the present application, the processing module is configured to call a dcbb tool to convert the communication information in the device description file, to generate the first code file.
[0015] In a possible design, in another implementation manner of the another aspect of the embodiment of the present application, the processing module is configured to configure a continuous integration environment by using a mirror container, the continuous integration environment being used to test the code file.
[0016] In a possible design, in another implementation manner of the another aspect of the embodiment of the present application, the processing module is configured to upload the second code file to the continuous integration environment;
[0017] obtain a test code file;
[0018] call the test code file to test the second code file, to obtain a test result;
[0019] process the second code file according to the test result.
[0020] In a possible design, in another implementation manner of another aspect of the embodiment of the present application, the processing module is configured to invoke the test code file to perform static testing on the second code file to obtain a first static test result.
[0021] When the first static test result indicates that the test is passed, the second code file is compiled to obtain a first running program.
[0022] The test code file is invoked to perform dynamic testing on the running program to obtain a first dynamic test result, and the first static test result and the first dynamic test result are taken as the test result.
[0023] In a possible design, in another implementation manner of another aspect of the embodiment of the present application, the processing module is configured to, when the first static test result indicates that the test is not passed, acquire a first error code of the second code file.
[0024] The first error code is modified to obtain a third code file.
[0025] The test code file is invoked to perform static testing on the third code file to obtain a second static test result.
[0026] When the second static test result indicates that the test is not passed, the above operations are repeated until the static test is passed, and a compilation operation of a code file is triggered.
[0027] In a possible design, in another implementation manner of another aspect of the embodiment of the present application, the processing module is configured to, when the first dynamic test result indicates that the test is not passed, acquire a second error code of the second code file.
[0028] The second error code is modified to obtain a fourth code file.
[0029] The test code file is invoked to perform static testing on the fourth code file to obtain a third static test result.
[0030] When the third static test result indicates that the test is passed, the fourth code file is compiled to obtain a second running program.
[0031] The test code file is invoked to perform dynamic testing on the second running program to obtain a second dynamic test result.
[0032] The output module is configured to repeat the above operations until the dynamic test result indicates that the test is passed, and output a final code file, or output the fourth code file when the second dynamic test result indicates that the test is passed.
[0033] In a possible design, in another implementation of another aspect of the embodiment of the present application, the output module is configured to send the test result to a related device by using a communication mode such as an email or a short message.
[0034] In a possible design, in another implementation of another aspect of the embodiment of the present application, the processing module is configured to output the second code file and store the second code file to a code management platform when the test result indicates that the test is passed.
[0035] Another aspect of the present application provides a computer device, comprising a memory, a processor, and a bus system;
[0036] The memory is configured to store a program.
[0037] The processor is configured to execute the program in the memory, and the processor is configured to execute the method in the above aspects according to instructions in the program code.
[0038] The bus system is configured to connect the memory and the processor, so that the memory and the processor communicate.
[0039] Another aspect of the present application provides a computer readable storage medium, and the computer readable storage medium stores instructions, when the instructions are executed on a computer, the computer executes the method in the above aspects.
[0040] Another aspect of the present application provides a computer program product or a computer program, and the computer program product or the computer program comprises computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in the above aspects.
[0041] As can be seen from the above technical solutions, the embodiments of the present application have the following advantages: the device description file of a general device is automatically converted into a corresponding code file by a code converter, and then the code file is converted by writing a business logic code file, so that the device description file of the general device can generate a code file of a specific device. Meanwhile, the business logic code file is generated by writing code, and various calculations can be flexibly and conveniently implemented in the process of writing code. Therefore, compared with interface configuration, the conversion of complex logic can be more simply and effectively implemented, and the workload of implementing the conversion of complex logic is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A schematic diagram of an application architecture of the code generation method in an embodiment of the present application;
[0043] Figure 2 A schematic diagram of a process architecture of a code generation method in an embodiment of the present application;
[0044] Figure 3 This is a schematic diagram of an embodiment of the code generation method in the embodiment of the present application;
[0045] Figure 4 A schematic diagram of a flow chart of code testing in an embodiment of the present application;
[0046] Figure 5 This is a schematic diagram of a stage of code testing in the CI pipeline in an embodiment of the present application;
[0047] Figure 6 This is a schematic diagram of the result of the construction process in the CI pipeline in the embodiment of the present application;
[0048] Figure 7 This is a schematic diagram of the result of constructing the product in the CI pipeline in the embodiment of this application;
[0049] Figure 8 A schematic diagram of the code generation and code application process in the embodiment of the present application;
[0050] Figure 9 This is a schematic diagram of an embodiment of a code generation device in an embodiment of the present application;
[0051] Figure 10 This is a schematic diagram of another embodiment of the code generation device in the embodiment of the present application;
[0052] Figure 11 This is a schematic diagram of another embodiment of the code generation device in the embodiment of the present application. DETAILED DESCRIPTION
[0053] The embodiments of the present application provide a code generation method, apparatus, device, storage medium, and program product for automatically generating code files and simply and efficiently implementing code conversion.
[0054] The terms "first", "second", "third", "fourth" and the like in the description and in the claims of the present application, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of these terms herein is to be construed to cover a general order and / or structure unless there comes a particular sequence or chronology explicitly from the specification. Further, the use of the terms "including", "comprising", "consisting of" and "consisting essentially of" to describe the various embodiments of the application, are intended to indicate that the embodiments include the listed features but not preclude other features. It is intended that these embodiments include the listed features but not preclude other features.
[0055] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory) or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an integral module or unit that includes the functions of the module or unit.
[0056] Those skilled in the art can understand that, unless specifically stated, the singular forms "a", "an" and "the" used herein also include the plural forms. It should be further understood that the terms "include" and "comprise" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude other features, information, data, steps, operations, elements, components and / or their combinations supported by the present technology. It should be understood that when we say that an element is "connected" or "coupled" to another element, the element can be directly connected or coupled to the other element, or can mean that the element and the other element are connected through an intermediate element. In addition, "connected" or "coupled" used herein can include wireless connection or wireless coupling. The term "and / or" used herein indicates that at least one of the items defined by the term, for example, "A and / or B" can be implemented as "A", or as "B", or as "A and B".
[0057] Nowadays, the application of automobile electronic controller in the automobile is more and more extensive, and has become an important component of influencing the performance of the automobile. The development cycle and quality of the program of the automobile electronic controller as a link of the development cycle and quality of the whole vehicle are more and more concerned by the automobile developers. Controller area network (CAN) communication is the most common communication method in the automobile network at present. In the software development cycle of the whole vehicle, the CAN communication is usually based on the database file (DatabaseCan, DBC) file to develop the code. For example, in the research and development process of automatic driving, multiple sensors need to obtain the CAN information of the automatic driving automobile as input in real time, so as to ensure that the actual situation of the vehicle is strictly matched, thereby laying a solid foundation for the normal and accurate operation. In the development process, the user needs to write code according to the basic library, makefile example and DBC file, or convert the signal through the interface configuration, and then develop the code of the DBC file based on the converted signal. That is, the existing automatic or semi-automatic communication configuration tool has insufficient development capability, has more manpower burden, and is only suitable for relatively simple business logic and cannot be applied to more complex scenarios. Therefore, a simpler and more efficient code generation scheme is needed at present.
[0058] To solve this technical problem, the present application provides the following technical solution: obtaining a device description file and a business logic of a target device, the device description file being used to describe the communication information corresponding to a general device, and the target device being an application device of the device description file to be generated a code file; calling a code converter to convert the communication information in the device description file to generate a first code file; generating a business logic code file based on the business logic of the target device, the business logic being used to describe the communication information corresponding to the target device; converting the first code file into a second code file based on the business logic code file, updating the compilation rule of the code file based on the business logic code file, and the second code file being a code file applied to the target device; and outputting the second code file. In this way, the device description file of the general device is automatically generated into a corresponding code file through the code converter, and then the code file is converted through the writing of the business logic code file, thereby realizing the effect that the device description file of the general device can generate the code file of the specific device. At the same time, the business logic code file is generated by writing code, and various calculations can be flexibly and conveniently realized in the process of writing code. Therefore, compared with the interface configuration, the conversion of complex logic can be more simply and effectively realized, and the workload of realizing the conversion of complex logic is reduced.
[0059] For the convenience of understanding, some terms involved in the present application are explained as follows:
[0060] Compilation: There are two interpretations of the existence of the following: 1, using the compiler from the source language written source program to produce the target program. 2, the action of generating target programs with a compiler. In summary, that is, the compilation is to change the high-level language into a binary language that the computer can recognize. In the specific operation, the compiler translates a source program into a target program into five stages: lexical analysis; syntax analysis; semantic checking and intermediate code generation; code optimization; target code generation. Mainly lexical analysis and syntax analysis, also known as source program analysis, and found in the analysis process syntax error, give prompt information.
[0061] Among them, the compiled language is a programming language implemented by a compiler. It is not like an interpreted language, which runs code one sentence at a time by an interpreter, but uses a compiler to compile the code into machine code first and then run it.
[0062] Continuous Integration (CI), Continuous Delivery (CD), and Continuous Deployment (CD): The above three can also be called CI / CD, which is a method of frequently delivering applications to customers by introducing automation during application development. The core concepts of CI / CD are continuous integration, continuous delivery, and continuous deployment. It is a solution for development and operations teams, mainly targeting problems caused when integrating new code. CI / CD allows continuous automation and continuous detection throughout the entire life cycle of an application (from integration and testing stages to delivery and deployment).
[0063] Continuous Integration (CI) can help developers more easily merge code changes into the main branch. Once developers merge the changed code into the main branch, the system will automatically build the application and run different levels of automated tests to verify the changes, ensuring that the changes do not break the application. If the automated tests find conflicts between the new code and the existing code, CI can more easily and quickly fix these errors.
[0064] After completing the automated processes of building, unit testing, and integration testing, Continuous Delivery can automatically release verified code to the code repository. Continuous Delivery aims to establish a code base that can deploy features from the development environment to the production environment at any time. During the Continuous Delivery process, each step involves test automation and code release automation. At the end of the process, the operations team can quickly and easily deploy the application to the production environment.
[0065] The final stage for a complete, mature CI / CD pipeline is continuous deployment. It is an extension of continuous delivery, which automatically releases an application to production. In practice, continuous deployment means that changes made by developers to an application are available in production within minutes of being written (provided it passes automated tests). This makes it easier for the operations team to continuously receive and incorporate user feedback.
[0066] Static testing: refers to not running the program itself, but only through the analysis or inspection of the source program syntax, structure, process, interface, etc. to check the correctness of the code file. That is, static testing is to find out the defects and suspicious places through the analysis of the static characteristics of the program. For example, unmatched parameters, inappropriate loop nesting and branch nesting, disallowed recursion, unused variables, reference to null pointer and suspicious calculation, etc. The test results of static testing can be used for further error checking and provide guidance for test case selection. Static testing can include code checking, static structure analysis, code quality measurement, etc. It can be automatically performed with the help of software tools. Among them, code checking includes code walk-through, desktop checking, code review, etc., mainly checking the consistency of code and design, code compliance with standards, code readability, correctness of code logic expression, rationality of code structure, etc.; it can find problems that violate program writing standards, unsafe, unclear and ambiguous parts in the program, find non-portable parts in the program, problems that violate program programming style, including variable checking, naming and type review, program logic review, program syntax checking and program structure checking, etc.
[0067] Dynamic testing: refers to running the program under test, checking the difference between the expected result and the actual result, and analyzing the performance of running efficiency, correctness and robustness. This testing method consists of three parts: constructing test cases, executing programs, and analyzing the output of the program. According to the stage and role of dynamic testing in the software development process, dynamic testing can be divided into the following steps: unit testing, integration testing, assembly testing, confirmation testing, system testing, acceptance testing, and regression testing.
[0068] Controller Area Network (CAN): a functional and rich vehicle bus standard.
[0069] Makefile: that is, the compilation rule of the whole project. The source files in a project are not counted, and they are placed in several directories according to types, functions and modules. Makefile defines a series of rules to specify which files need to be compiled first, which files need to be compiled later, and which files need to be recompiled, or even perform more complex function operations. The advantage brought by makefile is "automated compilation". That is, once makefile is written, the whole project can be automatically compiled by a make command, greatly improving the efficiency of software development.
[0070] DBC (Database Can) file, also known as CAN database file, is a device description file for controlling a CAN (Control Area Network) device. It includes information related to converting data in a CAN packet into actual physical quantities. In this file, the information of CAN communication is defined completely and clearly, and the communication of the CAN network is based on the description of this file, so the role of the DBC file is very powerful. It is because of it that the node controllers of the entire CAN network can be developed in error-free and synchronous manner.
[0071] Docker: an open source application container engine that allows developers to package their applications and dependencies into a portable image that can be run on any popular Linux or Windows operating system machine, and also realizes virtualization.
[0072] The code generation method of each optional embodiment of the present application is realized based on computer technology, and can be applied to the field of artificial intelligence. Artificial intelligence is to use digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which tries to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that the machine has the functions of perception, reasoning and decision-making.
[0073] Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, both hardware and software technologies. Artificial intelligence basic technologies generally include sensors, special artificial intelligence chips, cloud computing, distributed storage, large code generation technology, operation / interaction system, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, automatic driving, intelligent transportation and other fields.
[0074] The present application also relates to cloud technology. The cloud technology refers to a kind of hosting technology that the system resources such as hardware, software, network are unified in wide area network or local area network, and data calculation, storage, processing and sharing are realized.
[0075] The cloud technology is the general term of network technology, information technology, integration technology, management platform technology, application technology and the like based on cloud computing business model application, can form resource pool, use on demand, flexible and convenient.Cloud computing technology will become an important support.The background service of technical network system needs a large amount of computing and storage resources, such as video website, picture website and more portal website.With the high development and application of internet behavior, every item may have its own identification mark in the future, and needs to be transmitted to the background system for logical processing.Different levels of data will be processed separately, and various industry data need strong system backup support, which can only be realized by cloud computing.The cloud technology involved in the present application mainly refers to the code storage possibly through "cloud", such as storing code file in the cloud and the like.
[0076] The present application also relates to intelligent driving application and other technical scenarios.The automatic driving application involved in the present application mainly refers to the information communication between various sensors on the vehicle generated by the code of vehicle system running the technical solution provided by the present application.The intelligent driving vehicle under the intelligent driving application includes an automatic driving vehicle and a vehicle with intelligent driving or assisted driving function.
[0077] The code generation method, device, equipment, storage medium and program product provided by the present application embodiment can automatically generate code files and simply and efficiently realize code conversion.The exemplary application of the electronic device provided by the present application embodiment is described below.The electronic device provided by the present application embodiment can be implemented as various types of user terminals, or as a server.
[0078] The electronic device can automatically generate code files and simply and efficiently realize code conversion by running the code generation solution provided by the present application embodiment.The code generation solution is suitable for multiple application scenarios of intelligent driving or automatic driving.For example, the solution of the present application is run to generate code files corresponding to each automatic driving vehicle, so that the automatic driving vehicle runs the code files to realize the communication between the vehicle and the sensor.
[0079] In a possible implementation, the code generation method provided by the present application embodiment can be implemented as an application program or part of an application program, and installed in a terminal, so that the terminal has the functions of automatically generating code files and simply and efficiently realizing code conversion.
[0080] Referring to Figure 1 , Figure 1An optional architecture diagram in an application scenario of the code generation method provided in the embodiment of the present application is provided, in order to implement a code generation scheme, the terminal device 100 is connected to the server 300 through the network 200, the server 300 is connected to the database 400, and the network 200 can be a wide area network or a local area network, or a combination of the two. The client for implementing the code generation scheme is deployed on the terminal device 100, wherein the client can run on the terminal device 100 in the form of a browser, or run on the terminal device 100 in the form of an independent application (application, APP), etc. The specific form of the client is not limited here. The server 300 involved in the present application can be a standalone physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms, etc. Basic cloud computing services. The terminal device 100 can be a smartphone, a tablet computer, a notebook computer, a palm computer, a personal computer, a smart television, a smart watch, a vehicle-mounted device, a wearable device, a smart voice interaction device, a smart home appliance, an aircraft, etc., but is not limited thereto. The terminal device 100 and the server 300 can be directly or indirectly connected through the network 200 through wired or wireless communication, which is not limited in the present application. The number of servers 300 and terminal devices 100 is also not limited. The scheme provided in the present application can be completed independently by the terminal device 100, or independently by the server 300, or by the terminal device 100 and the server 300 together, which is not limited in the present application. The database 400 can be simply regarded as an electronic file cabinet, i.e., a place for storing electronic files, and users can add, query, update, delete, etc. Data in the file. The so-called "database" is a collection of data stored together in a certain way, shared by multiple users, with as little redundancy as possible, and independent of application programs. The database management system (Database Management System, DBMS) is a computer software system designed to manage databases, and generally has basic functions such as storage, interception, security, backup, etc.Database management systems can be classified according to the database models they support, such as relational and Extensible Markup Language (XML); or according to the types of computers they support, such as server clusters and mobile phones; or according to the query languages used, such as Structured Query Language (SQL) and XQuery; or according to performance priorities, such as maximum scale and maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, for example, supporting multiple query languages at the same time. In the present application, the database 400 can be used to store the second code file. Of course, the storage location of the second code file is not limited to the database. For example, it can also be stored in the terminal device 100, the blockchain, or the distributed file system of the server 300.
[0081] In some embodiments, both the server 300 and the terminal device 100 can execute the code generation method provided in the embodiments of the present application.
[0082] Based on the above description, Figure 2 The architecture diagram shown illustrates the code generation solution in this application:
[0083] like Figure 2 As shown, this application can be divided into input layer, business logic layer, basic layer and continuous integration CI pipeline.
[0084] Among them, the input layer is used to obtain the DBC file input by the user (i.e., the device description file in this application). In this embodiment, the DBC file is used to describe the communication of a single CAN network. Simply put, the DBC file describes what message information is on the CAN network, what signal information is carried on the message, which node the message is sent from, which node receives it, and other information. It has corresponding content elements, which include regular elements, keywords, and symbols. The regular elements are used to indicate the data type and identifier in the DBC file. The keywords generally include objects of network node type, objects of message type, objects of signal type, value descriptions, and attribute values. The syntax of the file is described using extended BNF (Backus-Naur-Format) symbols, including symbols such as equal signs, semicolons, square brackets, and curly brackets.
[0085] The business logic layer is configured to implement automatic code generation of the DBC file, generation of a conversion signal, and configuration update of a makefile, and the like. The DBC file can automatically generate a corresponding code file by calling a corresponding code converter. Meanwhile, a developer can determine a conversion signal according to information carried in the DBC file and business logic of a target device, and write code according to the conversion signal to obtain a business logic code file. Finally, the business logic code file can be called to forward the code file automatically generated by the DBC file to generate a code file executable by the target device. Meanwhile, corresponding information in the makefile also needs to be updated according to the business logic code file to enable the C code file executable by the target device to be normally compiled.
[0086] The base layer includes hardware-related libraries and dependencies and a program of a code converter. The hardware-related libraries and dependencies and the code converter are configured to implement functions of the code file automatically generated by the DBC file.
[0087] The CI pipeline is configured to implement continuous integration and continuous delivery of the code file executable by the target device. In an example, the CI pipeline can include a code file library (i.e., a git repository) and a CodingDevOps pipeline. The code file library is configured to store the code file executable by the target device. The code file is then tested and delivered based on the CodingDevOps pipeline.
[0088] It can be understood that in the specific embodiments of the present application, the DBC file, the code file, and the like are involved. When the above embodiments of the present application are applied to specific products or technologies, user permission or consent needs to be obtained, and collection, use, and processing of related data need to comply with relevant laws, regulations, and standards of countries and regions.
[0089] In combination with the above description, the code generation method in the present application is described below with the terminal device as an execution subject. Please refer to Figure 3 An embodiment of the code generation method in the present application includes the following steps.
[0090] 301. Obtain a device description file and business logic of a target device. The device description file is configured to describe communication information of a general device. The target device is an application device of the device description file.
[0091] In the embodiment, the terminal device obtains a device description file (i.e., a DBC file) uploaded by a third party or a user through an operation interface and business logic of a target device.
[0092] The target device can be an intelligent driving vehicle, which includes an autonomous vehicle and a vehicle with intelligent driving or assisted driving function. Based on this, the DBC file can be used to describe the general communication information of the autonomous vehicle. For example, the DBC file is used to describe the communication information of the brand A autonomous vehicle, i.e., the steering signal of the steering wheel of the car (unit: degree, range: -500 to 500). The target device is a brand B autonomous vehicle, and the business logic thereof can be as follows: the steering angle signal (unit: radian, range 0 to 300) and the steering direction of the steering wheel (left turn is 0, right turn is 1).
[0093] 302, calling a code converter to convert the communication information in the device description file to generate a first code file.
[0094] In this embodiment, after the terminal device obtains the device description file, a corresponding code converter is called to generate a corresponding code file (i.e., the first code file) based on the device description file.
[0095] It should be understood that the code converter can select a corresponding program based on different application scenarios. For example, in the autonomous driving scenario, the dbcc tool can be called to automatically generate code based on the device description file. It should be understood that during the coding process, a suitable coding language can be selected to generate the code file according to actual needs. For example, if C language is selected for coding, the first code file can be a C code file.
[0096] 303, generating a business logic code file based on the business logic of the target device, the business logic being used to describe the communication information corresponding to the target device.
[0097] In this embodiment, after the terminal device obtains the business logic of the target device and the communication information of the device description file, a conversion signal is determined based on the business logic and the communication information, and finally the business logic code file is generated based on the conversion signal.
[0098] In an example, the DBC file describes the communication information of a brand A autonomous vehicle, i.e., the steering wheel steering signal of the vehicle (unit: degree, range: -500 to 500), which can be understood as an input signal. The target device is a brand B autonomous vehicle, and its business logic can be as follows: the steering wheel steering angle signal (unit: radian, range 0 to 300) and the steering wheel steering direction (0 for left turn and 1 for right turn), which can be understood as an output signal. The corresponding conversion signal between the two is the process of converting the input signal into the output signal through certain rules. For example, the conversion signal can be as follows: the numerical value is first converted 1 degree (°) = π / 180 rad. Then, the steering direction of the steering wheel is determined to be 0 or 1 through the positive and negative of the input signal. Finally, the conversion signal is programmed to obtain the business logic code file.
[0099] In another example, the terminal device can also have built-in common conversion signals, so that the user can generate a business logic code file in a corresponding scenario through interface point selection or interface matching connection. For example, the commonly used steering wheel signal conversion is built-in as a common conversion signal, i.e., the steering wheel signal conversion of brand A to the steering wheel signal of brand B is set as a common conversion signal. Or when the interface is matched, the steering wheel signal of brand A and the steering wheel signal of brand B are stored respectively, and then the two are matched and connected, so that the corresponding business logic code can be generated. The specific implementation is not limited here, as long as the generation of the business logic code file can be realized.
[0100] 304、Based on the business logic code file, the first code file is converted into a second code file, and the compilation rule of the code file is updated based on the business logic code file. The second code file is a code file applied to the target device.
[0101] In this embodiment, the terminal device converts the bits or bytes in the first code file according to the conversion signal described in the business logic code file to obtain the second code file.
[0102] At the same time, in order to make the second code file run correctly, the terminal device also needs to update the compilation rule (i.e., makefile) of the code file according to the business logic code file.
[0103] In an example, the DBC file describes the communication information of a brand A autonomous vehicle, i.e., the steering wheel steering signal of the vehicle (unit: degree, range: -500 to 500). This piece of information can generate a corresponding code file A by calling the dbcc tool. The target device is a brand B autonomous vehicle, and its business logic can be as follows: the steering wheel steering angle signal (unit: radian, range 0 to 300) and the steering wheel steering direction (0 for left turn and 1 for right turn), i.e., it can be understood as an output signal. Its corresponding conversion signal 1 can be as follows: the value is first converted by unit 1 degree (°) = π / 180 rad. Then, by the positive and negative of the input signal, it is determined whether the steering wheel steering direction is 0 or 1. Then, based on the conversion signal, the corresponding values in the code file A are converted to obtain the code file B.
[0104] Since the makefile is the compilation rule in the entire autonomous driving, its initial compilation rule can be as follows: converting the code file A to the code file B based on the conversion signal. Since the conversion signal is named conversion signal 1 during the writing process, the “converting the code file A to the code file B based on the conversion signal” needs to be updated to “converting the code file A to the code file B based on the conversion signal 1”.
[0105] 305、output the second code file.
[0106] In this embodiment, after the terminal device generates the second code file corresponding to the target device, the second code file can be output.
[0107] The technical solution provided in this embodiment is particularly suitable for the CAN bus scene of intelligent driving vehicles, so that the device description files of other intelligent driving vehicles can be automatically generated into corresponding code files by the code converter, and then the code files can be converted by writing the business logic code file, thereby achieving the effect that the device description files of other intelligent driving vehicles can generate the code files of the target intelligent driving vehicle. At the same time, the business logic code file is generated by writing code, and since various calculations can be flexibly and conveniently implemented during the code writing process, compared with interface configuration, the conversion of complex logic can be more simply and effectively implemented, and the workload of implementing the conversion of complex logic is reduced.
[0108] It should be understood that after the code is automatically generated, in order to improve the development efficiency of the code file, the code file can also be automatically tested, delivered and deployed by using a CI pipeline, and the specific process can be as follows Figure 4 as shown in the following figure:
[0109] 401、upload the second code file to the continuous integration environment.
[0110] In this embodiment, in order to implement the continuous integration, delivery or deployment of the second code file, the continuous integration environment (i.e., the CI pipeline as shown in Figure 2 In an example, the developer can deploy the continuous integration environment by using an image container. The image container can be Docker, which is an open source application container engine that can package an application and dependent packages into a portable image and then publish the image to any popular Linux or Windows operating system machine or realize virtualization.
[0111] After the continuous integration environment is deployed, the terminal device transmits the second code file to a specified path in the git repository in the CI pipeline, so that the second code file is uploaded to the continuous integration environment.
[0112] In an example, a test process of the CI pipeline can include four stages of static testing, compilation, dynamic testing and release, as shown in Figure 5 The static testing is used for code checking of the second code file, the compilation is used for program compilation of the code file passing the static testing to generate a running program that can run on a computer, the running program is then dynamically tested, and the code file passing the dynamic testing is released, i.e., stored in a third-party code management library or a code management library of a developer.
[0113] 402, obtain a test code file.
[0114] In this embodiment, after the terminal device transmits the second code file to the specified path in the git repository in the CI pipeline, the terminal device triggers the execution operation of the CI pipeline and obtains the test code of the second code file after the code branch merging of the whole project is completed.
[0115] It should be understood that the test code is automatically generated after the second code file, and the developer writes the test code according to the detection target, or the test code can be a general test code, which is not limited here.
[0116] It should be understood that the CI pipeline in this embodiment can also have different function options. As shown in Figure 6 The CI pipeline can include a build process, a change record, access control & metadata, a build product, a build snapshot, metadata and operation record information. The build process is used to indicate the state information of each stage in the CI pipeline, the change record can record the modification of the code file in the CI pipeline and the change of each task in the CI pipeline, the build product is used to indicate the compilation product generated in the compilation process, i.e., a running program, and the build snapshot is used to indicate the snapshot of the build product.Figure 7 As shown, after clicking the build product option, you can display a running program generated during the compilation process and display its task name (such as Figure 7 RoutPro shown), the corresponding download address (such as Figure 7 As shown in the "hardware / pcanroute_pro / out / vv6_to_asr408_asr410_eyeq4_") and the size of the running program (such as Figure 7 247.79KB as shown).
[0117] 403. Call the test code file to test the second code file to obtain a test result.
[0118] In this embodiment, Figure 5 Taking the CI pipeline shown as an example, the test process of the second code file can be as follows: the terminal device calls the test code file to perform a static test on the second code file to obtain a first static test result; when the first static test result indicates that the test is passed, the second code file is compiled to obtain a first running program; the test code file is called to perform a dynamic test on the running program to obtain a first dynamic test result, and the first static test result and the first dynamic test result are used as the test result; when the first static test result indicates that the test fails, the first error code of the second code file is obtained; the first error code is modified to obtain a third code file; the test code file is called to perform a static test on the third code file to obtain a second static test result; when the second static test result indicates that the test fails If the test fails, the above operation is repeated until the static test passes, triggering the compilation operation of the code file; when the first dynamic test result indicates that the test fails, the second error code of the second code file is obtained; the second error code is modified to obtain a fourth code file; the test code file is called to perform a static test on the fourth code file to obtain a third static test result; when the third static test result indicates that the test passes, the fourth code file is compiled to obtain a second running program; the test code file is called to perform a dynamic test on the second running program to obtain a second dynamic test result; when the second dynamic test result indicates that the test fails, the above operation is repeated until the dynamic test result indicates that the test passes, and the final code file is output; when the second dynamic test result indicates that the test passes, the fourth code file is output.
[0119] In this embodiment, any test results generated during the above test process can be viewed during the build process, and the above test results can also be sent to the developer's corresponding relevant device via email or other communication methods, so that the developer can discover code problems in a timely manner.
[0120] 404、According to the test result, the second code file is processed.
[0121] In this embodiment, the terminal device can view the test results at different stages, and then process the second code file according to the test results. That is, if the test result indicates that the second code file passes the test, the second code file is released; if there is a test result in the test result indicating that the second code file fails the test, the second code file is modified and then tested again until the code file passes the test.
[0122] The technical solution provided in this embodiment combines continuous integration with code file development. After the code file is written, the code file is captured into the continuous integration environment, and the code file is tested according to the test code file, so that the code file can be conveniently tested, errors and code failures can be avoided, and the continuous development and update cycle of the code can be maintained.
[0123] The code generation method provided by the present application and the application scenario of the code will be described below in a specific application scenario.
[0124] Suppose a development engineer needs to develop the running code of intelligent driving vehicle B according to the DBC file of intelligent driving vehicle A. The process can be as shown in Figure 8 The development engineer first generates code according to the DBC file of intelligent driving vehicle A. The process can include: 1. Place multiple DBC files of intelligent driving vehicle A in a specified path of an engineering file (it should be understood that the engineering file is a file used to organize and manage projects during the code development process of intelligent driving vehicle B. It usually contains project configuration information, compilation options, dependency relationships, and other project-related settings. The main function of the engineering file is to tell the compiler how to compile and build the project, and how to link various source files and library files.); 2. Start the automatic writing tool (it should be understood that the automatic writing tool includes but is not limited to the dbcc tool mentioned in this embodiment, the integrated code generator based on the integrated development environment, or the code generator based on object relationship mapping), automatically generate c code from DBC, and then place the c code in the specified path; 3. Write business logic code file; 4. Write test code; 5. Update the file name of the business logic code file in makefile.
[0125] Then the development engineer puts the code file (i.e. the code file generated in steps 1-2 above) into a specified branch of a code repository in a CI pipeline through a terminal device; after the branch is merged, a CI process (in which the test code generated in step 4 above will be run) will be automatically started. In the CI process, mainly the static test of the code file is performed; the target program based on the code file is compiled (i.e. based on the updated makefile in step 5 above); and the dynamic test of the target program is performed; after the CI process is completed, the development engineer can download the target program and burn the target program to the corresponding hardware (such as the PCANRoutPro hardware); finally, the PCANRoutPro hardware with the burned program is correctly connected with the wire harness of the intelligent driving vehicle B; and the target program is run on the intelligent driving vehicle B.
[0126] The code generation device in the present application will be described in detail below. Please refer to Figure 9 , Figure 9 An embodiment of the code generation device in the present application is shown in the figure, and the code generation device 20 comprises:
[0127] The obtaining module 201 is configured to obtain a device description file and a service logic of a target device, the device description file is used to describe the communication information corresponding to a general device, and the target device is an application device for which the code file of the device description file is to be generated;
[0128] The processing module 202 is configured to generate a first code file based on the device description file; generate a service logic code file based on the service logic of the target device, the service logic is used to describe the communication information corresponding to the target device; convert the first code file into a second code file based on the service logic code file, and update the compilation rule of the code file based on the service logic code file, the second code file is a code file applied to the target device;
[0129] The output module 203 is configured to output the second code file.
[0130] In the present application, a code generation device is provided. By using the above device, the device description file of a general device is automatically converted into a corresponding code file by a code converter, and then the code file is converted by writing a service logic code file, thereby achieving the effect that the device description file of the general device can generate a code file of a specific device. Meanwhile, the service logic code file is generated by writing code, and various calculations can be flexibly and conveniently implemented in the process of writing code, so compared with interface configuration, the conversion of complex logic can be more simply and effectively implemented, and the workload of implementing the conversion of complex logic is reduced.
[0131] Optionally, in the above Figure 9 On the basis of the corresponding embodiment, another embodiment of the code generation device 20 provided by the embodiment of the application is provided,
[0132] The processing module 202 is configured to acquire the communication logic corresponding to the target device and the communication information in the device description file.
[0133] Determine the conversion signal between the communication logic and the communication information.
[0134] Generate the service logic code file according to the conversion signal.
[0135] In the embodiment of the application, a code generation device is provided. According to the service logic of the target device and the communication information of the general device, the corresponding conversion signal is determined by using the above device. Then, the service logic code file is written according to the conversion signal. Since various calculations can be flexibly and conveniently implemented in the process of writing the code, compared with interface configuration, the conversion of complex logic can be more simply and effectively implemented, and the workload of implementing the conversion of complex logic is reduced.
[0136] Optionally, in the above Figure 9 On the basis of the corresponding embodiment, another embodiment of the code generation device 20 provided by the embodiment of the application is provided, and the processing module 202 is configured to convert bits or bytes in the first code file according to the conversion signal described in the service logic code file to obtain the second code file.
[0137] In the embodiment of the application, a code generation device is provided. According to the service logic code file, the communication information of the general device is converted into corresponding bits or bytes by using the above device. The code file corresponding to the target device can be automatically converted and generated. The generation of the code file can be automatically performed, and the code generation device can be applied to various types of target devices, thereby improving the applicability of the scheme.
[0138] Optionally, in the above Figure 9 On the basis of the corresponding embodiment, another embodiment of the code generation device 20 provided by the embodiment of the application is provided,
[0139] The processing module 202 is configured to call the dcbb tool to convert the communication information in the device description file to generate a first code file.
[0140] In the embodiment of the application, a code generation device is provided. The specific type of the converter is provided by using the above device, and the feasibility of the scheme is improved.
[0141] Optionally, in the above Figure 9On the basis of the corresponding embodiment, another embodiment of the code generation apparatus 20 provided by the present application is provided,
[0142] The processing module 202 is configured to configure a continuous integration environment by using the mirror container, and the continuous integration environment is used to test the code file.
[0143] In the present application, a code generation apparatus is provided. By using the above apparatus, the continuous integration is combined with the development of the code file, so that the code file can be tested conveniently, thereby avoiding errors and code failures, and maintaining the continuity of the code development and updating cycle.
[0144] Optionally, in the above Figure 9 On the basis of the corresponding embodiment, another embodiment of the code generation apparatus 20 provided by the present application is provided, and the processing module 202 is configured to upload the second code file to the continuous integration environment.
[0145] Obtain a test code file.
[0146] Call the test code file to test the second code file to obtain a test result.
[0147] According to the test result, the second code file is processed.
[0148] In the present application, a code generation apparatus is provided. By using the above apparatus, after the code file is written, the code file is captured to the continuous integration environment, and is tested according to the test code file, so that the code file can be tested conveniently, thereby avoiding errors and code failures, and maintaining the continuity of the code development and updating cycle.
[0149] Optionally, in the above Figure 9 On the basis of the corresponding embodiment, another embodiment of the code generation apparatus 20 provided by the present application is provided, and the processing module 202 is configured to call the test code file to perform static testing on the second code file to obtain a first static test result.
[0150] When the first static test result indicates that the test is passed, the second code file is compiled to obtain a first running program.
[0151] Call the test code file to perform dynamic testing on the running program to obtain a first dynamic test result, and the first static test result and the first dynamic test result are taken as the test result.
[0152] In the embodiments of the present application, a code generation device is provided. The code file is tested in the CI environment according to static testing, compiling and dynamic testing by using the device, so that the code file can be tested conveniently, errors and code faults can be avoided, and the code development and updating cycle can be kept continuously.
[0153] Optionally, in the above Figure 9 Based on the embodiments corresponding thereto, in another embodiment of the code generation device 20 provided by the embodiments of the present application, the processing module 202 is configured to, when the first dynamic test result indicates that the test fails, acquire a second error code of the second code file.
[0154] The first error code is modified to obtain a third code file.
[0155] The test code file is called to perform static testing on the third code file to obtain a second static test result.
[0156] When the second static test result indicates that the test fails, the above operations are repeated until the static test passes, and a compiling operation of the code file is triggered.
[0157] In the embodiments of the present application, a code generation device is provided. The code file is tested in the CI environment according to static testing, compiling and dynamic testing by using the device, so that the code file can be tested conveniently, errors and code faults can be avoided, and the code development and updating cycle can be kept continuously.
[0158] Optionally, in the above Figure 9 Based on the embodiments corresponding thereto, in another embodiment of the code generation device 20 provided by the embodiments of the present application, the processing module 202 is configured to, when the first dynamic test result indicates that the test fails, acquire a second error code of the second code file.
[0159] The first error code is modified to obtain a third code file.
[0160] The test code file is called to perform static testing on the third code file to obtain a second static test result.
[0161] The test code file is called to perform static testing on the third code file to obtain a second static test result.
[0162] When the second static test result indicates that the test fails, the above operations are repeated until the static test passes, and a compiling operation of the code file is triggered.
[0163] The test code file is called to perform static testing on the third code file to obtain a second static test result.
[0164] The output module 203 is configured to repeat the above operation until the dynamic test result indicates that the test is passed, and output a final code file, when the second dynamic test result indicates that the test is failed.
[0165] In the embodiments of the present application, a code generation device is provided. By using the above device, the code file is tested in the CI environment according to static test, compilation and dynamic test, so that the code file can be conveniently tested, errors and code faults can be avoided, and the code development and updating cycle can be maintained.
[0166] Optionally, in the above Figure 9 Based on the embodiments of the above corresponding embodiments, in another embodiment of the code generation device 20 provided by the embodiments of the present application,
[0167] The output module 203 is configured to send the test result to a related device by a communication mode such as an email or a short message.
[0168] In the embodiments of the present application, a code generation device is provided. By using the above device, the results of each stage in the CI environment are sent to a related device, so that a developer can obtain the test result of the code file in time, errors and code faults can be avoided, and the code development and updating cycle can be maintained.
[0169] Optionally, in the above Figure 10 Based on the embodiments of the above corresponding embodiments, in another embodiment of the code generation device 20 provided by the embodiments of the present application,
[0170] The processing module 202 is configured to output the second code file and store the second code file to a code management platform when the test result indicates that the test is passed.
[0171] In the embodiments of the present application, a code generation device is provided. By using the above device, the second code file is stored to the code management platform, so that the code file can be shared, and the applicability of the scheme can be improved.
[0172] The code generation device provided by the present application can be used for a server. Please refer to Figure 10 , Figure 10is a schematic diagram of a server structure provided in an embodiment of the present application. The server 300 can have great differences due to different configurations or performances, and can include one or more central processing units (CPUs) 322 (for example, one or more processors) and a memory 332, one or more storage media 330 (for example, one or more mass storage devices) storing application programs 342 or data 344. The memory 332 and the storage media 330 can be temporary storage or persistent storage. The programs stored in the storage media 330 can include one or more modules (not shown in the figure), each of which can include a series of instruction operations in the server. Further, the central processing unit 322 can be configured to communicate with the storage media 330 and execute the series of instruction operations in the storage media 330 on the server 300.
[0173] The server 300 can also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM , and the like.
[0174] The steps performed by the server in the above embodiments can be based on the server structure shown in the above embodiments. Figure 11
[0175] The code generation apparatus provided in the present application can be used in a terminal device. Please refer to Figure 11 , for the sake of brevity, only parts related to the embodiments of the present application are shown, and specific technical details not disclosed are referred to the method part of the embodiments of the present application. In the embodiments of the present application, a terminal device is taken as a smartphone as an example for illustration:
[0176] Figure 11 A block diagram of part of the structure of a smartphone related to the terminal device provided in the embodiments of the present application is shown. Please refer to Figure 11 , the smartphone includes radio frequency (RF) circuit 410, memory 420, input unit 430, display unit 440, sensor 450, audio circuit 460, wireless fidelity (WiFi) module 470, processor 480, and power supply 490, and the like. Those skilled in the art can understand that Figure 11 The structure of the smartphone shown in the figure is not intended to limit the smartphone, which can include more or fewer components than shown, or combine some components, or arrange different components.
[0177] The following will be described in detail Figure 11 The various components of the smartphone will be described in detail:
[0178] The RF circuit 410 can be used for receiving and sending signals in the process of information or communication, in particular, receiving the downlink information of the base station and processing it by the processor 480; in addition, sending the uplink data to the base station. Generally, the RF circuit 410 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 410 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to global system for mobile communication (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), long term evolution (LTE), email, short message service (SMS), etc.
[0179] The memory 420 can be used to store software programs and modules, and the processor 480 executes various functions of the smartphone and code generation by running the software programs and modules stored in the memory 420. The memory 420 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), etc.; the data storage area can store data created according to the use of the smartphone (such as audio data, a phone book, etc.), etc. In addition, the memory 420 can include a high-speed random access memory, and can also include a non-volatile memory, for example, at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device.
[0180] The input unit 430 can be used to receive input digital or character information, and to generate key signal inputs for user settings and function controls of the smart phone. Specifically, the input unit 430 can include a touch panel 431 and other input devices 432. The touch panel 431, also called a touch screen, can collect a user's touch operation (such as the user's operation on or near the touch panel 431 using a finger, a stylus, or any suitable object or accessory) and drive a corresponding connection device according to a pre-set program. Optionally, the touch panel 431 can include two parts, a touch detection device and a touch controller. The touch detection device detects the user's touch position and detects the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into touch coordinates, and sends it to the processor 480, and can receive the commands from the processor 480 and execute them. In addition, the touch panel 431 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 431, the input unit 430 can also include other input devices 432. Specifically, the other input devices 432 can include one or more of a physical keyboard, function keys (such as volume control keys, on / off keys, etc.), trackballs, mice, joysticks, etc.
[0181] The display unit 440 can be used to display information input by the user or information provided to the user and various menus of the smart phone. The display unit 440 can include a display panel 441, which can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 431 can cover the display panel 441, and when the touch panel 431 detects a touch operation on or near it, it transmits to the processor 480 to determine the type of touch event, and then the processor 480 provides corresponding visual output on the display panel 441 according to the type of touch event. Although in the Figure 11 , the touch panel 431 and the display panel 441 are implemented as two independent components to realize the input and output functions of the smart phone, in some embodiments, the touch panel 431 and the display panel 441 can be integrated to realize the input and output functions of the smart phone.
[0182] The smart phone can also include at least one sensor 450, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor can include an ambient light sensor and a proximity sensor, where the ambient light sensor can adjust the brightness of the display panel 441 according to the brightness of ambient light, and the proximity sensor can turn off the display panel 441 and / or the backlight when the smart phone is moved to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and when at rest, can detect the magnitude and direction of gravity, and can be used for applications of identifying the smart phone posture (such as switching between landscape and portrait, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), and the like. As for other sensors that can also be configured on the smart phone, such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, and the like, they will not be described here.
[0183] The audio circuit 460, the speaker 461, and the microphone 462 can provide an audio interface between the user and the smart phone. The audio circuit 460 can convert the received audio data into an electrical signal, transmit the electrical signal to the speaker 461, and convert the electrical signal into a sound signal output by the speaker 461; on the other hand, the microphone 462 converts the collected sound signal into an electrical signal, which is received by the audio circuit 460 and converted into audio data, and then output to the processor 480 for processing, and then transmitted to another smart phone through the RF circuit 410, or output to the memory 420 for further processing.
[0184] WiFi belongs to a short-range wireless transmission technology, and the smart phone can help the user to send and receive emails, browse web pages, and access streaming media through the WiFi module 470, which provides the user with wireless broadband Internet access. Although Figure 11 The WiFi module 470 is shown, but it can be understood that it does not belong to the essential structure of the smart phone, and can be omitted as needed without changing the essence of the application.
[0185] The processor 480 is the control center of the smart phone, which connects all parts of the smart phone through various interfaces and lines, executes various functions of the smart phone and processes data by running or executing software programs and / or modules stored in the memory 420 and calling data stored in the memory 420, thereby monitoring the smart phone as a whole. Optionally, the processor 480 can include one or more processing units; optionally, the processor 480 can integrate an application processor and a modem processor, where the application processor mainly processes the operating system, user interface, and application program, and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 480.
[0186] The smart phone further includes a power supply 490 (such as a battery) for supplying power to each component. Optionally, the power supply can be logically connected to the processor 480 through a power management system, so that the power management system can realize functions such as management of charging, discharging, and power consumption management.
[0187] Although not shown, the smart phone can further include a camera, a Bluetooth module, and the like, which will not be described herein.
[0188] The steps performed by the terminal device in the above embodiments can be based on the terminal device structure shown in the above embodiments. Figure 11 The terminal device structure shown in the above embodiments.
[0189] The computer readable storage medium in the embodiments of the present application stores a computer program, and when the computer program is run on a computer, the computer program causes the computer to execute the method described in the above embodiments.
[0190] The computer program product in the embodiments of the present application includes a program, and when the program is run on a computer, the program causes the computer to execute the method described in the above embodiments.
[0191] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the above method embodiments, which will not be described herein.
[0192] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented by other ways. For example, the above-described device embodiments are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.
[0193] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, part or all of the units can be selected to realize the purpose of the embodiment scheme.
[0194] In addition, each of the functional units in the various embodiments of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0195] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in the form of a contribution to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and various other media that can store program codes.
[0196] The above-described embodiments are merely used to illustrate the technical solutions of the present application, rather than limit the same; even though the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still make modifications to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some of the technical features; and these modifications or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of the present application.
Claims
1. A code generation method, characterized in that: include: Obtaining a device description file and the business logic of a target device, wherein the device description file is used to describe communication information corresponding to a general device, and the target device is an application device for which a code file is to be generated from the device description file; Invoking a code converter to convert the communication information in the device description file to generate a first code file; Generate a business logic code file based on the business logic of the target device, wherein the business logic is used to describe the communication information corresponding to the target device; Converting the first code file into a second code file based on the business logic code file, and updating a compilation rule of the code file based on the business logic code file, wherein the second code file is a code file applied to the target device; Output the second code file.
2. The method according to claim 1, characterized in that Generating a business logic code file based on the business logic of the target device includes: Obtaining the communication logic corresponding to the target device and the communication information in the device description file; determining a conversion signal between the communication logic and the communication information; The business logic code file is generated according to the conversion signal.
3. The method according to claim 1, characterized in that The converting the first code file into a second code file based on the business logic code file includes: The bits or bytes in the first code file are converted according to the conversion signal described in the business logic code file to obtain the second code file.
4. The method according to claim 1, wherein Calling a code converter to convert the communication information in the device description file to generate a first code file includes: The dcbb tool is called to convert the communication information in the device description file to generate a first code file.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: A continuous integration environment is configured using a mirrored container, and the continuous integration environment is used to test code files.
6. The method according to claim 5, characterized in that After outputting the second code file, the method further includes: Uploading the second code file to the continuous integration environment; Get the test code file; Calling the test code file to test the second code file to obtain a test result; The second code file is processed according to the test result.
7. The method according to claim 6, characterized in that Calling the test code file to test the second code file to obtain a test result includes: Calling the test code file to perform a static test on the second code file to obtain a first static test result; When the first static test result indicates that the test passes, compiling the second code file to obtain a first running program; The test code file is called to perform dynamic testing on the running program to obtain a first dynamic test result, and the first static test result and the first dynamic test result are used as the test results.
8. The method according to claim 7, characterized in that After calling the test code file to perform a static test on the second code file to obtain a first static test result, the method further includes: When the first static test result indicates that the test fails, obtaining a first error code of the second code file; Modifying the first error code to obtain a third code file; Calling the test code file to perform a static test on the third code file to obtain a second static test result; When the second static test result indicates that the test fails, the above operation is repeated until the static test passes, triggering the compilation operation of the code file.
9. The method according to claim 7, characterized in that After calling the test code file to perform dynamic testing on the running program to obtain a first dynamic testing result, the method further includes: When the first dynamic test result indicates that the test fails, obtaining a second error code from the second code file; Modifying the second error code to obtain a fourth code file; Calling the test code file to perform a static test on the fourth code file to obtain a third static test result; When the third static test result indicates that the test passes, compile the fourth code file to obtain a second running program; Calling the test code file to perform dynamic testing on the second running program to obtain a second dynamic testing result; When the second dynamic test result indicates that the test fails, repeating the above operation until the dynamic test result indicates that the test passes, and outputting the final code file; When the second dynamic test result indicates that the test passes, the fourth code file is output.
10. The method according to any one of claims 6 to 9, characterized in that The method further comprises: The test results are sent to the relevant equipment via communication methods such as email or SMS.
11. The method according to any one of claims 6 to 9, characterized in that Processing the second code file according to the test result includes: When the test result indicates that the test is passed, the second code file is output and the second code file is stored in a code management platform.
12. The method according to any one of claims 1 to 4 and 6 to 9, characterized in that The target device is an intelligent driving vehicle, and the general device is an intelligent driving vehicle.
13. A code generating device, characterized in that: include: An acquisition module, configured to acquire a device description file and the business logic of a target device, wherein the device description file is used to describe communication information corresponding to a general device, and the target device is an application device for which a code file is to be generated from the device description file; A processing module, configured to generate a first code file based on the device description file; Generate a business logic code file based on the business logic of the target device, wherein the business logic is used to describe the communication information corresponding to the target device; Converting the first code file into a second code file based on the business logic code file, and updating a compilation rule of the code file based on the business logic code file, wherein the second code file is a code file applied to the target device; An output module is used to output the second code file.
14. A computer device, characterized in that: include: Memory, processor, and bus system; Wherein, the memory is used to store programs; The processor is configured to execute the program in the memory, and the processor is configured to execute the method according to any one of claims 1 to 12 according to instructions in the program code; The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.
15. A computer-readable storage medium comprising instructions, which, when executed on a computer, causes the computer to perform the method according to any one of claims 1 to 12.
16. A computer program product comprising a computer program, characterized in that The computer program is used by a processor to execute the method according to any one of claims 1 to 12.