Hash-driven efficient message-driven system, method and device and storage medium

By using a hash-driven message-driven system, module coupling is reduced, modules are decoupled, device stability and scalability are enhanced, maintenance is simplified, and response speed is improved.

CN120929076APending Publication Date: 2025-11-11SHENZHEN JIAYZ PHOTO IND LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511070388.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-31
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

In existing technologies, direct calls between modules lead to high coupling, making unified management and expansion difficult, module upgrades cumbersome, and increasing system complexity and maintenance costs.

Method used

A message-driven system using hash-driven architecture receives functional messages through a routing module, performs hash calculations and functional parameter analysis, dynamically determines the execution method, and executes the message using a pre-generated list of functions.

Benefits of technology

Reduce module coupling, enhance equipment stability and scalability, simplify maintenance processes, and improve response speed and equipment flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929076A_ABST
    Figure CN120929076A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an efficient message-driven system, method and device driven by hash, and a storage medium. The method comprises the following steps: receiving function messages sent by all function modules through a routing module; wherein the function message comprises a message identifier and a function parameter; performing hash calculation on the message identifier to obtain a hash value of the function message; determining an execution mode of the function message based on the function parameter; and executing the function message through a routing module according to the execution mode of the function message, the hash value and a pre-generated function list. According to the method provided by the invention, decoupling between modules is realized, the equipment stability is enhanced, the equipment structure is clearer, and the maintenance is more convenient. By dynamically determining the execution mode of the function message, the equipment can flexibly process various types of messages, so that the equipment adapts to new function requirements under the condition of not performing large-scale modification, and the expandability of the equipment is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of data processing technology, and in particular to a high-efficiency message-driven system, method, apparatus and storage medium driven by hashing. Background Technology

[0002] Driven by mobile internet and 5G technologies, enterprises are accelerating their digital transformation, leading to a surge in software development. Electronic products often require more expensive R&D to support their complex software systems. For example, a microphone typically uses an embedded software system where interfaces between modules can be directly called to handle message passing and processing. That is, when a module needs to communicate with other modules, it directly calls the target module's interface function and passes the necessary parameters to that function.

[0003] This approach, due to direct calls between modules, results in highly coupled modules throughout the system. Modifying or upgrading one module may require adjustments to other modules. Furthermore, because each module is independently developed with different functions and interfaces, system functionality is scattered across different modules, making unified management and expansion difficult. For example, upgrading or replacing a module may necessitate adjustments to the entire system architecture, making module upgrades overly cumbersome and increasing system complexity and maintenance costs. Summary of the Invention

[0004] This invention provides a hash-driven, high-efficiency message-driven system, method, apparatus, and storage medium that can reduce coupling between device modules, enhance module cohesion, and make the device structure clearer and maintenance more convenient.

[0005] In a first aspect, embodiments of the present invention provide an efficient message-driven method driven by hashing, comprising:

[0006] The routing module receives function messages sent by each function module; wherein, the function message includes a message identifier and function parameters;

[0007] Perform a hash calculation on the message identifier to obtain the hash value of the functional message;

[0008] The execution method of the function message is determined based on the function parameters;

[0009] The routing module executes the function message according to the execution method of the function message, the hash value, and the pre-generated function list.

[0010] Secondly, embodiments of the present invention provide a computer program product, including a computer program that, when executed by a processor, implements an efficient message-driven method driven by hashing as described in any of the embodiments of the present invention.

[0011] Thirdly, embodiments of the present invention provide a high-efficiency message-driven device driven by hashing, the device comprising:

[0012] The message receiving module is used to receive function messages sent by each function module through the routing module; wherein, the function message includes a message identifier and function parameters;

[0013] A hash calculation module is used to perform hash calculation on the message identifier to obtain the hash value of the functional message;

[0014] The method determination module is used to determine the execution method of the function message based on the function parameters;

[0015] The message execution module is used to execute the function message through the routing module, based on the execution method of the function message, the hash value, and the pre-generated function list.

