Data communication method, device and system of embedded software, equipment and medium
By analyzing the communication frames sent by the host computer and querying them in the multi-level command table, the callback function of the lowest-level command is solved, and the problem of repeated development of the same functions in the chip system is achieved, achieving higher flexibility and reduced maintenance complexity.
Patent Information
- Application Number
- CN202510515192.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2045-04-23
AI Technical Summary
In the chip production and quality inspection system, although there are functional differences in multiple chips of the same series, most of the functions are the same, which leads to the computer software requiring repeated development operations on the same functions, resulting in wasting development resources and complex software maintenance.
By analyzing the communication frames sent by the upper computer, a multi-level command combination is obtained, and a hierarchical query is performed in the pre-established multi-level command table to obtain the callback function corresponding to the lowest level command. Pass a preset pointer to the communication frame as a parameter to the callback function to initiate data communication.
It avoids repeated development of the same functions, reduces the complexity of software maintenance, and improves the flexibility of the computer software, so that it does not depend on the specific chip architecture, but on the functions implemented by the chip.
Smart Images

Figure CN120045249A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of embedded software technology, and in particular to a data communication method, device, system, equipment and medium for embedded software. Background Art
[0002] In embedded software design, the lower-level computer software system is responsible for the underlying data acquisition, control execution and other tasks. It needs to communicate data with the upper-level computer to achieve more complex functions. Usually, polling or state machine switching is used to achieve the data communication process with the upper-level computer.
[0003] As the basis for the operation of the lower-level computer software, the chip provides basic computing, storage capabilities and various interface resources. Considering that different chips use different architectures and instruction sets, it is usually necessary to design the lower-level computer software separately to achieve different data communications. However, in the complex technical environment of chip production and quality inspection systems, although there are certain functional differences among multiple chips in the same series, most of the functions are the same, which means that the lower-level computer software needs to repeatedly develop the same functions, which not only wastes development resources but also increases the complexity of software maintenance. Summary of the invention
[0004] In view of this, the present application provides a data communication method, device, system, equipment and medium for embedded software, the main purpose of which is to solve the problem in the prior art that repeated development operations for the same functions will cause waste of development resources and increase the complexity of software maintenance.
[0005] In a first aspect, a data communication method of embedded software is provided, comprising: When receiving a communication frame sent by the host computer, parsing the communication frame to obtain a multi-level command combination, wherein the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure; Performing a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command, wherein the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure, and non-lowest-level commands are used as indexes to query a command table of a next level in a command table of a current level, and the lowest-level command is used to query the callback function; The preset pointer pointing to the communication frame is passed as a parameter to the callback function, so that the callback function determines the lower computer calling function through the preset pointer and initiates data communication according to the lower computer calling function.
[0006] Further, the communication frame is parsed to obtain a multi-level command combination, including: Determining the field area of the multi-level command in the communication frame according to the frame structure specified by the protocol; Decoding the command fields of each level in the communication frame according to the field area of the multi-level command to obtain the multi-level command and the logical relationship between the multi-level commands; The multi-level commands are processed using the logical relationship between the multi-level commands to obtain a multi-level command combination.
[0007] Further, decoding the command fields of each level in the communication frame according to the field area of the multi-level command to obtain the multi-level command and the logical relationship between the multi-level commands includes: Identifying a field identification bit of a first-level command in a communication frame according to the field area of the multi-level command, so as to decode a first-level command field in the communication frame through the field identification bit of the first-level command to obtain a first-level command; Based on the first-level command, determine a command field identification bit of a next-level in the communication frame, so as to decode the command field of the next-level in the communication frame through the command field identification bit of the next-level to obtain a next-level command; Based on the next level of commands, the command fields of each level are decoded in turn until the command field of the lowest level. In the process of decoding the command fields of each level, the associations between the commands of each level are recorded to obtain multi-level commands and the logical relationships between the multi-level commands.
[0008] Furthermore, before performing hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command, the method further includes: Decompose the functions of embedded software systems into multi-level commands; Constructing command tables of different levels according to the multi-level commands, wherein the lowest level command table is constructed according to the lowest level command and the callback function corresponding to the lowest level command, and the non-lowest level command table is constructed according to the non-lowest level command; The command tables of different levels are hierarchically bound with the multi-level commands in the order from the lowest level command to the highest level command to obtain a multi-level command table. During the hierarchical binding process, the command table of the current level is bound to the command of the previous level using the command of the previous level as an index until the highest level command is reached.
[0009] Further, after hierarchically binding the command tables of different levels with the multi-level commands in the order from the lowest level command to the highest level command, the method further includes: In the process of hierarchical binding, the binding relationship between the command tables of different hierarchies and the commands of the previous hierarchical level is recorded; When the binding relationship changes, the binding relationship between the command table of the corresponding level and the command of the previous level is released, and the command table of the corresponding level is bound to the updated command of the previous level using the updated command of the previous level as an index to update the binding relationship between the command table and the command in the multi-level command table.
[0010] Further, the multi-level command set includes a main command set and a sub-command set, the main command is a non-lowest level command, the sub-command is a lowest level command, and the multi-level command table includes a main command table and a sub-command table; Accordingly, the functions of the embedded software system are decomposed into primary commands and secondary commands; Constructing a secondary command table and a main command table respectively, wherein the secondary command table is constructed according to the secondary command and the callback function corresponding to the secondary command, and the main command table is constructed according to the main command; The secondary command table is bound to the primary command using the primary command as an index to obtain a multi-level command table.
[0011] Furthermore, the lowest level command is stored through a first setting structure, which at least includes a lowest level command field, a callback function pointer variable, and a reserved field; the lowest level command table is stored through a second setting structure, which at least includes a pointer variable of the lowest level command, a command quantity field, a command description field, and a reserved field; the non-lowest level command table is stored through a third setting structure, which at least includes a pointer variable of the non-lowest level command, a command quantity field, a command description field, and a reserved field.
[0012] Further, performing a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command includes: According to the multi-level command combination, a hierarchical query is performed in a pre-established multi-level command table in the order of the highest level command to the lowest level command; During the hierarchical query process, the current level command is used as an index to query the command table of the current level to obtain the command table of the next level, until the lowest level command is used to query the command table of the lowest level to obtain the callback function corresponding to the lowest level command.
[0013] Further, the multi-level command combination includes a main command and a sub-command, the main command is a non-lowest level command, the sub-command is a lowest level command, and the multi-level command table includes a main command table and a sub-command table; Correspondingly, when receiving the communication frame sent by the host computer, the communication frame is parsed to obtain the main command and the secondary command; Using the main command as an index to search the main command table, to obtain a secondary command table; According to the sub-command, the sub-command table is searched to obtain the callback function corresponding to the sub-command.
[0014] In a second aspect, an embedded software data communication system is provided, comprising: an application layer, a system layer, an adaptation layer and a resource library; The application layer is used to construct a command table of the lowest level, and hierarchically bind the command table of the lowest level by exposing a pointer, so that command tables of multiple levels are coupled to obtain a multi-level command table; The system layer calls the resource library to store the multi-level command table in the resource library; When receiving a communication frame sent by the host computer, the system layer calls the adaptation layer to parse the communication frame, and calls the resource library to perform a hierarchical query in the multi-level command table according to the multi-level command combination obtained by the parsing, and obtains the callback function corresponding to the lowest level command; The system layer initiates data communication with the host computer according to the callback function.
[0015] A third aspect provides a data communication device of embedded software, comprising: A parsing unit, configured to parse a communication frame sent by a host computer to obtain a multi-level command combination when receiving the communication frame, wherein the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure; A query unit, used to perform hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command, wherein the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure, and non-lowest-level commands are used as indexes to query the command table of the next level in the command table of the current level, and the lowest-level command is used to query the callback function; The communication unit is used to pass the preset pointer pointing to the communication frame as a parameter to the callback function, so that the callback function determines the lower computer calling function through the preset pointer and initiates data communication according to the lower computer calling function.
[0016] Furthermore, the parsing unit is specifically used for: Determining the field area of the multi-level command in the communication frame according to the frame structure specified by the protocol; Decoding the command fields of each level in the communication frame according to the field area of the multi-level command to obtain the multi-level command and the logical relationship between the multi-level commands; The multi-level commands are processed using the logical relationship between the multi-level commands to obtain a multi-level command combination.
[0017] Furthermore, the parsing unit is further configured to: Identifying a field identification bit of a first-level command in a communication frame according to the field area of the multi-level command, so as to decode a first-level command field in the communication frame through the field identification bit of the first-level command to obtain a first-level command; Based on the first-level command, determine a command field identification bit of a next-level in the communication frame, so as to decode the command field of the next-level in the communication frame through the command field identification bit of the next-level to obtain a next-level command; Based on the next level of commands, the command fields of each level are decoded in turn until the command field of the lowest level. In the process of decoding the command fields of each level, the associations between the commands of each level are recorded to obtain multi-level commands and the logical relationships between the multi-level commands.
[0018] Furthermore, the device also includes: A disassembling unit, configured to disassemble the functions of the embedded software system into multi-level commands before performing a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command; A construction unit, configured to construct command tables of different levels according to the multi-level commands, wherein the command table of the lowest level is constructed according to the lowest level command and the callback function corresponding to the lowest level command, and the command table of the non-lowest level is constructed according to the non-lowest level command; A binding unit is used to hierarchically bind the command tables of different levels with the multi-level commands in the order from the lowest level command to the highest level command to obtain a multi-level command table. During the hierarchical binding process, the command table of the current level is bound to the command of the previous level using the command of the previous level as an index until the highest level command is reached.
[0019] Furthermore, the device also includes: a recording unit, configured to record the binding relationship between the command tables of different levels and the commands of a previous level in the process of hierarchical binding after the command tables of different levels are hierarchically bound with the multi-level commands in the order from the lowest level command to the highest level command; An updating unit is used to release the binding relationship between the command table of the corresponding level and the command of the previous level when the binding relationship changes, and use the updated command of the previous level as an index to bind the command table of the corresponding level to the updated command of the previous level, so as to update the binding relationship between the command table and the command in the multi-level command table.
[0020] Further, the multi-level command includes a main command and a sub-command, the main command is a non-lowest level command, the sub-command is a lowest level command, and the multi-level command table includes a main command table and a sub-command table; Accordingly, the disassembly unit is specifically used to disassemble the functions of the embedded software system into main commands and secondary commands; The construction unit is specifically used to construct a secondary command table and a main command table respectively, wherein the secondary command table is constructed according to the secondary commands and the callback functions corresponding to the secondary commands, and the main command table is constructed according to the main commands; The binding unit is specifically used to bind the secondary command table to the primary command using the primary command as an index to obtain a multi-level command table.
[0021] Furthermore, the lowest level command is stored through a first setting structure, which at least includes a lowest level command field, a callback function pointer variable, and a reserved field; the lowest level command table is stored through a second setting structure, which at least includes a pointer variable of the lowest level command, a command quantity field, a command description field, and a reserved field; the non-lowest level command table is stored through a third setting structure, which at least includes a pointer variable of the non-lowest level command, a command quantity field, a command description field, and a reserved field.
[0022] Furthermore, the query unit is specifically used to: According to the multi-level command combination, a hierarchical query is performed in a pre-established multi-level command table in the order of the highest level command to the lowest level command; During the hierarchical query process, the current level command is used as an index to query the command table of the current level to obtain the command table of the next level, until the lowest level command is used to query the command table of the lowest level to obtain the callback function corresponding to the lowest level command.
[0023] Further, the multi-level command combination includes a main command and a sub-command, the main command is a non-lowest level command, the sub-command is a lowest level command, and the multi-level command table includes a main command table and a sub-command table; Accordingly, the parsing unit is specifically used to parse the communication frame when receiving the communication frame sent by the host computer to obtain the main command and the secondary command; The query unit is further specifically used for: Using the main command as an index to search the main command table, to obtain a secondary command table; According to the sub-command, the sub-command table is searched to obtain the callback function corresponding to the sub-command.
[0024] According to a fourth aspect, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method according to the first aspect when executing the computer program.
[0025] According to a fifth aspect, a readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0026] By means of the above technical scheme, the present application provides a data communication method, device, system, equipment and medium for embedded software. Compared with the existing technology of realizing the data communication method of embedded software by repeatedly developing the same function through the lower computer software, the present application parses the communication frame when receiving the communication frame sent by the upper computer to obtain a multi-level command combination, and the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure; according to the multi-level command combination, a hierarchical query is performed in a pre-established multi-level command table to obtain a callback function corresponding to the lowest level command, and the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure, and non-lowest level commands are used as indexes for querying the command table of the next level in the command table of the current level, and the lowest level command is used to query the callback function; a preset pointer pointing to the communication frame is passed to the callback function as a parameter, so that the callback function determines the lower computer call function through the preset pointer, and initiates data communication with the upper computer according to the lower computer call function. The whole process uses a multi-level command table to standardize the storage of commands at different levels, so that the commands do not depend on the specific chip, but on the functions implemented by the chip, avoiding repeated development operations for the same function. In this way, the lower-level computer software can transfer function development to the multi-level command table, and accurately locate the callback functions of different functions through multi-level command combinations, making the lower-level computer software more flexible and reducing the complexity of software maintenance.
[0027] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 It is a flowchart of a data communication method of embedded software in an embodiment of the present application; Figure 2 yes Figure 1 A schematic flow chart of a specific implementation of step 101; Figure 3 is a flow chart of a data communication method of embedded software in another embodiment of the present application; Figure 4 is a flow chart of a data communication method of embedded software in another embodiment of the present application; Figure 5 yes Figure 1 A schematic flow chart of a specific implementation of step 102; Figure 6 is a flow chart of a data communication method of embedded software in another embodiment of the present application; Figure 7 is a schematic diagram of a command hierarchy structure in an embodiment of the present application; Figure 8 is a schematic diagram of a process of using a command hierarchy structure to perform data communication in an embodiment of the present application; Fig. 9 It is a structural diagram of a data communication system of embedded software in one embodiment of the present application; Fig.10 is a schematic diagram of the structure of a data communication device of an embedded software in an embodiment of the present application; Fig.11 It is a schematic diagram of the device structure of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] Now the content of the present invention will be discussed with reference to several exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and thus implement the content of the present invention, rather than implying any limitation on the scope of the present invention.
[0030] As used herein, the term "including" and variations thereof are to be interpreted as open-ended terms meaning "including but not limited to." The term "based on" is to be interpreted as "based, at least in part, on." The terms "one embodiment" and "an embodiment" are to be interpreted as "at least one embodiment." The term "another embodiment" is to be interpreted as "at least one other embodiment."
[0031] In the related technology, the chip serves as the basis for the operation of the lower-level computer software, providing basic computing, storage capabilities and various interface resources. Considering that different chips use different architectures and instruction sets, it is usually necessary to design the lower-level computer software separately to achieve different data communications. However, in the complex technical environment of chip production and quality inspection systems, although there are certain functional differences among multiple chips in the same series, most of the functions are the same, which means that the lower-level computer software needs to perform repeated development operations for the same functions, which not only wastes development resources but also increases the complexity of software maintenance.
[0032] In order to solve this problem, this embodiment provides a data communication method for embedded software, such as Figure 1 As shown, the following steps are included: 101. When a communication frame sent by a host computer is received, the communication frame is parsed to obtain a multi-level command combination.
[0033] In embedded software design, the lower computer and the upper computer are connected through a communication interface, and the same communication protocol needs to be used for communication frame transmission. The communication frame is used as a carrier for the upper computer to transmit information to the lower computer, so that the upper computer can accurately send control instructions, configuration parameters, etc. to the lower computer to achieve control of the lower computer. In order to meet the control requirements of complex system functions, a multi-level command combination can be constructed in the upper computer, and the multi-level command combination can be encapsulated into a communication frame according to the set communication protocol, and the communication frame is sent to the lower computer. Correspondingly, when the lower computer receives the communication frame sent by the upper computer, it parses the communication frame according to the set communication protocol to obtain a multi-level command combination.
[0034] In this embodiment, the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure. In the case where the command hierarchy structure is three levels, the multi-level command structure includes first-level commands, second-level commands, and third-level commands. In this case, the multi-level command combination needs to select one command from the first-level commands, one command from the second-level commands, and one command from the third-level commands for combination. For example, the first-level commands include command A and command B; the second level includes command C, command D, command E, and command F; the third level includes command G, command H, command I, command J, and command K. The corresponding multi-level command combination can be a combination of command A, command E, and command H, or a combination of command B, command F, and command J, which is not limited here.
[0035] Generally speaking, the command hierarchy structure is divided into multiple levels according to system functions and control logic. Each level has corresponding functional control. Under such a hierarchical structure, commands at different levels have clear functional directions and can be independently modified and expanded according to needs, which facilitates software system maintenance.
[0036] 102. Perform a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command; Among them, the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure. Non-lowest level commands are used as indexes to query the command table of the next level in the command table of the current level. The lowest level command is used to query the callback function.
[0037] In this embodiment, each non-lowest level command in the multi-level command table has a repeated index function, and the command table of the next level can be queried accordingly. In the case of the lowest level command, the lowest level command is already the end of the command refinement. By reading the lowest level command, a specific functional operation can be executed through the callback function corresponding to the lowest level command.
[0038] Specifically, each level in the pre-established multi-level command table contains a set of related commands, which have certain similarities or correlations in function. For example, in an industrial automation control system, there are high-level commands such as device control, parameter setting, and status monitoring, and each high-level command will be further subdivided into more specific low-level commands. The non-lowest level command acts as an index to query the command table of the next level. Through this indexing mechanism, the next level command table associated with different level commands can be quickly located. For example, the next level command table can be queried through the high-level command "device control" as an index, and the corresponding next level command table contains commands such as "start device", "stop device", and "device reset". The lowest level command is used to query the callback function. The callback function can be a pre-written piece of code used to perform a specific operation or task. According to the lowest level command, the corresponding callback function can be queried, and the corresponding function is completed by executing the callback function. For example, the lowest level command in the multi-level commands of temperature monitoring is "read current temperature value". The callback function corresponding to this command will accurately execute the operation of reading data from the temperature sensor, processing and returning the data in the format required by the system.
[0039] 103. Pass a preset pointer pointing to the communication frame as a parameter to the callback function, so that the callback function determines the lower computer calling function through the preset pointer and initiates data communication according to the lower computer calling function.
[0040] In the process of data communication, the preset pointer pointing to the communication frame is a variable used to store the address of the communication frame in the memory. In the computer memory, when the communication frame is received or sent, the system will allocate a continuous storage space for it, and the pointer pointing to the communication frame is used as an address label to store the starting address of the memory area where the communication frame is located. Through the preset pointer, the callback function can read the field content of the corresponding memory area in the communication frame, obtain the parameters used to call the lower computer function, determine the lower computer call function based on these parameters, and initiate data communication with the upper computer through the lower computer call function. For example, the callback function is used to call the function that reads sensor data, and the corresponding lower computer call function is used to read sensor data. At this time, the sensor hardware interface can be accessed through the lower computer call function to obtain the sensor's measurement value and realize data communication.
[0041] It is understandable that the preset pointer pointing to the communication frame can use different pointer types, which can be an array pointer or a structure pointer. When the communication frame is regarded as a continuous sequence of bytes without complex internal structure division, it is more appropriate to use an array pointer. For example, in a simple serial communication protocol, data is transmitted in the form of a fixed-length byte array. At this time, an array pointer can be used to easily access each byte in sequence to perform operations such as reading and verifying data. If the communication frame has a clear structure and contains different types of data members, for example, a data packet in a network communication may contain a header, a data part, a checksum, etc., using a structure to represent the structure of the communication frame will be clearer, and each member can be easily accessed and processed accordingly, which enhances the readability and maintainability of the code.
[0042] Considering that the callback function is pre-defined and is called when a specific condition is met, different callback functions accept different types of pointer parameters. In order to correctly call the callback function and let it process the communication frame, it is necessary to convert the pointer structure pointing to the communication frame into the pointer type corresponding to the callback function. For example, a callback function is defined to accept a structure pointer type parameter to process the communication frame, but the pointer type obtained to the communication frame is an array pointer. At this time, appropriate conversion is required to ensure that the callback function can correctly access and process the data of the communication frame.
[0043] The data communication method for embedded software provided in the embodiment of the present application is compared with the data communication method for embedded software realized by repeated development of the same function by lower computer software in the prior art. When receiving a communication frame sent by an upper computer, the present application parses the communication frame to obtain a multi-level command combination, wherein the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure; a hierarchical query is performed in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest level command, wherein the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure, and non-lowest level commands are used as indexes for querying the command table of the next level in the command table of the current level, and the lowest level command is used for querying the callback function; a preset pointer pointing to the communication frame is passed as a parameter to the callback function, so that the callback function determines the lower computer calling function through the preset pointer, and initiates data communication with the upper computer according to the lower computer calling function. The whole process uses a multi-level command table to standardize the storage of commands at different levels, so that the commands do not depend on the specific chip, but on the functions implemented by the chip, avoiding repeated development operations for the same function. In this way, the lower-level computer software can transfer function development to the multi-level command table, and accurately locate the callback functions of different functions through multi-level command combinations, making the lower-level computer software more flexible and reducing the complexity of software maintenance.
[0044] Considering the logical relationship between commands in the multi-level command combination, specifically in the process of parsing the data frame, such as Figure 2 As shown, step 101 includes the following steps: 201. Determine a field area of a multi-level command in the communication frame according to a frame structure specified by a protocol.
[0045] 202. Decode the command fields of each level in the communication frame according to the field area of the multi-level command to obtain the multi-level command and the logical relationship between the multi-level commands.
[0046] 203. Process the multi-level commands using the logical relationship between the multi-level commands to obtain a multi-level command combination.
[0047] In actual application scenarios, different communication protocols have different communication frame structures. Usually, the frame structure specified by the protocol will include frame header, command, data check and frame tail. After receiving the communication frame, the frame header is used to mark the beginning of a communication frame, and the frame tail marks the end of the communication frame. By identifying the frame header and frame tail, the scope of the entire communication frame can be determined.
[0048] Correspondingly, the position identifier related to the multi-level command may be a specific field name, a field position offset, or an area starting at a fixed position after the frame header. The field area of the multi-level command can be determined in the communication frame through the position identifier. For example, the protocol stipulates that the multi-level command field starts at the 5th byte after the frame header and has a length of 10 bytes. After further determining the field area of the multi-level command, the separation method of each level of command in the command field is analyzed according to the protocol regulations. Here, the multi-level command combination exists in the command field in a specific separation method, for example, different levels of commands are divided by a fixed number of bytes or data types.
[0049] Specifically, in the process of decoding the command fields of each level in the communication frame according to the field area of the multi-level command, the field identification bit of the first-level command in the communication frame can be identified according to the field area of the multi-level command, so as to decode the command field of the first level in the communication frame through the field identification bit of the first-level command to obtain the first-level command; on the basis of the first-level command, the command field identification bit of the next level in the communication frame is determined, so as to decode the command field of the next level in the communication frame through the command field identification bit of the next level to obtain the next-level command; on the basis of the next-level command, the command field of each level is decoded in turn until the command field of the lowest level, and the association between the commands of each level is recorded in the process of decoding the command field of each level to obtain the multi-level command and the logical relationship between the multi-level commands.
[0050] In this embodiment, since the protocol specifies the field area of each level command, we can start from the highest level or lowest level command, extract the corresponding bytes and convert them into corresponding command values according to the field area and encoding method. For example, in the field area of the multi-level command, the decoding result of the first level command parsed from the first byte is 3, and the command value represents the "read data" operation. Then, based on the decoding result of the first level command, the decoding process of the next level command is entered. This process needs to determine the specific meaning or parsing method of the second level command according to the specific value of the first level command. For example, if the first level command is "set parameters", then the second level command may be a specific parameter value, and the parameter value is further parsed as 1024 according to the specified two-byte integer. Repeat the decoding process of the above-mentioned level commands until the decoding process of the lowest level command, and a multi-level command can be obtained.
[0051] At the same time, considering that there is a logical association between multi-level commands, the logical relationship between the multi-level commands can be determined during the decoding process of the multi-level commands. The logical relationship here may include but is not limited to a sequential relationship, a conditional relationship, an inclusion relationship, etc. For example, some commands may be a parent-child relationship, that is, the first-level command is the parent command, and the second-level command is a specific parameter setting or detailed operation of the parent command; some commands may be a sequential relationship, that is, the first-level command is executed first, and then the second-level command is executed according to its result, etc.
[0052] Finally, by using the logical relationship between the multi-level commands, the rules for combining the multi-level commands can be determined, and the commands of each level can be combined according to the rules to obtain the multi-level command combination. For example, the commands of each level can be combined in sequence according to the hierarchical order, or the commands of each level can be selected according to specific conditions for combination.
[0053] In actual application scenarios, considering that there is a certain correlation between multi-level commands and the command tables of the levels, in order to facilitate the query of the hierarchical commands, further, such as Figure 3 As shown, before step 102, the method further includes: 301. Decompose the functions of the embedded software system into multi-level commands.
[0054] 302. Construct command tables of different levels according to the multi-level commands.
[0055] 303. Hierarchically bind the command tables of different levels with the multi-level commands in order from the lowest level command to the highest level command.
[0056] It can be understood that the embedded software system has multiple relatively independent functional modules, and there is an interactive relationship between different functional modules. According to the demand analysis, the functions of the embedded software system can be divided into multiple levels of commands. Specifically, the functions of the embedded software system can be disassembled according to the task priority in the system, so that the commands corresponding to the tasks with higher priority are placed at a higher level to ensure priority access to system resources and execution time, and correspondingly, the commands corresponding to the tasks with lower priority are placed at a lower level. The functions of the embedded software system can also be disassembled according to the data flow in the system, so that the commands with the front data flow are placed at a lower level, and the commands with the back data flow are placed at a higher level. For example, the data acquisition command is at a lower level and is responsible for obtaining raw data from the sensor. The data processing command is at an intermediate level and is responsible for analyzing, calculating and converting the collected data. The data transmission command is at a higher level and is responsible for transmitting the processed data to the specified destination.
[0057] In this embodiment, command tables of different levels are command tables constructed according to commands of corresponding levels. Specifically, the command table of the lowest level is constructed according to the lowest level command and the callback function corresponding to the lowest level command, and the command table of the non-lowest level is constructed according to the non-lowest level command. In an embedded system, when a command is received, it needs to be parsed and executed according to the command level and specific content. The command table bound to the level can provide a clear search path and rules for the command parser. The corresponding command parser can first determine the level to which the command belongs according to the level name, and then search for the specific command in the command table of the level, so as to quickly and accurately find the corresponding execution function or operation process, and realize the efficient execution of the command.
[0058] It should be noted that the first-level command table in the multi-level command table is usually set with reserved fields, that is, if there are many empty items in the first-level command table, then the corresponding commands in the first-level command table do not exist in the command table of the next level. In other words, the first-level command table can add current-level commands or delete current-level commands accordingly. This can save a lot of memory space. After constructing the command table of the current level, it can be directly bound to the command of the previous level or add a command to the previous level for binding. If the command table of the current level is not bound to the command of the previous level, it means that the command table cannot be used in the data communication process.
[0059] Specifically, in the process of hierarchical binding, the command table of the current level is bound to the command of the previous level using the command of the previous level as an index, until the highest level command. That is to say, the command table of the current level can be obtained by querying the command of the previous level as an index. For example, the command table of the third level can be queried by the command of the second level as an index, and the command table of the second level can be queried by the command of the first level as an index. By binding the hierarchical command with the command table of the level, the hierarchical command can be used as the index command table of the next level, so that there is a clear hierarchical relationship between the commands of different levels in the system, which is more convenient and quick for developers to understand the system architecture and to maintain and expand the system in the future. When the system receives a command, the index relationship of the hierarchical binding can be used to quickly locate the command table of the corresponding level, and then find the specific command and its execution logic. Just like in a multi-layer file directory, the lowest level command and the callback function corresponding to the lowest level command can be accurately located by indexing step by step, avoiding blind searching in a large number of commands and improving the response speed of the system.
[0060] It should be noted that the above-mentioned hierarchical binding allows the lower-level command table to be bound to the upper-level command, for example, the second-level command table is bound to the upper-level command, but considering that different usage scenarios may require the system to organize and call commands in different ways, the binding relationship between the command table and the command is changeable. For example, in the daily production mode, the command table is bound to the hierarchical command of "routine production operation"; in the equipment maintenance mode, the same command table needs to be switched to bind to the hierarchical command of "equipment maintenance operation" so that maintenance personnel can perform related operations more conveniently, improving the flexibility and adaptability of the system. Specifically, in the process of hierarchical binding, the binding relationship between command tables of different levels and commands of the previous level is recorded; when the binding relationship changes, the binding relationship between the command table of the corresponding level and the command of the previous level is released, and the command table of the corresponding level is bound to the updated command of the previous level using the updated command of the previous level as an index to update the binding relationship between the command table and the command in the multi-level command table. Here, the change of binding relationship can be realized by combining multi-level commands. For example, the multi-level command table includes two levels. The command table B1 of the second level is bound to the command a of the first level. The updated binding relationship requires the command table B2 of the second level to be bound to the command a of the first level. At this time, it is necessary to control the command table B1 of the second level to release the binding relationship with the command a of the first level through multi-level commands, and then control the command table B2 of the second level to bind to the command a of the first level to realize the change of binding relationship.
[0061] In actual application scenarios, multi-level commands include main commands and sub-commands. The main command is a non-lowest level command, and the sub-command is a lowest level command. The multi-level command table includes the main command table and the sub-command table. Correspondingly, Figure 4 As shown, the above steps 301 to 303 can be implemented by the following steps: 401. Decompose the functions of the embedded software system into primary commands and secondary commands.
[0062] 402. Construct a secondary command table and a primary command table respectively.
[0063] 403. Use the main command as an index to bind the secondary command table to the main command to obtain a multi-level command table.
[0064] In this embodiment, the secondary command table is constructed according to the secondary command and the callback function corresponding to the secondary command, and the main command table is constructed according to the main command. Here, the main command is the first-level command, and the secondary command table can be bound to the main command as an index to obtain a multi-level command table.
[0065] In actual application scenarios, multi-level command combinations need to go through hierarchical queries to obtain callback functions. Specifically, Figure 5 As shown, step 102 includes the following steps: 501. According to the multi-level command combination, perform a hierarchical query in a pre-established multi-level command table in the order from the highest-level command to the lowest-level command.
[0066] 502. During the hierarchical query process, the current-level command is used as an index to query the command table of the current level to obtain the command table of the next level, until the lowest-level command is used to query the command table of the lowest level to obtain the callback function corresponding to the lowest-level command.
[0067] In this embodiment, the multi-level command combination has multiple levels of commands. For non-lowest level commands, each level command can query the command table of each level layer by layer through the pre-established multi-level command table until the callback function corresponding to the lowest level command is queried in the lowest level command table.
[0068] For example, a multi-level command combination is a three-level command of "home appliance control-air conditioning control-temperature adjustment". In the pre-established multi-level command table, each level has a corresponding command table, which records the commands of this level and the binding relationship with the command table of the next level. In order, start with the command table of the highest-level command "home appliance control", use "home appliance control" as an index to query the command table of "air conditioning control" in the command table of "home appliance control", and then use "air conditioning control" as an index to query the command table of "temperature adjustment" in the command table of "air conditioning control". Since "temperature adjustment" is the lowest-level command, finally, according to "temperature adjustment", the callback function corresponding to "temperature adjustment" is queried in the command table of "temperature adjustment".
[0069] In actual application scenarios, a multi-level command combination includes a main command and a secondary command, the main command is a non-lowest level command, the secondary command is a lowest level command, and the multi-level command table includes a main command table and a secondary command table; accordingly, Figure 6 As shown, the above steps 101 to 103 can be implemented by the following steps: 601. When a communication frame sent by a host computer is received, the communication frame is parsed to obtain a main command and a secondary command.
[0070] 602. Use the main command as an index to search in the main command table to obtain a secondary command table.
[0071] 603. Search the sub-command table according to the sub-command to obtain a callback function corresponding to the sub-command.
[0072] In this embodiment, after using the multi-level command table for data communication, the main command table can directly use the main command as an index to query the secondary command table. The time performance is , while the performance of the secondary command table using traversal query time is However, if the multi-level command table is not used for data communication, all the main commands and sub-commands will be placed in the same command table, and the time performance of the corresponding query will change to ,in, The number of main commands. The number of sub-commands.
[0073] In actual application scenarios, the lowest level command is stored through the first setting structure, which at least includes the lowest level command field, callback function pointer variable, and reserved field; the lowest level command table is stored through the second setting structure, which at least includes the pointer variable of the lowest level command, the command quantity field, the command description field, and reserved field; the non-lowest level command table is stored through the third setting structure, which at least includes the pointer variable of the non-lowest level command, the command quantity field, the command description field, and reserved field. Take the multi-level command combination including the main command and the secondary command as an example.
[0074] See Figure 7 The command hierarchy in As a sub-command structure, it contains 4 fields: a byte of sub-command , two reserved fields and Each occupies one byte and one callback function pointer , the pointer type of the callback function is . As a structure of the secondary command table, it contains 4 fields: a pointer variable of the secondary command , a field describing the number of commands , a sub-command description field and a reserved field . As the structure of the main command, it contains a pointer variable of the main command Usually, the pointer variable will be assigned as the first address of a secondary command array, and the secondary command table can be retrieved by using the main command as an index.
[0075] Accordingly, the process of using a multi-level command structure for data communication is as follows Figure 8 As shown in the figure, when the system receives the communication frame sent by the host computer, it parses the communication frame to obtain a multi-level command combination including the main command and subcommands , pre-built with main command table and subcommand table , the main command As an index in the main command table The query points to the secondary command table A pointer to the subcommand The secondary command table ,get Corresponding , according to the next command Query the command table Get the fields corresponding to the sub-command sub_cmd , remove the callback function .
[0076] Further, based on the same inventive concept, the present application embodiment also provides a data communication system of embedded software, such as Fig. 9 As shown, it includes: application layer, system layer, adaptation layer and resource library; The application layer is used to construct a command table of the lowest level, and hierarchically bind the command table of the lowest level by exposing a pointer, so that command tables of multiple levels are coupled to obtain a multi-level command table; The system layer calls the resource library to store the multi-level command table in the resource library; When receiving a communication frame sent by the host computer, the system layer calls the adaptation layer to parse the communication frame, and calls the resource library to perform a hierarchical query in the multi-level command table according to the multi-level command combination obtained by the parsing, and obtains the callback function corresponding to the lowest level command; The system layer initiates data communication with the host computer according to the callback function.
[0077] As a coupling scenario, after the application layer constructs the lowest-level command table, the application layer will expose the lowest-level command table pointer, so that the system layer can bind the lowest-level command table to the upper-level command through the exposed command table pointer, and perform hierarchical binding on the command table, so that command tables of multiple levels are coupled to obtain a multi-level command table.
[0078] As another coupling scenario, after the application layer constructs the lowest-level command table, the system layer can expose the interface pointer of the command table of the upper level, so that the application layer binds the lowest-level command table to the upper-level command through the exposed interface pointer, and performs hierarchical binding on the command table, so that the command tables of multiple levels are coupled to obtain a multi-level command table.
[0079] In actual application scenarios, the system layer, as the operating environment and basic service of embedded software, can control the adaptation layer and resource library. Specifically, the adaptation layer is between the system layer and the application layer. The system layer can adapt the control instructions and requests of the application layer to the interfaces and services of the system layer by calling the adaptation layer, and also feed back the status and data of the system layer to the application layer. For example, in an intelligent device control system, the control adaptation layer will convert the control commands issued by the user through the mobile phone application into instructions that the device can understand, and feed back the operating status information of the device to the mobile phone application so that the user can understand the current situation of the device. The resource library is used to store multi-level command tables. The hierarchical commands in the command table of each level are bound by the command table of the next level, so that the multi-level command table has an index mechanism and a clear storage structure. In this way, the system layer can quickly locate specific commands in the multi-level command table by calling the resource library, greatly improving the efficiency of system operation.
[0080] Further, based on the same inventive concept, the present application embodiment also provides a data communication device of embedded software, such as Fig.10 As shown, the device includes: a parsing unit 71, a query unit 72 and a communication unit 73.
[0081] The parsing unit 71 is used for parsing the communication frame sent by the host computer to obtain a multi-level command combination when receiving the communication frame sent by the host computer, wherein the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure; A query unit 72, configured to perform a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command, wherein the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure, and non-lowest-level commands are used as indexes to query a command table of a next level in a command table of a current level, and the lowest-level command is used to query the callback function; The communication unit 73 is used to pass the preset pointer pointing to the communication frame as a parameter to the callback function, so that the callback function determines the lower computer calling function through the preset pointer and initiates data communication according to the lower computer calling function.
[0082] The data communication device for embedded software provided in the embodiment of the present application is compared with the data communication method of the embedded software realized by repeated development of the same function by the lower computer software in the prior art. When receiving the communication frame sent by the upper computer, the present application parses the communication frame to obtain a multi-level command combination, wherein the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure; performs a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest level command, wherein the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure, and non-lowest level commands are used as indexes for querying the command table of the next level in the command table of the current level, and the lowest level command is used for querying the callback function; a preset pointer pointing to the communication frame is passed to the callback function as a parameter, so that the callback function determines the lower computer calling function through the preset pointer, and initiates data communication with the upper computer according to the lower computer calling function. The whole process uses a multi-level command table to standardize the storage of commands at different levels, so that the commands do not depend on the specific chip, but on the functions implemented by the chip, avoiding repeated development operations for the same function. In this way, the lower-level computer software can transfer function development to the multi-level command table, and accurately locate the callback functions of different functions through multi-level command combinations, making the lower-level computer software more flexible and reducing the complexity of software maintenance.
[0083] In actual application scenarios, the parsing unit is specifically used for: Determining the field area of the multi-level command in the communication frame according to the frame structure specified by the protocol; Decoding the command fields of each level in the communication frame according to the field area of the multi-level command to obtain the multi-level command and the logical relationship between the multi-level commands; The multi-level commands are processed using the logical relationship between the multi-level commands to obtain a multi-level command combination.
[0084] In actual application scenarios, the parsing unit is further used to: Identifying a field identification bit of a first-level command in a communication frame according to the field area of the multi-level command, so as to decode a first-level command field in the communication frame through the field identification bit of the first-level command to obtain a first-level command; Based on the first-level command, determine a command field identification bit of a next-level in the communication frame, so as to decode the command field of the next-level in the communication frame through the command field identification bit of the next-level to obtain a next-level command; Based on the next level of commands, the command fields of each level are decoded in turn until the command field of the lowest level. In the process of decoding the command fields of each level, the associations between the commands of each level are recorded to obtain multi-level commands and the logical relationships between the multi-level commands.
[0085] In an actual application scenario, the device further includes: A disassembling unit, configured to disassemble the functions of the embedded software system into multi-level commands before performing a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command; A construction unit, configured to construct command tables of different levels according to the multi-level commands, wherein the command table of the lowest level is constructed according to the lowest level command and the callback function corresponding to the lowest level command, and the command table of the non-lowest level is constructed according to the non-lowest level command; A binding unit is used to hierarchically bind the command tables of different levels with the multi-level commands in the order from the lowest level command to the highest level command to obtain a multi-level command table. During the hierarchical binding process, the command table of the current level is bound to the command of the previous level using the command of the previous level as an index until the highest level command is reached.
[0086] In an actual application scenario, the device further includes: a recording unit, configured to record the binding relationship between the command tables of different levels and the commands of a previous level in the process of hierarchical binding after the command tables of different levels are hierarchically bound with the multi-level commands in the order from the lowest level command to the highest level command; An updating unit is used to release the binding relationship between the command table of the corresponding level and the command of the previous level when the binding relationship changes, and use the updated command of the previous level as an index to bind the command table of the corresponding level to the updated command of the previous level, so as to update the binding relationship between the command table and the command in the multi-level command table.
[0087] In an actual application scenario, the multi-level command includes a main command and a secondary command, the main command is a non-lowest level command, the secondary command is a lowest level command, and the multi-level command table includes a main command table and a secondary command table; Accordingly, the disassembly unit is specifically used to disassemble the functions of the embedded software system into main commands and secondary commands; The construction unit is specifically used to construct a secondary command table and a main command table respectively, wherein the secondary command table is constructed according to the secondary commands and the callback functions corresponding to the secondary commands, and the main command table is constructed according to the main commands; The binding unit is specifically used to bind the secondary command table to the primary command using the primary command as an index to obtain a multi-level command table.
[0088] In actual application scenarios, the lowest-level command is stored through a first setting structure, which includes at least a lowest-level command field, a callback function pointer variable, and a reserved field; the lowest-level command table is stored through a second setting structure, which includes at least a pointer variable of the lowest-level command, a command quantity field, a command description field, and a reserved field; the non-lowest-level command table is stored through a third setting structure, which includes at least a pointer variable of the non-lowest-level command, a command quantity field, a command description field, and a reserved field.
[0089] In an actual application scenario, the query unit is specifically used to: According to the multi-level command combination, a hierarchical query is performed in a pre-established multi-level command table in the order of the highest level command to the lowest level command; During the hierarchical query process, the current level command is used as an index to query the command table of the current level to obtain the command table of the next level, until the lowest level command is used to query the command table of the lowest level to obtain the callback function corresponding to the lowest level command.
[0090] In an actual application scenario, the multi-level command combination includes a main command and a secondary command, the main command is a non-lowest level command, the secondary command is a lowest level command, and the multi-level command table includes a main command table and a secondary command table; Accordingly, the parsing unit is specifically used to parse the communication frame when receiving the communication frame sent by the host computer to obtain the main command and the secondary command; The query unit is further specifically used for: Using the main command as an index to search the main command table, to obtain a secondary command table; According to the sub-command, the sub-command table is searched to obtain the callback function corresponding to the sub-command.
[0091] It should be noted that for other corresponding descriptions of the functional units involved in the data communication device of an embedded software provided in this embodiment, reference can be made to Figure 1-Figure 6 The corresponding description in will not be repeated here.
[0092] Based on the above Figure 1-Figure 6 The method shown in the embodiment of the present application accordingly provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned Figure 1-Figure 6 The data communication method of the embedded software shown.
[0093] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0094] Based on the above Figure 1-Figure 6 The method shown, and Fig.10 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides a physical device of the data communication method of embedded software, which can be a computer, a smart phone, a tablet computer, a smart watch, a server, or a network device, etc. The physical device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1-Figure 6 The data communication method of the embedded software shown.
[0095] Optionally, the physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0096] In an exemplary embodiment, see Fig.11 The physical device includes a communication bus, a processor, a memory and a communication interface, and may also include an input / output interface and a display device, wherein each functional unit can communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the data communication method of the embedded software in the above embodiment.
[0097] Those skilled in the art will appreciate that the physical device structure of data communication of an embedded software provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0098] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the physical device hardware and software resources for data communication of the above-mentioned embedded software, and supports the operation of information processing programs and other software and / or programs. The network communication module is used to realize communication between the components inside the storage medium, and communication with other hardware and software in the information processing physical device.
[0099] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. By applying the technical solution of the present application, compared with the current existing methods, the present application uses a multi-level command table to standardize the storage of commands at different levels, so that the command does not depend on the specific chip, but depends on the function implemented by the chip, avoiding repeated development operations for the same function, so that the lower computer software can transfer function development to the multi-level command table, and accurately locate the callback functions of different functions through multi-level command combinations, so that the lower computer software has higher flexibility and reduces the complexity of software maintenance.
[0100] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0101] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.
Claims
1. A data communication method for embedded software, characterized in that: include: When receiving a communication frame sent by the host computer, parsing the communication frame to obtain a multi-level command combination, wherein the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure; Performing a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command, wherein the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure, and non-lowest-level commands are used as indexes to query a command table of a next level in a command table of a current level, and the lowest-level command is used to query the callback function; The preset pointer pointing to the communication frame is passed as a parameter to the callback function, so that the callback function determines the lower computer calling function through the preset pointer and initiates data communication according to the lower computer calling function.
2. The method according to claim 1, characterized in that The parsing of the communication frame to obtain a multi-level command combination includes: Determining the field area of the multi-level command in the communication frame according to the frame structure specified by the protocol; Decoding the command fields of each level in the communication frame according to the field area of the multi-level command to obtain the multi-level command and the logical relationship between the multi-level commands; The multi-level commands are processed using the logical relationship between the multi-level commands to obtain a multi-level command combination.
3. The method according to claim 2, characterized in that The step of decoding the command fields of each level in the communication frame according to the field area of the multi-level command to obtain the multi-level command and the logical relationship between the multi-level commands includes: Identifying a field identification bit of a first-level command in a communication frame according to the field area of the multi-level command, so as to decode a first-level command field in the communication frame through the field identification bit of the first-level command to obtain a first-level command; Based on the first-level command, determine a command field identification bit of a next-level in the communication frame, so as to decode the command field of the next-level in the communication frame through the command field identification bit of the next-level to obtain a next-level command; Based on the next level of commands, the command fields of each level are decoded in turn until the command field of the lowest level. In the process of decoding the command fields of each level, the associations between the commands of each level are recorded to obtain multi-level commands and the logical relationships between the multi-level commands.
4. The method according to claim 1, characterized in that: Before performing hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command, the method further includes: Decompose the functions of embedded software systems into multi-level commands; Constructing command tables of different levels according to the multi-level commands, wherein the lowest level command table is constructed according to the lowest level command and the callback function corresponding to the lowest level command, and the non-lowest level command table is constructed according to the non-lowest level command; The command tables of different levels are hierarchically bound with the multi-level commands in the order from the lowest level command to the highest level command to obtain a multi-level command table. During the hierarchical binding process, the command table of the current level is bound to the command of the previous level using the command of the previous level as an index until the highest level command is reached.
5. The method according to claim 4, characterized in that After hierarchically binding the command tables of different levels with the multi-level commands in the order from the lowest level command to the highest level command, the method further includes: In the process of hierarchical binding, the binding relationship between the command tables of different hierarchies and the commands of the previous hierarchical level is recorded; When the binding relationship changes, the binding relationship between the command table of the corresponding level and the command of the previous level is released, and the command table of the corresponding level is bound to the updated command of the previous level using the updated command of the previous level as an index to update the binding relationship between the command table and the command in the multi-level command table.
6. The method according to claim 4, characterized in that The multi-level command includes a main command and a sub-command, the main command is a non-lowest level command, the sub-command is a lowest level command, and the multi-level command table includes a main command table and a sub-command table; Accordingly, the functions of the embedded software system are decomposed into primary commands and secondary commands; Constructing a secondary command table and a main command table respectively, wherein the secondary command table is constructed according to the secondary command and the callback function corresponding to the secondary command, and the main command table is constructed according to the main command; The secondary command table is bound to the primary command using the primary command as an index to obtain a multi-level command table.
7. The method according to claim 4, characterized in that The lowest level command is stored through a first setting structure, which includes at least a lowest level command field, a callback function pointer variable, and a reserved field; the lowest level command table is stored through a second setting structure, which includes at least a pointer variable of the lowest level command, a command quantity field, a command description field, and a reserved field; the non-lowest level command table is stored through a third setting structure, which includes at least a pointer variable of the non-lowest level command, a command quantity field, a command description field, and a reserved field.
8. The method according to any one of claims 1 to 7, characterized in that The step of performing a hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command includes: According to the multi-level command combination, a hierarchical query is performed in a pre-established multi-level command table in the order of the highest level command to the lowest level command; During the hierarchical query process, the current level command is used as an index to query the command table of the current level to obtain the command table of the next level, until the lowest level command is used to query the command table of the lowest level to obtain the callback function corresponding to the lowest level command.
9. The method according to claim 8, characterized in that The multi-level command combination includes a main command and a secondary command, the main command is a non-lowest level command, the secondary command is a lowest level command, and the multi-level command table includes a main command table and a secondary command table; Correspondingly, when receiving the communication frame sent by the host computer, the communication frame is parsed to obtain the main command and the secondary command; Using the main command as an index to search the main command table, to obtain a secondary command table; According to the sub-command, the sub-command table is searched to obtain the callback function corresponding to the sub-command.
10. A data communication system of embedded software, characterized in that: include: Application layer, system layer, adaptation layer and resource library; The application layer is used to construct a command table of the lowest level, and hierarchically bind the command table of the lowest level by exposing a pointer, so that command tables of multiple levels are coupled to obtain a multi-level command table; The system layer calls the resource library to store the multi-level command table in the resource library; When receiving a communication frame sent by the host computer, the system layer calls the adaptation layer to parse the communication frame, and calls the resource library to perform a hierarchical query in the multi-level command table according to the multi-level command combination obtained by the parsing, and obtains the callback function corresponding to the lowest level command; The system layer initiates data communication with the host computer according to the callback function.
11. A data communication device of embedded software, characterized in that: include: A parsing unit, configured to parse a communication frame sent by a host computer to obtain a multi-level command combination when receiving the communication frame, wherein the multi-level command combination is obtained by selecting a command combination at each level according to the command hierarchy structure; A query unit, used to perform hierarchical query in a pre-established multi-level command table according to the multi-level command combination to obtain a callback function corresponding to the lowest-level command, wherein the multi-level command table includes command tables of different levels constructed according to the command hierarchy structure, and non-lowest-level commands are used as indexes to query the command table of the next level in the command table of the current level, and the lowest-level command is used to query the callback function; The communication unit is used to pass the preset pointer pointing to the communication frame as a parameter to the callback function, so that the callback function determines the lower computer calling function through the preset pointer and initiates data communication according to the lower computer calling function.
12. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the data communication method of the embedded software in any one of claims 1 to 9 are implemented.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data communication method of the embedded software in any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
RS485 bus multi-device multi-protocol analysis method and RS485 bus multi-device multi-protocol analysis system
CN105491017A
Embedded software interface data frame analysis method based on configuration
CN117271323A
Intercommunication device and communication system based on multiple protocols
CN117596312A
Methods and apparatus for communicating between multiple levels of software components
US20070006199A1
Auto-completion and auto-correction of cryptic language commands with dynamic learning of syntax rules
US20190108216A1