Dynamic function table generation method and device and function calling method and device based on dynamic function table
By automatically generating dynamic function tables through predefined keywords and command line interface functions, the method addresses the inefficiencies in manual script editing, enhancing development efficiency and reducing errors in embedded system development.
Patent Information
- Application Number
- CN202411279239.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-31
AI Technical Summary
Developers face challenges in efficiently generating and managing dynamic function tables for embedded systems due to the need for deep understanding of link script writing rules and build system workflows, leading to increased time consumption and error-proneness, especially in environments like Linux where editable scripts are lacking.
A method and device for automatically generating a dynamic function table by scanning embedded source code for predefined keywords and corresponding command line interface functions, extracting function entry addresses, and creating a dynamic function table, which reduces reliance on manual script editing and enhances development efficiency.
The automatic generation of dynamic function tables simplifies the development process, reduces human error, and improves compatibility and maintainability, ensuring seamless integration with other components and systems.
Smart Images

Figure CN119225709A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for generating a dynamic function table and calling a function based on the dynamic function table. Background Art
[0002] As the complexity of embedded platform hardware grows, modular strategies are often used to organize and manage the development process of embedded system software to ensure that each functional module can be independently version controlled and compiled. In this context, the Command Line Interface (CLI) has gradually become a powerful tool for development and debugging due to its high flexibility and wide recognition by developers, especially because it can be dynamically adjusted according to the real-time progress of the project.
[0003] However, in existing methods, in order to adapt to this dynamic nature, developers usually need to add segment information to the link script, which not only requires them to be proficient in the link script writing rules of various compilers, but also requires a deep understanding of the entire build system to avoid the newly added segment information from being accidentally overwritten. Especially in environments that rely on specific system link scripts, such as Linux devices, finding and accurately modifying these scripts is often a difficult task. Summary of the invention
[0004] The embodiments of the present application provide a method and device for generating a dynamic function table and a function calling method based on the dynamic function table, aiming to automatically generate a dynamic function table to eliminate the developer's dependence on compilation and linking knowledge, thereby reducing time consumption in the development process and improving overall development efficiency.
[0005] According to one embodiment of the present application, a method for generating a dynamic function table is provided, comprising: scanning an embedded source code to determine keywords defined in the embedded source code; wherein the embedded source code includes predefined keywords and corresponding command line interface functions; extracting a function entry address of the corresponding command line interface function according to the keywords; and generating a dynamic function table according to the function entry address.
[0006] In an implementable manner, the predefined keywords and the corresponding command line interface functions are configured as follows: the keywords and the command line interface functions are defined in an embedded source code based on a preset association format.
[0007] In one implementable manner, the command line interface function includes: a command word and a functional description of the command line interface function.
[0008] In one implementable manner, the command line interface function further includes: the number and type of parameters of the command line interface function.
[0009] In one implementable manner, extracting a function entry address of a corresponding command line interface function according to a keyword includes: determining the command line interface function corresponding to the keyword according to an association format between the keyword and the command line interface function; and extracting the function entry address of the command line interface function.
[0010] In one implementable manner, generating a dynamic function table according to a function entry address includes: storing the function entry addresses in the function table in an array form to generate the dynamic function table.
[0011] In an implementable manner, after the dynamic function table is generated according to the function entry address, the method further includes: calling system compilation to map the dynamic function table to an embedded image file.
[0012] According to another aspect of an embodiment of the present application, a function calling method based on a dynamic function table is further provided, wherein the dynamic function table is generated based on the dynamic function table generating method in the aforementioned exemplary embodiment, and comprises:
[0013] If the input command word is obtained, the dynamic function table is queried according to the command word to determine the corresponding function entry address; the obtained parameters are carried to jump from the function entry address to the function entry of the command line interface function; the command line interface function is called, and the corresponding function function is executed according to the parameters.
[0014] According to another aspect of an embodiment of the present application, a dynamic function table generation device is also provided, including a keyword search module, used to scan an embedded source code and determine keywords defined in the embedded source code; wherein the embedded source code includes pre-defined keywords and corresponding command line interface functions; a function entry address extraction module, used to extract the function entry address of the corresponding command line interface function according to the keywords; and a dynamic function table generation module, used to generate a dynamic function table according to the function entry address.
[0015] According to another aspect of an embodiment of the present application, a function calling device based on a dynamic function table is also provided. The dynamic function table used by the device is generated based on the dynamic function table generation method in the aforementioned exemplary embodiment, including: a function entry address determination module, which is used to query the dynamic function table according to the command word when an input command word is obtained, and determine the corresponding function entry address; a function entry jump module, which is used to carry the obtained parameter input and jump from the function entry address to the function entry of the command line interface function; a command line interface function calling module, which is used to call the command line interface function and execute the corresponding function function according to the parameters.
[0016] The present application provides a method and device for generating a dynamic function table and a function calling method based on the dynamic function table, wherein the dynamic function generation method automatically defines keywords and corresponding command line interface functions in embedded source code, and according to the corresponding relationship, enables the development tool to extract the function entry address corresponding to the command line interface function from the keywords during the scanning of the source code, and generate a dynamic function table from it, thereby reducing the time-consuming and cumbersome script link editing and the overly restricted Linux environment caused by following script writing rules, thereby ensuring the overall development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 is a schematic diagram of a hardware environment of a function calling method based on a dynamic function table according to an embodiment of the present application;
[0020] Figure 2 is a flow chart of a method for generating a dynamic function table according to an embodiment of the present application;
[0021] Figure 3 It is a flow chart of extracting the function entry address of the corresponding command line interface function according to the keyword in a dynamic function table generation method according to an embodiment of the present application;
[0022] Figure 4 is a flow chart of a function calling method based on a dynamic function table according to an embodiment of the present application;
[0023] Figure 5 is a structural schematic diagram of a dynamic function table generating device according to an embodiment of the present application;
[0024] Figure 6 is a structural schematic diagram of a function calling device based on a dynamic function table according to an embodiment of the present application;
[0025] Figure 7 It is the way that existing specific compilers write function implementation code for specific connection scripts. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] According to one aspect of an embodiment of the present application, a dynamic function table generation method and a function calling method based on the dynamic function table are provided. In the control of smart home devices, a gateway device is usually used to control the smart home devices based on an embedded system. Therefore, the dynamic function table generation method and the function calling method based on the dynamic function table can be applied in the scenario of controlling smart home devices. The function calling method based on the dynamic function table can be widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (Intelligence House) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above-mentioned function calling method based on the dynamic function table can be applied to the following scenarios: Figure 1 In the hardware environment composed of the terminal device 102 and the server 104 shown in FIG. Figure 1 As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0029] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0030] With the increasing complexity of embedded platform hardware, modular strategies are being used to organize and manage the development process of embedded system software to ensure that each functional module can be independently version controlled and compiled. In this context, the command line interface (CLI) has gradually become a powerful tool for development and debugging due to its high flexibility and wide recognition by developers, especially because it can be dynamically adjusted according to the real-time progress of the project.
[0031] However, in order to adapt to this command line interface, developers usually need to add segment information to the link script, which not only requires them to be proficient in the link script writing rules of various compilers, but also requires a deep understanding of the entire build system to avoid the newly added segment information being accidentally overwritten. Especially in environments that rely on specific system link scripts, such as Linux devices, they need to find and accurately modify these scripts.
[0032] In order to adapt to the dynamic nature of embedded system development and ensure the flexibility and configurability of software functional modules, developers often need to add specific segment information in the linker script. This step is crucial to ensure that the program can correctly place data or code in the specified location in memory when it is running. However, this will cause the following technical problems:
[0033] First, you need to be proficient in the link script writing rules of various compilers. Different compilers may use different syntax and instructions to define segment information, which means that developers need to be familiar with and understand the specific rules of the compiler used. This usually takes a lot of time and effort to learn and practice.
[0034] Secondly, you also need to have a deep understanding of the entire build system. Developers need to understand how the build system works, including various stages such as compilation, linking, and optimization. Only in this way can they ensure that the newly added segment information will not be accidentally overwritten or conflict with other parts. This requires a deep understanding of the build system and rich experience.
[0035] And manually editing the linker script is a tedious and error-prone task. Especially in large projects, the linker script may contain hundreds or even thousands of segment definitions. Manually modifying these definitions is not only time-consuming, but also easy to introduce errors.
[0036] At the same time, in specific usage environments, such as Linux, due to the simplicity and specificity of the system, the system usually does not directly provide developers with editable link scripts, but relies on default build processes and scripts. This may not fully meet the special needs of developers in some cases. For example, when developers need to adjust the memory layout or segment definition for specific hardware or application scenarios, they often find it difficult to directly find the correct configuration file and modify it.
[0037] Due to the lack of directly editable link scripts, developers may need to search for relevant configuration files in the deep structure of the build system, or have a deep understanding of the usage details of the underlying build tools and linkers. This process is not only time-consuming, but also requires developers to have deep knowledge and experience in embedded system development. Therefore, when developers face such challenges, their development efficiency may be seriously affected, thereby delaying the time to market of the product.
[0038] In addition, for the function table used in the subsequent steps, the method currently adopted also includes the following conditions: developers need to be proficient in the link script writing rules of various compilers and have a deep understanding of the workflow of the entire build system, which limits the number of users; link scripts may contain a large number of segment definitions, and manually editing these definitions is not only time-consuming but also prone to errors, which reduces efficiency; embedded Linux systems usually do not directly provide user-editable link scripts, but rely on default build processes and scripts. When developers need to adjust memory layout or segment definitions for specific hardware or application scenarios, they find it difficult to directly find and modify the correct configuration files, which further reduces development efficiency; due to the simplicity and specificity of embedded Linux systems, developers may need to go deep into the underlying structure of the build system, search for related configuration files, or understand the details of the use of underlying build tools and linkers. This process is time-consuming and difficult, requiring developers to have deep knowledge and experience in embedded system development, which further increases the difficulty and cost of technical implementation. In summary, the disadvantages of these technologies mainly include high professional knowledge requirements, the tediousness and error-proneness of editing link scripts, the limitations of embedded Linux environments, and the difficulty of searching and understanding underlying details. These disadvantages together lead to reduced development efficiency.
[0039] Therefore, one aspect of the embodiments of the present application provides a method for generating a dynamic function table, such as Figure 2 As shown, including:
[0040] Predefine keywords and corresponding command line interface functions in the embedded source code; keywords can be in a customized form, for example, multiple alphabetic characters are used to form keywords. For example, keywords can be defined as AUTO_CLI_OUTPUT_FUNCTION, where the keywords include multiple groups of letters, and each group of letters is connected by "_" to form a keyword. Of course, it is understandable that the definition of keywords is not limited to letters or "_" symbols. Accordingly, the number of command line interface functions needs to be the same as that of keywords, and the defined keywords and defined command line interface functions form a one-to-one correspondence.
[0041] Based on a preset association format, this preset method includes but is not limited to the same line belonging to the same code segment, or the two can be connected by a preset symbol to indicate the corresponding relationship between the keyword and the command line function. For example, the keyword and the command line function can be connected by symbols such as "-", ">>", etc.; the keyword and the command line interface function are defined in the embedded source code. In addition, the format association of keywords and command line interface functions can not only play a corresponding role, but also provide a clear framework, so that developers can achieve unified specifications in the process of writing code frameworks and subsequent program maintenance, and can prevent the emergence of differentiation.
[0042] The defined command line interface function is set based on a specific function, and usually includes the command word and function description of the command line interface function; the command word and function description are also entered in the process of defining the command line interface function. It should be noted here that the above command line interface function needs to follow a unified specification, which is not only conducive to the improvement of development speed, but also conducive to subsequent maintenance.
[0043] In addition, the process of defining the corresponding command line interface function also includes defining the number and type of parameters of the command line interface function, which will be beneficial in the subsequent calling process, that is, executing the corresponding function according to the specified number and type of parameters. Specifying the number and type of input parameters of the command line function can ensure that the calling and execution process of the function is clear.
[0044] 240: Scan the embedded source code to determine the keywords defined in the embedded source code; the embedded source code can be stored locally on the device or obtained from other devices, and the embedded source code includes predefined keywords and corresponding command line interface functions. The code scanning tool used for scanning can be an existing code scanning tool. During use, all the above source codes are scanned to search for keywords. Of course, if necessary, a certain section or several sections in the source code can be specified for keyword scanning. For example, if the keyword includes AUTO_CLI_OUTPUT_FUNCTION, then the above keyword AUTO_CLI_OUTPUT_FUNCTION contained in the source code is scanned; the above scanning process is a process of automatic recognition by a code scanning tool, which can reduce the time required for manual search and manual recognition of codes.
[0045] And as an optional implementation, in the process of searching for keywords, the identification of code snippets that define line command interface functions is also achieved. Therefore, it can be further understood that the above code snippets can be code snippets that interleave key information such as keywords, command words, and function descriptions.
[0046] 260: Extracting the function entry address of the corresponding command line interface function according to the keyword; the extraction process includes:
[0047] Further Figure 3 As shown, 332: according to the association format between the keyword and the command line interface function, determine the command line interface function corresponding to the keyword; as mentioned above, the association format can be the same line belonging to the same code segment, or the two can be connected by a preset symbol. Its main purpose is to achieve a clear correspondence, that is, according to the keyword AUTO_CLI_OUTPUT_FUNCTION, find the corresponding line command interface function.
[0048] 334: Extract the function entry address of the command line interface function. As mentioned above, the command line interface function follows a unified specification, so it must be set with a corresponding function entry address, and the number should be unique. After all the keywords are found, the corresponding command line interface functions are obtained, and then the function entry addresses corresponding to each command line interface function are obtained.
[0049] 280: Generate a dynamic function table according to the function entry address. The aforementioned code scanning tool is preset with rule logic instructions for generating a dynamic function table, which can be stored in the form of an array according to the function entry address obtained above, and automatically generate a dynamic function table. The generated function table can automatically generate a compilable file, such as a C language source file. The function entry address in the function table is stored in the form of a C language array, and does not involve the connection between the function entry address and the corresponding function implementation. The generation process is an automatic process, and after the process, the dynamic function table can be mapped to an embedded image file by calling the system compilation, specifically by connecting the function entry address of the dynamic function table with the corresponding function implementation to generate an embedded image file image. Figure 7As shown in the figure, the existing specific compiler is used to write the function implementation code for a specific connection script. This writing method requires developers to actively find the connection file and ensure that the content is written correctly. It should be pointed out here that in the embedded Linux environment, due to the simplicity and specificity of the system, the system usually does not directly provide user-editable link scripts, but relies on the default build process and scripts. This default mechanism may not fully meet the special needs of developers in some cases. When developers need to adjust the memory layout or segment definition for specific hardware or application scenarios, they often find it difficult to directly find the correct configuration file and modify it. In turn, developers may need to search for relevant configuration files in the deep structure of the build system, or have a deep understanding of the usage details of the underlying build tools and linkers. This process not only increases the learning cost of developers and increases time consumption, but also requires developers to have deep knowledge and experience in embedded system development. By comparison, it can be seen that automatically generating dynamic function tables will help improve the efficiency of embedded development.
[0050] The embedded image file image can be loaded onto the embedded device for running. In addition, the generation process of the above-mentioned dynamic function table is also an automatic generation process, which avoids the tedious process of manually writing the function table, and has a high degree of compatibility and reliability by adopting preset rules and logic. This reduces problems caused by human errors and enhances the maintainability of the code, and because the dynamic function table is automatically generated based on preset rules and logic, it has a high degree of compatibility. This ensures that the generated dynamic function table can be seamlessly integrated with other components or systems; accordingly, the automatically generated function table reduces the possibility of human errors and improves the reliability of the system.
[0051] A dynamic function table generation method provided by the present application automatically defines keywords and corresponding command line interface functions in embedded source code, and according to the corresponding relationship, enables the development tool to extract the function entry address corresponding to the command line interface function from the keywords during the scanning of the source code, and generate a dynamic function table from it, thereby reducing the time-consuming and cumbersome script link editing and the overly restricted Linux environment caused by following script writing rules, thereby ensuring the overall development efficiency.
[0052] This embodiment further proposes a function calling method based on a dynamic function table on the basis of the above technical solution. The dynamic function table involved is obtained by the dynamic function table generation method provided by any of the above embodiments. Figure 4 As shown, the function calling method based on the dynamic function table includes:
[0053] 420: If the input command word is obtained, query the dynamic function table according to the command word to determine the corresponding function entry address;
[0054] Specifically, before obtaining the command word, it is also necessary to load the aforementioned embedded image file image into the hardware of the embedded device and start the embedded device to run the embedded system; after the embedded system is initialized, it can also include judging whether the system has entered the ready state. If the system is initialized normally and enters the ready state, it can wait for the command input, that is, judging whether the input command word is obtained. Optionally, the method of obtaining the command word can be to obtain the input command word through the serial communication interface of the embedded device. Of course, other methods can also be used to obtain the input command word, and after obtaining the command word, the corresponding function entry address in the command line interface function in the dynamic function table is searched according to the command word;
[0055] 440: Jump from the function entry address to the function entry of the command line interface function with the acquired parameters. While acquiring the input command word through the serial communication interface or other means, the input parameters can also be acquired through the serial communication interface or other means. Of course, the command word and the parameters can also be acquired at different times. The input command word jumps to the corresponding function entry through the confirmed function entry address.
[0056] 460: Call the command line interface function and execute the corresponding function according to the parameters. The acquired parameters are input into the corresponding command line interface function, so that the command line interface function receives and subsequently executes the functions related to the command line function. Some command line interface functions will output related information after running.
[0057] This embodiment further proposes a dynamic function table generation device based on the above technical solution, such as Figure 5 As shown, including:
[0058] The keyword search module 504 is used to scan the embedded source code to determine the keywords defined in the embedded source code; wherein the embedded source code includes predefined keywords and corresponding command line interface functions;
[0059] The code scanning tool used for scanning can be an existing code scanning tool. During use, the entire source code is scanned to search for keywords. Of course, if necessary, a certain section or several sections in the source code can be specified for keyword scanning. For example, if the keyword includes AUTO_CLI_OUTPUT_FUNCTION, then the above keyword AUTO_CLI_OUTPUT_FUNCTION contained in the source code is scanned; the above scanning process is a process of automatic recognition by a code scanning tool, which can reduce the time required for manual search and manual recognition of code.
[0060] And as an optional implementation, in the process of searching for keywords, the identification of code snippets that define line command interface functions is also achieved. Therefore, it can be further understood that the above code snippets can be code snippets that interleave key information such as keywords, command words, and function descriptions.
[0061] Keywords can be in a customized form, for example, multiple alphabetic characters are combined into keywords. For example, a keyword can be defined as AUTO_CLI_OUTPUT_FUNCTION, where the keyword includes multiple groups of letters, and each group of letters is connected by "_" to form a keyword. Of course, it is understandable that the definition of keywords is not limited to letters or "_". Accordingly, the number of command line interface functions needs to be the same as the keywords, and the defined keywords and the defined command line functions form a one-to-one correspondence.
[0062] The defined command line interface function is set based on a specific function, and usually includes the command word and function description of the command line interface function; the command word and function description are also entered in the process of defining the command line interface function. It should be noted here that the above command line interface function needs to follow a unified specification, which is not only conducive to the improvement of development speed, but also conducive to subsequent maintenance.
[0063] In addition, the process of defining the corresponding command line interface function also includes defining the number and type of parameters of the command line interface function, which will be beneficial in the subsequent calling process, that is, executing the corresponding function according to the specified number and type of parameters. Specifying the number and type of input parameters of the command line function can ensure that the calling and execution process of the function is clear.
[0064] The function entry address extraction module 506 is used to extract the function entry address of the corresponding command line interface function according to the keyword; the function entry address extraction module 506 is configured to perform the following operations:
[0065] According to the association format between the keyword and the command line interface function, the command line interface function corresponding to the keyword is determined; the association format as mentioned above can be the same line belonging to the same code segment, or the two can be connected by a preset symbol. Its main purpose is to achieve a clear correspondence, that is, according to the keyword AUTO_CLI_OUTPUT_FUNCTION, find the corresponding line command interface function.
[0066] Extract the function entry address of the command line interface function. As mentioned above, the command line interface function follows a unified specification, so it must be set with a corresponding function entry address, and the number should be unique. After all the keywords are found, the corresponding command line interface functions are obtained, and then the function entry addresses corresponding to each command line interface function are obtained.
[0067] The dynamic function table generation module 508 is used to generate a dynamic function table according to the function entry address. The aforementioned code scanning tool is preset with rule logic instructions for generating a dynamic function table, which can be stored in the form of an array according to the function entry address obtained above, and automatically generate a dynamic function table. The generated function table can automatically generate a compilable file, such as a C language source file. The function entry address in the function table is stored in the form of a C language array, and does not involve the connection between the function entry address and the corresponding function implementation. The generation process is an automatic process, and after the process, the dynamic function table can also be mapped to an embedded image file by calling the system compilation, by connecting the function entry address and the corresponding function implementation of the dynamic function table into the embedded image file image. Figure 7 As shown in the figure, the existing specific compiler is used to write the function implementation code for a specific connection script. This writing method requires developers to actively find the connection file and ensure that the content is written correctly. It should be pointed out here that in the embedded Linux environment, due to the simplicity and specificity of the system, the system usually does not directly provide user-editable link scripts, but relies on the default build process and scripts. However, this default mechanism may not fully meet the special needs of developers in some cases. When developers need to adjust the memory layout or segment definition for specific hardware or application scenarios, they often find it difficult to directly find the correct configuration file and modify it. In turn, developers may need to search for relevant configuration files in the deep structure of the build system, or have a deep understanding of the usage details of the underlying build tools and linkers. This process not only increases the learning cost of developers and increases time consumption, but also requires developers to have deep knowledge and experience in embedded system development. By comparison, it can be seen that automatically generating dynamic function tables will help improve the efficiency of embedded development.
[0068] The embedded image file image can be loaded onto the embedded device for running. In addition, the generation process of the above-mentioned dynamic function table is also an automatic generation process, which avoids the tedious process of manually writing the function table, and has a high degree of compatibility and reliability by adopting preset rules and logic. This reduces problems caused by human errors and enhances the maintainability of the code, and because the dynamic function table is automatically generated based on preset rules and logic, it has a high degree of compatibility. This ensures that the generated dynamic function table can be seamlessly integrated with other components or systems; accordingly, the automatically generated function table reduces the possibility of human errors and improves the reliability of the system.
[0069] The dynamic function table generating device provided in this embodiment adopts the same technical concept as the aforementioned dynamic function table generating method and achieves the same technical effect, which will not be described in detail here.
[0070] This embodiment further proposes a function calling device based on a dynamic function table on the basis of the above technical solution. The dynamic function table used is based on the above dynamic function table generation method, such as Figure 6 As shown, specifically including:
[0071] The function entry address determination module 602 is used to query the dynamic function table according to the command word to determine the corresponding function entry address if the input command word is obtained;
[0072] A function entry jump module 604, used to carry the acquired parameters and jump from the function entry address to the function entry of the command line interface function;
[0073] The command line interface function calling module 606 is used to call the command line interface function and execute the corresponding function according to the parameters.
[0074] As an optional implementation, the function calling device based on the dynamic function table also includes an embedded image file loading module, which is used to load the embedded image file image into the hardware of the embedded device before obtaining the command word; an embedded system running module, which is used to start the embedded device to run the embedded system for initialization; and a system status determination module, which is used to determine whether the system has entered a ready state after the embedded system is initialized. If the system is initialized normally and enters the ready state, it can wait for command input.
[0075] In an optional embodiment, the function calling device based on the dynamic function table also includes a command word acquisition module for acquiring command words in a preset manner, wherein the method for acquiring command words can be to acquire input command words through a serial communication interface of an embedded device, and of course other methods can also be used to acquire input command words.
[0076] In an optional embodiment, the function calling device based on the dynamic function table also includes a command parameter acquisition module, which is used to obtain input parameters through a preset method, wherein the input command word can be obtained through a serial communication interface or other methods at the same time as the input parameters are obtained through a serial communication interface or other methods, or the command word and parameters can be obtained at different times.
[0077] In an optional implementation, the function entry jump module 604 is specifically used to jump the input command word to the corresponding function entry after the confirmed function entry address, and input the acquired parameters into the corresponding command line interface function, so that the command line interface function calling module implements the command line interface function receiving and subsequent execution of command line function related functions. For some command line interface functions, relevant information will be output after running. In an optional implementation, the function calling device based on the dynamic function table also includes an output information feedback module, which is used to feed back the output information after the command line function is executed to the user, wherein the output information can be fed back through the serial communication interface of the embedded device.
[0078] The embodiment of the present application further provides an electronic device, wherein the electronic device may be a computer device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to perform the following steps through the computer program:
[0079] Scan the embedded source code and search for the keywords defined in the embedded source code; wherein the embedded source code includes predefined keywords and corresponding command line interface functions; extract the function entry address of the corresponding command line interface function according to the keywords; generate a dynamic function table according to the function entry address. The memory, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as the program instructions / modules corresponding to the dynamic function table generation method in the embodiment of the present application (for example, the keyword search module 504, the function entry address extraction module 506 and the dynamic function table generation module 508 in the dynamic function table generation device). The processor executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory, that is, the above-mentioned dynamic function table generation method is realized.
[0080] The embodiment of the present application further provides an electronic device, wherein the electronic device may be a computer device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to perform the following steps through the computer program:
[0081] If the input command word is obtained, the dynamic function table is queried according to the command word to determine the corresponding function entry address; the obtained parameters are carried to jump from the function entry address to the function entry of the command line interface function; the command line interface function is called, and the corresponding function function is executed according to the parameters. The dynamic function table is generated based on the dynamic function table generation method in any of the above embodiments.
[0082] As a computer-readable storage medium, the memory can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the function calling method based on the dynamic function table in the embodiment of the present application (for example, the function entry address determination module 602, the function entry jump module 604 and the command line interface function calling module 606 in the function calling device based on the dynamic function table). The processor executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory, that is, realizing the above-mentioned function calling method based on the dynamic function table.
[0083] In the embodiments of the present application, the above-mentioned storage medium may include, but is not limited to: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk or optical disk and other media that can store program code. Through the above description of the implementation method, the technicians in the relevant field can clearly understand that the present invention can be implemented with the help of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium.
[0084] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for generating a dynamic function table, characterized in that: include: Scanning the embedded source code to determine the keywords defined in the embedded source code; wherein the embedded source code includes predefined keywords and corresponding command line interface functions; Extracting the function entry address of the corresponding command line interface function according to the keyword; A dynamic function table is generated according to the function entry address.
2. The method according to claim 1, characterized in that The predefined keywords and the corresponding command line interface functions are set as: The keywords and the command line interface functions are defined in the embedded source code based on a preset association format.
3. The method according to claim 2, characterized in that The command line interface function includes: The command word and function description of the command line interface function.
4. The method according to claim 3, characterized in that The command line interface function also includes: The number and type of parameters of the command line interface function.
5. The method according to claim 2, characterized in that: The step of extracting the function entry address of the command line interface function corresponding to the keyword includes: Determining the command line interface function corresponding to the keyword according to the association format between the keyword and the command line interface function; Extract the function entry address of the command line interface function.
6. The method according to claim 5, characterized in that The generating a dynamic function table according to the function entry address comprises: The function entry addresses in the function table are stored in an array form to generate the dynamic function table.
7. The method according to claim 1, characterized in that After generating the dynamic function table according to the function entry address, the method further includes: Calling system compilation, mapping the dynamic function table to an embedded image file.
8. A function calling method based on a dynamic function table, characterized in that: The dynamic function table is generated based on the dynamic function table generation method according to any one of claims 1 to 7, comprising: If the input command word is obtained, the dynamic function table is searched according to the command word to determine the corresponding function entry address; Carrying the acquired parameters, jumping from the function entry address to the function entry of the command line interface function; Call the command line interface function and execute the corresponding function according to the parameters.
9. A dynamic function table generating device, characterized in that: include: A keyword search module, used to scan the embedded source code and determine the keywords defined in the embedded source code; wherein the embedded source code includes predefined keywords and corresponding command line interface functions; A function entry address extraction module, used to extract the function entry address of the corresponding command line interface function according to the keyword; The dynamic function table generating module is used to generate a dynamic function table according to the function entry address.
10. A function calling device based on a dynamic function table, characterized in that: The dynamic function table is generated based on the dynamic function table generation method according to any one of claims 1 to 7, comprising: A function entry address determination module, for, if an input command word is obtained, querying the dynamic function table according to the command word to determine a corresponding function entry address; A function entry jump module, used to carry the acquired parameters and jump from the function entry address to the function entry of the command line interface function; The command line interface function calling module is used to call the command line interface function and execute the corresponding function according to the parameters.