[0016] Fourthly, embodiments of the present invention also provide a microcontroller unit, the microcontroller unit including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements a hash-driven, high-efficiency message-driven method as described in any of the embodiments of the present invention.

[0017] Fifthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements an efficient message-driven method driven by hash as described in any of the embodiments of the present invention.

[0018] Sixthly, embodiments of the present invention also provide a hash-driven, high-efficiency message-driven system, the system including a routing module, a message sending module, a message response module, and other modules; the routing module is connected to the message sending module, the message response module, and the other modules; the system is used to implement a hash-driven, high-efficiency message-driven method as described in any of the embodiments of the present invention.

[0019] In this embodiment of the invention, a routing module receives function messages sent by various functional modules. Each function message includes a message identifier and function parameters. The message identifier is hashed to obtain a hash value for the function message. The execution method of the function message is determined based on the function parameters. The routing module then executes the function message according to its execution method, hash value, and a pre-generated function list. This method transforms the direct connections between modules in the original device into indirect connections through the routing module, thereby decoupling the modules, enhancing device stability, making the device structure clearer, and facilitating maintenance. Hash calculation of the message identifier allows for quick location of the corresponding callback function in the function list, reducing search time. By dynamically determining the execution method of the function message, the device can flexibly handle various types of messages, enabling it to adapt to new functional requirements without large-scale modifications, thus improving the device's scalability. Attached Figure Description

[0020] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 A first flowchart of an efficient message-driven method based on hashing provided in an embodiment of the present invention;

[0022] Figure 2 This is a schematic diagram of a high-efficiency message-driven system based on hashing, provided as an embodiment of the present invention.

[0023] Figure 3 A second flowchart of an efficient message-driven method based on hashing provided in an embodiment of the present invention;

[0024] Figure 4 A schematic diagram of a high-efficiency message-driven device driven by hashing, provided in an embodiment of the present invention;

[0025] Figure 5 This is a schematic diagram of a microcontroller unit provided in an embodiment of the present invention. Detailed Implementation

[0026] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0027] Figure 1 This is a first flowchart of a hash-driven, high-efficiency message-driven method provided by an embodiment of the present invention. The method of this embodiment reduces module coupling and enhances module cohesion, resulting in a clearer device structure and easier maintenance. This method can be executed by a hash-driven, high-efficiency message-driven device provided by an embodiment of the present invention, which can be implemented in software and / or hardware. The following embodiments will illustrate this using the integration of this device into a microcontroller unit as an example. (Refer to...) Figure 1 The method may specifically include the following steps:

[0028] Step 101: Receive function messages sent by each function module through the routing module.

[0029] Functional messages include message identifiers and functional parameters. A microcontroller unit (MCU) is a microcomputer system integrating a processor, memory, and input / output interfaces. MCUs can be used in embedded systems, such as microphone transmitters, receivers, and headphones. A routing module is a software component in the microcontroller, used to manage and coordinate message passing and processing between different modules. The routing module can receive messages from other modules and forward them to the appropriate target module based on the message's destination address. The routing module supports various communication protocols, such as serial port protocols, serial peripheral interfaces, and serial bus interfaces, to adapt to different hardware interface requirements. Message identifiers are used to mark different messages; one message corresponds to one identifier. Message identifiers can be message names or message numbers, etc. Functional parameters are used to instruct the electronic device to perform corresponding functions; functional parameters can be different types of data such as numbers, strings, or Boolean values.

[0030] In one optional implementation, when a user triggers a function of a module of an electronic device, the module generates a function message based on the triggered function. The module sends this function message to a routing module, which can receive function messages from various modules in real time. For example, the electronic device is a microphone transmitter, including two functional modules: an audio acquisition module and a wireless transmission module. The audio acquisition module acquires audio signals from the microphone and converts them into digital data. The wireless transmission module is responsible for sending the digital data to a receiving end. When the user triggers the "record" function, the audio acquisition module generates a function message identified as "start recording," with function parameters including the recording start time (current moment). The audio acquisition module sends this function message to the routing module, which can receive it in real time.

