Operation method of embedded code message routing architecture and architecture system
By introducing routing management modules and queue modules into the embedded software architecture, decoupling of the code module interface and data flow interface is achieved, which solves the problem of excessive coupling between modules and improves the flexibility and maintainability of the system.
Patent Information
- Application Number
- CN202510046053.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-01-29
- Filing Date
- 2025-01-10
- Publication Date
- 2025-07-29
AI Technical Summary
In the embedded software architecture, strong binding of code module interfaces and data flow interfaces leads to excessive coupling between modules, reduced system flexibility and maintainability, and increased modification costs.
It provides an embedded code message routing architecture, which uses routing memory application and sending functions to perform memory management and message routing, so as to decouple the code module interface and data flow interface.
It reduces strong dependencies between code modules, improves system flexibility and maintainability, and reduces modification and maintenance costs.
Smart Images

Figure CN120386645A_ABST
Abstract
Description
[0001] This application is based upon and claims the benefit of priority from Chinese patent application No. 2024101243004, filed on January 29, 2024. The entire contents of the above application are incorporated herein by reference. Technical Field
[0002] The present invention belongs to the field of embedded system software, and in particular relates to an operating method and an architecture system of an embedded code message routing architecture. Background Art
[0003] Code modules in embedded software architectures typically interact with data in one-to-one, one-to-many, many-to-many, and many-to-one scenarios. These scenarios, such as pipelines in Windows / Linux operating systems and PDU routing in Autosar systems, are used to manage data flow in business scenarios. However, this is often due to the rigid binding between code module interfaces and data flow interfaces. This excessive coupling between modules reduces system flexibility and maintainability. Changes to a module interface or data flow may require modifications to multiple modules, increasing system complexity and maintenance costs. Summary of the invention
[0004] The purpose of the present invention is to provide an operating method and an architecture system of an embedded code message routing architecture.
[0005] In order to solve the above technical problems, the present invention provides an operation method of an embedded code message routing architecture, comprising:
[0006] Setting at least one routing management module and at least one queue module;
[0007] The method for setting the routing management module includes configuring: a routing memory application function and a routing memory sending function;
[0008] The routing management module applies for memory from the memory management module through a routing memory application function to obtain memory space for routing message data; and
[0009] The routing management module also sends the message data to be sent to each queue module through the routing memory sending function.
[0010] In another aspect, the present invention further provides an embedded code message routing architecture system, comprising:
[0011] At least one routing management module and at least one queue module; wherein
[0012] The routing management module includes: a routing memory application function and a routing memory sending function;
[0013] The routing management module is configured to apply for memory from the memory management module through a routing memory application function to obtain a memory space for routing message data; and
[0014] The routing management module is further configured to send the message data to be sent to each queue module through a routing memory sending function.
[0015] In a third aspect, the present invention further provides a message routing system, including: the embedded code message routing architecture system as described above and at least one code module; wherein
[0016] The code module is adapted to send message data to the embedded code message routing architecture system or receive message data output from the embedded code message routing architecture system.
[0017] In a fourth aspect, the present invention further provides a readable storage medium storing readable instructions for an embedded system, which when executed by at least one embedded processor, causes the running method as described above to be executed.
[0018] In a fifth aspect, the present invention further provides an electronic device, characterized in that it includes: at least one memory and at least one processor, wherein the memory stores executable instructions, and when the executable instructions are executed by the embedded processor, the embedded processor executes the running method as described above
[0019] In a sixth aspect, the present invention further provides an embedded program product, including a program or instructions, wherein when the program or instructions are executed on an embedded system, the running method as described above is caused to be executed.
[0020] The beneficial effect of the present invention is that the running method of the embedded code message routing architecture of the present invention encapsulates the queue module, shared type messages, shared memory management module, etc. by providing a unified access interface, decouples the code module interface and the data flow interface, and reduces the strong dependency relationship between code modules during the development process.
[0021] Other features and advantages of the present invention will be described in the subsequent specification, and part of them will become obvious from the specification or be understood by implementing the present invention. The purpose and other advantages of the present invention are achieved and obtained by the structure specifically pointed out in the specification and the drawings.
[0022] To make the above objects, features and advantages of the present invention more obvious and understandable, the following specific preferred embodiments are given and described in detail in conjunction with the accompanying drawings as follows. Description of the Drawings
[0023] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0024] Figure 1 The flowchart shows the steps of the operation method of the embedded code message routing architecture involved in some embodiments;
[0025] Figure 2 The schematic diagram shows the structure of the embedded code message routing architecture system involved in some embodiments;
[0026] Figure 3 The schematic diagram shows the structure of the message routing system involved in some embodiments;
[0027] Figure 4 The schematic diagram shows the structure of the electronic device involved in some embodiments. Specific Embodiments
[0028] Now, the present invention will be further described in detail with reference to the drawings. These drawings are all simplified schematic diagrams, only illustrating the basic structure of the present invention in a schematic manner, so they only show the components related to the present invention.
[0029] For each code module in the embedded software architecture, data interaction is usually required in scenarios of 1-to-1, 1-to-many, many-to-many, and many-to-1. For example, pipes in the windows / linux operating system, PDU routing in the Autosar system, etc., are used to handle data flow management in business scenarios. However, there is a problem of strong binding between the code module interface and the data flow interface, and the coupling degree between modules is too high, resulting in reduced flexibility and maintainability of the system. Once a change occurs in a certain module interface or data flow, it may be necessary to modify multiple modules, increasing the complexity and maintenance cost of the system.
[0030] To solve the above technical problems, as Figures 1 to 4 shown, at least one embodiment provides a method for operating an embedded code message routing architecture, including: Step S01, setting at least one routing management module and at least one queue module; the method of setting the routing management module includes configuration: a routing memory application function and a routing memory sending function; Step S02, the routing management module applies for memory from the memory management module through the routing memory application function to obtain a memory space for routing message data; and Step S03, the routing management module also sends the message data to be sent to each queue module through the routing memory sending function.
[0031] Specifically, the routing management module provides a function for applying for routing memory and a function for routing message data. One routing management module is associated with one memory management module and multiple queue modules, and the routing management module supports fast (occupying more RAM) message distribution and slow message distribution.
[0032] The operating method of this embedded code message routing architecture encapsulates queue modules, shared type messages, shared memory management modules, etc. by providing a unified access interface, decouples the code module interface and the data flow interface, and reduces the strong dependency relationship between code modules during the development process.
[0033] In some embodiments, in addition to including a routing management module initialization function, the routing management module also stores routing management module initialization constant parameters, a routing memory application function, a routing memory sending function, etc.
[0034] In some embodiments, the method by which the routing management module applies for memory from the memory management module through the routing memory application function includes: determining the routing management module for routing according to the message data type to be sent; determining the corresponding memory pool of the memory management module bound to the routing management module according to the index value of the routing management module; and using the index value of the routing management module and the space size occupied by the message data to be sent as input parameters of the routing memory application function to apply for the memory space for routing of the routing management module from the corresponding memory pool.
[0035] In some embodiments, when the message data type is shared type message data, the corresponding routing management module will apply for the shared memory space for routing of the routing management module from the corresponding memory pool.
[0036] In some embodiments, the method by which the routing management module also sends the message data to be sent to each queue module through the routing memory sending function includes: determining each queue module bound to the routing management module according to the index value of the routing management module; and using the index value of the routing management module and the address of the message data to be sent as input parameters of the routing memory sending function to route the address pointer of the message data to be sent to each queue module.
[0037] In some embodiments, the routing management module is also initialized through the routing management module initialization function, including: using the index value of the routing management module and the address of the initialization structure corresponding to the initialization constant parameters as input parameters of the routing management module initialization function to obtain the routing management module initialization constant parameters; and initializing the corresponding routing management module according to the routing management module initialization constant parameters.
[0038] Specifically, examples of the initialization of the routing management module, the acquisition of routing memory, and the related functions of message routing are as follows:
[0039] / / The following code example initializes the routing management module. The input parameters of the routing management module initialization function include: the index value of the routing management module and the address of the initialization structure of the routing management module:
[0040]
[0041]
[0042]
[0043] / / The following code example acquires the memory space for routing, that is, the input parameters of the routing memory application function include: the index value of the routing management module and the size of the space occupied by the message data to be sent:
[0044]
[0045]
[0046]
[0047] / / The following code example sends a message through the routing management module, that is, the input parameters of the routing memory sending function include: the index value of the routing management module and the address of the message data to be sent:
[0048]
[0049]
[0050]
[0051]
[0052] Specifically, the operation method of the embedded code message routing architecture in some embodiments further includes: setting a shared memory management module for managing the shared memory space; the shared memory management module initialization function and the shared memory management module initialization constant parameters; using the address of the initialization structure of the shared memory management module as the input parameter of the shared memory management module initialization function to obtain the shared memory management module initialization constant parameters; the shared memory management module initialization constant parameters include: lock enable flag bit, reference count, memory address pointer for release regression, and share mode data format parameters; and initializing the shared memory management module according to the shared memory management module initialization constant parameters.
[0053] In some embodiments, the shared memory management module further includes: a static segment memory occupancy calculation result function, a count increment function, and a count decrement function; wherein the input parameters of the static segment memory occupancy calculation result function include: the initialization constant parameters of the shared memory management module, and the output parameter is the actual occupied space size of the message data; the input parameters of the count increment function include: the memory address pointer of the shared message data, and the output parameter is the count increment result; the input parameters of the count decrement function include: the memory address pointer of the shared message data and the callback function parameter, and the output parameter is the decrement result; wherein the callback function parameter includes: the processing result of the shared message data; when the message data passed into the shared memory management module is used, the count is incremented; after use, the count is decremented, and when the count is decremented to 0, the shared memory space occupied by the corresponding message data is returned to the memory pool by the memory management module.
[0054] Examples of obtaining the static segment memory occupancy, initializing the shared memory management module, incrementing the reference count, and decrementing the reference count to release space are as follows:
[0055] / / The following code example takes share_mem_ext_data as an example to describe the static segment memory occupancy. The input parameters include: the address of the initialization structure of the shared memory management module:
[0056]
[0057]
[0058] / / The following code example takes share_mem_ext_data as an example to describe the initialization of the shared memory management module. The parameters include: the address of the initialization structure of the shared memory management module:
[0059]
[0060]
[0061]
[0062]
[0063] / / The following code example takes share_mem_ext_data as an example to describe the increment of the reference count. The input parameters include: the memory address pointer of the shared message data:
[0064]
[0065]
[0066] / / The following code example takes share_mem_ext_data as an example to describe the reduction of reference count. The input parameters include: the memory address pointer of the shared message data and the processing result of the memory message data:
[0067]
[0068]
[0069]
[0070] / / The following code example takes share_mem_ext_data as an example to describe the function of reducing the count. The input parameters include: the memory address pointer of the shared message data and the processing result of the shared message data:
[0071]
[0072]
[0073]
[0074]
[0075]
[0076] In some embodiments, the queue module provides functions such as caching system messages, supporting configuration of the cache length, discarding new / old messages when the queue is full, message data types (ordinary memory / shared memory), and data consistency protection.
[0077] In some embodiments, the queue module includes: a queue module initialization function and queue module initialization constant parameters; the input parameters of the queue module initialization function include: the structure address of the queue module and the queue module initialization constant parameters, and the output parameter is whether the initialization is successful.
[0078] In some embodiments, the queue module further includes: a queue module static memory occupancy calculation sub-function and a message retrieval function; wherein the queue module initialization constant parameters include: queue module function customization parameters; the input parameter of the queue module static memory occupancy calculation sub-function includes: the queue module initialization constant parameters, and the output parameter is the calculation result of the queue module static segment memory occupancy; and the input parameters of the message retrieval function include: the structure address pointer of the queue module and the pointer to the address for saving the dequeued message, and the output parameter is whether the dequeue is successful; the message retrieval function obtains the fifo queue message type according to the structure address pointer of the queue module, and then performs a value-taking operation using the corresponding structure.
[0079] An example of describing the sub-function for calculating the static memory occupancy of the fifo queue module is as follows:
[0080] / / The following code example shows the process of the sub-function for calculating the static memory occupancy of the fifo queue module of the type fifo_queue_base_slow_1blk_raw_abadonnew. The input parameters include: the initialization constant parameters of the queue module, that is, the address value of the initialization structure of the queue module:
[0081]
[0082]
[0083] / / The following code example describes the process of the initialization function of the fifo queue module taking fifo_queue_base_slow_1blk_raw_abadonnew as an example. The input parameters include: the address of the initialization structure for the queue module and the initialization constant parameters of the queue module:
[0084]
[0085]
[0086] / / The following code example describes the process of the message acquisition function of the fifo queue module taking fifo_queue_base_slow_1blk_raw_abadonnew as an example. The input parameters include: the pointer to the structure address of the queue module and the pointer to the address for saving the dequeued message:
[0087]
[0088]
[0089]
[0090] As Figure 2 shown, some embodiments also provide an embedded code message routing architecture system, including: at least one routing management module and at least one queue module; wherein the routing management module includes: a routing memory application function and a routing memory sending function; the routing management module is configured to apply for memory from the memory management module through the routing memory application function to obtain a memory space for routing message data; and the routing management module is further configured to send the message data to be sent to each queue module through the routing memory sending function.
[0091] The embedded code message routing architecture system further includes: a shared memory management module; the shared memory management module is adapted to manage a shared memory space for routing shared type message data.
[0092] As Figure 3 shown, some embodiments further provide a message routing system, including: the embedded code message routing architecture system as described above and at least one code module; wherein
[0093] the code module is adapted to send message data to the embedded code message routing architecture system or receive message data output from the embedded code message routing architecture system.
[0094] Specifically, the code module is adapted to send message data to the embedded code message routing architecture system or receive message data output from the embedded code message routing architecture system.
[0095] Specifically, when there are multiple code modules, one of the code modules is adapted to transmit message data to the remaining code modules via the embedded code message routing architecture system.
[0096] Specifically, the message routing system further includes: a memory management module; not shown in the drawings. The embedded code message routing architecture system is adapted to apply for memory from the memory management module to obtain a memory space for routing message data.
[0097] Some embodiments further provide a readable storage medium storing readable instructions for an embedded system, which when executed by at least one embedded processor, cause the running method of the embedded code message routing architecture to be executed; the running method of the embedded code message routing architecture includes: setting at least one routing management module and at least one queue module; the routing management module includes: a routing memory application function and a routing memory sending function; the routing management module applies for memory from the memory management module through the routing memory application function to obtain a memory space for routing message data; and the routing management module also sends the message data to be sent to each queue module through the routing memory sending function.
[0098] Some embodiments also provide an embedded program product, including a program or instructions, which, when the program or instructions are executed on an embedded system, cause the operating method of the embedded code message routing architecture to be executed; the operating method of the embedded code message routing architecture includes: setting at least one routing management module and at least one queue module; the routing management module includes: a routing memory application function and a routing memory sending function; the routing management module applies for memory from the memory management module through the routing memory application function to obtain a memory space for routing message data; and the routing management module also sends the message data to be sent to each queue module through the routing memory sending function.
[0099] Some embodiments also provide an embedded program product, including a readable storage medium, on which readable program code is stored, and the embedded readable program code includes instructions that cause at least one processor (one or more embedded devices) to perform the following operations: setting at least one routing management module and at least one queue module; the routing management module includes: a routing memory application function and a routing memory sending function; the routing management module applies for memory from the memory management module through the routing memory application function to obtain a memory space for routing message data; and the routing management module also sends the message data to be sent to each queue module through the routing memory sending function.
[0100] As Figure 4 shown, some embodiments also provide an electronic device, such as an embedded device, including: at least one memory and at least one processor, wherein the memory stores executable instructions, and when the executable instructions are executed by the embedded processor, the embedded processor executes the operating method of the embedded code message routing architecture; the operating method of the embedded code message routing architecture includes: setting at least one routing management module and at least one queue module; the routing management module includes: a routing memory application function and a routing memory sending function; the routing management module applies for memory from the memory management module through the routing memory application function to obtain a memory space for routing message data; and the routing management module also sends the message data to be sent to each queue module through the routing memory sending function.
[0101] In some embodiments, the device may be an embedded control device or a single-chip microcomputer control device, including at least one memory and at least one processor.
[0102] In some embodiments, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the drawings show the possible architectures, functions, and operations of devices, methods, and embedded program products according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or actions.
[0103] In addition, in each embodiment of the present invention, the functional modules can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0104] If the described functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This embedded software product stores in a storage medium and executes all or part of the steps of the methods described in each embodiment of the present invention.
[0105] Taking the above ideal embodiments of the present invention as an inspiration, through the above description, relevant staff can, without departing from the technical idea of this invention, make various changes and modifications. The technical scope of this invention is not limited to the content in the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A running method of an embedded code message routing architecture, characterized in that Including: Setting at least one routing management module and at least one queue module; The method of setting the routing management module includes configuring: a routing memory application function and a routing memory sending function; The routing management module applies for memory from the memory management module through the routing memory application function to obtain a memory space for routing message data; and The routing management module also sends the message data to be sent to each queue module through the routing memory sending function.
2. The operation method according to claim 1, characterized in that The method by which the routing management module applies for memory from the memory management module through the routing memory application function includes: Determining the routing management module for routing according to the type of message data to be sent; Determining the corresponding memory pool of the memory management module bound to the routing management module according to the index value of the routing management module; and Using the index value of the routing management module and the size of the space occupied by the message data to be sent as input parameters of the routing memory application function to apply for the memory space for routing of the routing management module from the corresponding memory pool.
3. The operation method according to claim 2, characterized in that When the message data type is shared type message data, the corresponding routing management module will apply for the shared memory space for routing of the routing management module from the corresponding memory pool.
4. The operation method according to claim 2, characterized in that The method by which the routing management module also sends the message data to be sent to each queue module through the routing memory sending function includes: Determining each queue module bound to the routing management module according to the index value of the routing management module; and Using the index value of the routing management module and the message data address to be sent as input parameters of the routing memory sending function to route the message data address pointer to each queue module.
5. The operation method according to claim 4, characterized in that The routing management module is also initialized through the routing management module initialization constant parameters and the routing management module initialization function, including: Using the index value of the routing management module and the address of the initialization structure of the routing management module as input parameters of the routing management module initialization function to obtain the routing management module initialization constant parameters; and Initializing the corresponding routing management module according to the routing management module initialization constant parameters.
6. The operating method according to claim 3, characterized in that, Also including: Setting a shared memory management module for managing the shared memory space; The method of setting the shared memory management module includes configuring: a shared memory management module initialization function and shared memory management module initialization constant parameters; Using the address of the initialization structure of the shared memory management module as the input parameter of the shared memory management module initialization function to obtain the shared memory management module initialization constant parameters; The shared memory management module initialization constant parameters include: a lock enable flag bit, a reference count, a memory address pointer for release regression, and a share mode data format parameter; And Initializing the shared memory management module according to the shared memory management module initialization constant parameters.
7. The operation method according to claim 6, characterized in that The shared memory management module further includes: a static segment memory occupancy calculation result function, a count increment function, and a count decrement function; where The input parameters of the static segment memory occupancy calculation result function include: the initialization constant parameters of the shared memory management module, and the output parameter is the actual occupied space size of the message data; The input parameters of the count increment function include: the memory address pointer of the shared message data, and the output parameter is the count increment result; The input parameters of the count decrement function include: the memory address pointer of the shared message data and the callback function parameter, and the output parameter is the decrement result; where the callback function parameter includes: the processing result of the shared message data; When the message data passed into the shared memory management module is used, the count is incremented; after use, the count is decremented. When the count is decremented to 0, the shared memory space occupied by the corresponding message data is returned to the corresponding memory pool through the memory management module.
8. The operation method according to claim 1, characterized in that The method for setting up the queue module includes configuring: a queue module initialization function and queue module initialization constant parameters; The input parameters of the queue module initialization function include: the initialization structure address of the queue module and the queue module initialization constant parameters, and the output parameter is whether the initialization is successful.
9. The operation method according to claim 8, characterized in that The queue module further includes: a queue module static memory occupancy calculation sub-function and a message retrieval function; where The queue module initialization constant parameters include: queue module function customization parameters; The input parameters of the queue module static memory occupancy calculation sub-function include: the queue module initialization constant parameters, and the output parameter is the calculation result of the queue module static segment memory occupancy; and The input parameters of the message retrieval function include: the structure address pointer of the queue module and the pointer for saving the dequeued message address, and the output parameter is whether the dequeue is successful.
10. An embedded code message routing architecture system, characterized in that, Includes: At least one routing management module and at least one queue module; Where The routing management module includes: a routing memory application function and a routing memory sending function; The routing management module is configured to apply for memory from a memory management module through the routing memory application function to obtain a memory space for routing message data; and send the message data to be sent to each queue module through the routing memory sending function.
11. The embedded code message routing architecture system according to claim 1, wherein Further includes: A shared memory management module; The shared memory management module is adapted to manage the shared memory space for routing shared type message data.
12. A message routing system, characterized in that, Includes: The embedded code message routing architecture system according to any one of claims 10 - 11 and at least one code module; Where The code module is adapted to send message data to the embedded code message routing architecture system or receive message data output from the embedded code message routing architecture system.
13. A readable storage medium storing readable instructions for an embedded system, which when executed by at least one embedded processor, causes the operation method according to any one of claims 1 - 9 to be executed.
14. An electronic device, characterized in that, Includes: At least one memory and at least one processor, wherein the memory stores executable instructions, and when the executable instructions are executed by the embedded processor, the embedded processor executes the operation method according to any one of claims 1-9.
15. An embedded program product, comprising a program or instructions, wherein when the program or instructions are executed on an embedded system, the operation method according to any one of claims 1-9 is executed.