[0031] Figure 2 This diagram illustrates a high-efficiency message-driven system based on hashing, as provided in an embodiment of the present invention. The system includes a routing module, a message sending module, a message response module, and other modules. The routing module is connected to the message sending module, the message response module, and the other modules. The routing module can receive functional messages sent by each module and forward them to the corresponding message response module.

[0032] Step 102: Perform a hash calculation on the message identifier to obtain the hash value of the functional message.

[0033] The hash value is a string obtained by hashing the message identifier. Specifically, after receiving a function message, the channel routing module uses a pre-determined hash function to hash the message identifier and obtain the hash value of the function message. Hash functions include the MD5 message digest algorithm function, the Secure Hash Algorithm 1 function, or the Secure Hash Algorithm 256 function, etc. The message identifier is sent as input data to the hash function, and the hash function generates a corresponding hash value based on the input message identifier. This hash value is a hexadecimal string, and its specific length depends on the hash function used. For example, assuming the message identifier is "START_RECORDING (Start Recording)", inputting it into the hash function yields the hash value "A1B2C3D4".

[0034] Step 103: Determine the execution method of the function message based on the function parameters.

[0035] The execution methods include direct execution and forwarded execution. Forwarded execution means that the function message needs to be forwarded to the corresponding function module, and the function module will execute the function message's function. Direct execution means that the function message's function is executed directly without forwarding. Specifically, some function messages may only be notification-like and do not require other modules to take action or respond. For example, simple status update or log recording function messages do not need to be forwarded to other modules, so their execution method can be determined as direct execution. Function parameters also include relevant information about the corresponding function, such as message type, destination, and priority. After obtaining the function message, analyzing the function parameters can determine the execution method of the function message's function.

[0036] In an optional implementation, the routing module may receive many function messages simultaneously. To improve data processing efficiency, this solution may optionally include the following steps A1-A3 after obtaining the hash value of the function message:

[0037] Step A1: The routing module encapsulates the hash value and function parameters to obtain the encapsulated message corresponding to the function message.

[0038] Specifically, to flexibly respond to workflow changes and achieve load balancing in message processing, after obtaining the hash value of the message identifier, this hash value, along with information including the message type and content, is packaged into a separate data structure, such as an object or dictionary, to obtain the encapsulated message corresponding to the functional message. By encapsulating the hash value and functional parameters, the format of each message can be ensured to be consistent, reducing errors in data processing.

[0039] Step A2: Store the encapsulated message in a predefined message queue and obtain the current operating status of the microcontroller unit.

[0040] The operating state can be either idle or non-idle. The message queue is a predefined queue used to store encapsulated messages. After receiving an encapsulated message, it can be stored in the message queue. This ensures that function messages are processed in the order they are received, and also supports the device's asynchronous processing mechanism. After storing the encapsulated message in the message queue, the current operating state of the microcontroller is obtained to determine whether the microcontroller is idle or performing other tasks. When it is idle, the function message is retrieved from the message queue and executed. The message queue avoids potential congestion during message processing, ensuring stable operation of the device even under high load.

[0041] Step A3: When the running state is idle, execute the step of determining the execution method of the function message based on the function parameters.

[0042] Specifically, when the operating state is idle, it means that the function message can be executed, and the steps to determine the execution method of the function message based on the function parameters are executed. If the operating state of the microcontroller is non-idle, it means that the function message cannot be executed immediately, and it is necessary to wait until the operating state of the microcontroller is idle before executing the steps to determine the execution method of the function message based on the function parameters.

[0043] Through the above steps, the device can dynamically adjust task execution based on current resource usage, improving response speed and processing efficiency. Message queues ensure that functional messages are processed in the order they are received. Furthermore, if an error occurs in processing a functional message, storing it in the queue temporarily isolates the error, allowing the microcontroller unit to continue processing other messages, and the problematic message can be processed or investigated later.

[0044] Step 104: Execute the function message through the routing module according to the execution method, hash value, and pre-generated function list of the function message.

[0045] The execution methods include direct execution or forwarded execution. The function list stores predefined message identifiers and their corresponding callback functions. The device can execute the function of the corresponding function message through the callback function. In one optional implementation, if the function message is executed via forwarded execution, a target hash value matching the function message's hash value is searched in the function list; the callback function corresponding to the target hash value in the function list is determined as the target callback function, and the function message's function is executed through the target callback function. If no callback function corresponding to the function message is found in the function list, a callback function corresponding to the function message can be registered in real-time based on the function message using a predefined event handler; after registration, the function message's function can be executed through the corresponding callback function. The registered callback functions corresponding to the function message are stored in the function list for later use. If the function message is executed via direct execution, the function message's function is executed directly according to the function parameters.

[0046] The technical solution of this embodiment receives function messages sent by various functional modules through a routing module. Each function message includes a message identifier and function parameters. A hash calculation is performed on the message identifier to obtain the hash value of the function message. The execution method of the function message is determined based on the function parameters. The routing module executes the function message according to its execution method, hash value, and a pre-generated function list. This embodiment transforms the direct connections between modules in the original device into indirect connections through the routing module, thereby decoupling the modules, enhancing device stability, making the device structure clearer, and facilitating maintenance. Hash calculation on the message identifier allows for quick location of the corresponding callback function in the function list, reducing search time. By dynamically determining the execution method of the function message, the device can flexibly handle various types of messages, enabling it to adapt to new functional requirements without large-scale modifications, thus improving the device's scalability.

[0047] Figure 3 This is a second flowchart of a hash-driven, high-efficiency message-driven method provided in an embodiment of the present invention. This embodiment is a refinement based on the above embodiment. The specific method can be as follows: Figure 3 As shown, the method may include the following steps:

[0048] Step 301: Receive function messages sent by each function module through the routing module.

[0049] The functional message includes a message identifier and functional parameters.

[0050] Step 302: Perform a hash calculation on the message identifier to obtain the hash value of the functional message.

[0051] Step 303: Obtain the interface information of the function message based on the function parameters; determine whether there is a corresponding callback function for the function message based on the interface information.

[0052] The interface information for a functional message includes the message's function, parameters, return value, and whether a callback function is required. Functional parameters define not only the content of the functional message but also the specific operations to be performed or the data types involved. In this solution, after obtaining the functional parameters, the microcontroller unit can search for the corresponding interface information for the functional message in a predefined interface information library and identify it as the interface information for the functional message. After obtaining the interface information, it determines whether a callback function associated with the functional message exists.

[0053] Step 304: If the function message has a corresponding callback function, determine that the execution method of the function message is forward execution.

[0054] Specifically, if the interface information determines that a corresponding callback function exists for a functional message, it indicates that the functional message requires forwarding by the routing module; that is, the execution method of the functional message is forwarding execution. For example, when a user uses a microphone with a voice-changing function, the device receives a functional message containing the original sound data (functional parameters) when the user inputs sound through the microphone. The message identifier of this functional message is hashed to obtain its hash value. Based on the functional parameters, the corresponding interface information is searched in a predefined interface information database, and based on this interface information, it is determined that the functional message has a corresponding callback function, further confirming that the execution method of the functional message is forwarding execution.

[0055] Step 305: If the execution mode of the function message is forward execution, search for the target hash value that matches the hash value of the function message in the function list.

[0056] The target hash value is the same as the hash value of the function message. The function list stores predefined message identifiers and their corresponding callback functions. Before receiving function messages from various function modules via the routing module, hash values ​​and callback functions for each message identifier can be pre-generated and stored in the function list. When the execution mode of a function message is determined to be forward execution, the microcontroller unit can retrieve the function message from the message queue. It then searches the function list for a hash value that matches the message identifier of the function message and uses this hash value as the target hash value.

[0057] Step 306: Determine the callback function corresponding to the target hash value in the function list as the target callback function, and execute the function message through the target callback function.

[0058] Specifically, after obtaining the target hash value, the callback function corresponding to the target hash value in the function list is identified as the target callback function, and the function message is executed through the target callback function. For example, if a user is using a microphone that can change their voice, the device determines that the execution method of the function message is forwarding. After calculating and determining that the hash value of the message identifier of the function message is "aaa", the microcontroller unit searches for "aaa" in the function list and identifies the callback function corresponding to "aaa" as the target callback function.

[0059] In practical applications, the function list includes callback functions for function messages corresponding to the device's basic functions, but may not include callback functions for some simple extended function messages. In this solution, optionally, if no callback function corresponding to a function message is found in the function list, a callback function corresponding to the function message is registered based on the function message using a predefined event handler; the function message's functionality is executed using the callback function corresponding to the function message, and the function list is updated based on the registered callback function corresponding to the function message.

[0060] The event handler is used to register corresponding callback functions based on the function message. Specifically, when no callback function corresponding to the function message is found in the function list, and the function message is executed via forwarding, the device can call a predefined event handler. The event handler creates a new callback function based on the function parameters of the function message. For example, if a user requests a new voice-changing effect (a voice-changing effect exists but the user has not used it), and this effect is not currently in the function list, the event handler can generate a callback function for this new effect (the function message that changes the voice effect). Furthermore, the event handler associates the new callback function with the hash value corresponding to the function message and adds it to the function list. Thus, when the same function message is triggered again, the device can directly find and execute the corresponding callback function in the function list.

[0061] By following the steps above, it can be ensured that the device can dynamically process and adapt to new functional requirements, while maintaining an efficient execution and update mechanism to respond promptly to changes in user needs, thereby achieving highly flexible and scalable functionality.

[0062] Step 307: If there is no corresponding callback function for the function message, determine that the execution method of the function message is direct execution, and execute the function message according to the function parameters.

[0063] If a function message does not have a corresponding callback function, it means that the function message does not require a callback function, and the microcontroller unit can directly execute the function message's function. That is, if a function message does not have a corresponding callback function, the microcontroller unit determines the execution method of the function message as direct execution. Specifically, after determining that the execution method of the function message is direct execution, the microcontroller unit can perform corresponding operations according to the function parameters, including calling relevant application programming interfaces (APIs) or modifying device settings. For example, if the function message's function is to increase the microphone input volume, the microcontroller unit will directly call the operating system's audio processing API to adjust the microphone input volume.

[0064] In this solution, the microcontroller unit can also perform error handling and feedback during direct execution. If an error occurs during processing, such as invalid parameters or hardware failure, the microcontroller unit can identify these errors and send error notifications to the user or perform other recovery operations.

[0065] In this embodiment, the routing module receives function messages sent by various functional modules. Each function message includes a message identifier and function parameters. The message identifier is hashed to obtain a hash value for the function message. The interface information of the function message is obtained based on the function parameters. The existence of a corresponding callback function for the function message is determined based on the interface information. If a corresponding callback function exists, the execution method of the function message is determined to be forward execution. If no corresponding callback function exists, the execution method of the function message is determined to be direct execution. If the execution method of the function message is forward execution, a target hash value matching the hash value of the function message is searched in the function list. The callback function corresponding to the target hash value in the function list is determined as the target callback function, and the function message's function is executed through the target callback function. This embodiment decouples modules, enhances device stability, makes the device structure clearer, and facilitates maintenance. Hashing the message identifier to obtain a unique hash value allows for quick location of the corresponding callback function, reducing search time and ensuring the device maintains a fast response speed even with a large number of function messages. If a callback function corresponding to a function message cannot be found in the function list, the device can dynamically register a new callback function based on the function message through the event handler and update the function list, ensuring that the device can adapt to new changes in a timely manner while maintaining the consistency and continuity of operation.

[0066] This invention also provides a computer program product.

[0067] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer program products, which may include one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be an application-specific or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0068] Figure 4 This is a schematic diagram of a hash-driven, high-efficiency message-driven device provided in an embodiment of the present invention. This device is suitable for executing the hash-driven, high-efficiency message-driven method provided in an embodiment of the present invention. Figure 4 As shown, the device may specifically include:

[0069] The message receiving module 401 is used to receive function messages sent by each function module through the routing module; wherein, the function message includes a message identifier and function parameters;

[0070] The hash calculation module 402 is used to perform hash calculation on the message identifier to obtain the hash value of the functional message;

[0071] The method determination module 403 is used to determine the execution method of the function message based on the function parameters;

[0072] The message execution module 404 is used to execute the function message through the routing module according to the execution method of the function message, the hash value and the pre-generated function list.

[0073] Optionally, the message receiving module 401 is specifically used to: encapsulate the hash value and the function parameter through the routing module to obtain the encapsulated message corresponding to the function message;

[0074] The encapsulated message is stored in a predefined message queue, and the operating status of the microcontroller at the current moment is obtained; the operating status is either idle or non-idle.

[0075] When the running state is the idle state, the step of determining the execution mode of the function message based on the function parameters is executed.

[0076] Optionally, the method determination module 403 is specifically used to: obtain the interface information of the function message based on the function parameters;

[0077] Based on the interface information, determine whether the function message has a corresponding callback function. If the function message has a corresponding callback function, determine that the execution method of the function message is forward execution.

[0078] If the function message does not have a corresponding callback function, the execution method of the function message is determined to be direct execution.

[0079] Optionally, the message execution module 404 is specifically used to: if the execution mode of the function message is the forwarding execution, search the function list for a target hash value that matches the hash value of the function message;

[0080] The callback function corresponding to the target hash value in the function list is determined as the target callback function, and the function message is executed through the target callback function.

[0081] Optionally, the message execution module 404 is further configured to: if no callback function corresponding to the function message is found in the function list, register a callback function corresponding to the function message according to the function message through a predefined event handler;

[0082] The function of the function message is executed by the callback function corresponding to the function message, and the function list is updated according to the registered callback function corresponding to the function message.

[0083] Optionally, the message execution module 404 is further configured to: if the execution mode of the function message is direct execution, then execute the function of the function message according to the function parameters.

[0084] The hash-driven high-efficiency message-driven device provided in this embodiment of the invention can execute the hash-driven high-efficiency message-driven method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method execution. Content not described in detail in this embodiment can be referred to the description in any method embodiment of the invention.

[0085] Figure 5 This is a schematic diagram of a microcontroller unit provided in an embodiment of the present invention, with reference to... Figure 5 , Figure 5 The microcontroller unit 12 shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments in this application. Figure 5As shown, the microcontroller unit 12 is represented in the form of a general-purpose computing device. The components of the microcontroller unit 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and a bus 18 connecting different system components (including system memory 28 and processing units 16).

[0086] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0087] The microcontroller unit 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the microcontroller unit 12, including volatile and non-volatile media, removable and non-removable media.

[0088] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Microcontroller unit 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 5 Not shown; usually referred to as a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this application.

[0089] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of this application.

[0090] The microcontroller unit 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with the microcontroller unit 12, and / or with any device that enables the microcontroller unit 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, the microcontroller unit 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of the microcontroller unit 12 via bus 18. It should be understood that, although... Figure 5 As not shown, other hardware and / or software modules can be used in conjunction with the microcontroller 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0091] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28. For example, it implements a hash-driven, high-efficiency message-driven method provided in this embodiment of the invention: receiving functional messages sent by various functional modules through the routing module; wherein the functional message includes a message identifier and functional parameters; performing a hash calculation on the message identifier to obtain the hash value of the functional message; determining the execution mode of the functional message based on the functional parameters; and executing the functional message through the routing module according to the execution mode of the functional message, the hash value, and a pre-generated function list.

[0092] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a hash-driven, high-efficiency message-driven method as provided in all embodiments of this invention: receiving function messages sent by various function modules through a routing module; wherein the function message includes a message identifier and function parameters; performing a hash calculation on the message identifier to obtain a hash value of the function message; determining the execution mode of the function message based on the function parameters; and executing the function message through the routing module according to the execution mode of the function message, the hash value, and a pre-generated function list. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor microcontroller unit, device, or component, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: electrical connections having one or more wires; portable computer disks; hard disks; random access memory (RAM); read-only memory (ROM); erasable programmable read-only memory (EPROM or flash memory); optical fiber; portable compact disk read-only memory (CD-ROM); optical storage devices; magnetic storage devices; or any suitable combination of the foregoing. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with a microcontroller unit, device, or apparatus that executes instructions.

[0093] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in conjunction with a microcontroller unit, device, or apparatus that executes instructions.

[0094] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0095] Computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0096] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A hash-driven, high-efficiency message-driven method, characterized in that, Applied to a microcontroller unit, the microcontroller unit including a routing module, the method includes: The routing module receives function messages sent by each function module; wherein, the function message includes a message identifier and function parameters; Perform a hash calculation on the message identifier to obtain the hash value of the functional message; The execution method of the function message is determined based on the function parameters; The routing module executes the function message according to the execution method of the function message, the hash value, and a pre-generated function list; the function list includes the hash value and callback function of each function message.

2. The method according to claim 1, characterized in that, After obtaining the hash value of the functional message, the method further includes: The routing module encapsulates the hash value and the functional parameters to obtain the encapsulated message corresponding to the functional message. The encapsulated message is stored in a predefined message queue, and the operating status of the microcontroller at the current moment is obtained; the operating status is either idle or non-idle. When the running state is the idle state, the step of determining the execution mode of the function message based on the function parameters is executed.

3. The method according to claim 1, characterized in that, The execution methods include direct execution or forwarded execution; Determining the execution method of the function message based on the function parameters includes: The interface information for obtaining the functional message based on the functional parameters; Based on the interface information, determine whether the function message has a corresponding callback function. If the function message has a corresponding callback function, determine that the execution method of the function message is forward execution. If the function message does not have a corresponding callback function, the execution method of the function message is determined to be direct execution.

4. The method according to claim 3, characterized in that, Executing the function message according to the execution method of the function message, the pre-generated function list, and the function parameters includes: If the execution method of the function message is forwarding execution, find the target hash value that matches the hash value of the function message in the function list; The callback function corresponding to the target hash value in the function list is determined as the target callback function, and the function message is executed through the target callback function.

5. The method according to claim 4, characterized in that, The method further includes: If no callback function corresponding to the function message is found in the function list, the callback function corresponding to the function message is registered according to the function message through a predefined event handler; The function of the function message is executed by the callback function corresponding to the function message, and the function list is updated according to the registered callback function corresponding to the function message.

6. The method according to claim 3, characterized in that, Executing the function message according to the execution mode of the function message, the pre-generated function list, and the function parameters includes: if the execution mode of the function message is direct execution, then the function of the function message is executed according to the function parameters.

7. The method according to claim 3, characterized in that, Obtaining interface information for a function message based on function parameters includes: searching for interface information related to the function message in a predefined interface information database according to the function parameters.

8. A high-efficiency message-driven system based on hashing, characterized in that, The system includes a routing module, a message sending module, a message response module, and other modules; the routing module is connected to the message sending module, the message response module, and the other modules; the system is used to implement a hash-driven, efficient message-driven method as described in any one of claims 1 to 7.

9. A high-efficiency message-driven device driven by hashing, characterized in that, include: The message receiving module is used to receive function messages sent by each function module through the routing module; wherein, the function message includes a message identifier and function parameters; A hash calculation module is used to perform hash calculation on the message identifier to obtain the hash value of the functional message; The method determination module is used to determine the execution method of the function message based on the function parameters; The message execution module is used to execute the function message through the routing module, based on the execution method of the function message, the hash value, and the pre-generated function list.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements a hash-driven, efficient message-driven method as described in any one of claims 1 to 7.