Message processing method and device, equipment and storage medium

Through global data structure and multi-threaded processing, the resource consumption problem when the main control end and the target device interact in the OTA system is solved, and efficient and low-resource consumption communication is achieved to adapt to large-scale message transmission.

CN120653461APending Publication Date: 2025-09-16CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510684411.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-26
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

In existing OTA systems, the main control end and the target vehicle device interact through a single thread, which consumes hardware resources when sending and receiving a large number of messages, resulting in a decrease in business processing efficiency.

Method used

A global data structure is used to store messages, message field data is stored through multiple data nodes, and multi-threaded processing is used to process message transmission, including the first global data structure to store the master end message and the second global data structure to store the target device reply message. The legitimacy of the message is verified by comparing the message type and timestamp to ensure efficient transmission.

Benefits of technology

It reduces network and memory resource consumption, realizes high-speed and low-resource consumption communication between the master terminal and the target device, and adapts to the needs of large-scale message transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653461A_ABST
    Figure CN120653461A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of data processing, in particular to a message processing method, device and equipment and a storage medium, and aims to realize high-speed and low-resource-consumption communication between a vehicle master control end and vehicle equipment. The method comprises the following steps: receiving a first message sent by a master control end; the first message is stored in a first global data structure, the first global data structure comprises a plurality of data nodes, and the data nodes store data of partial or all fields in the message; sending the first message in the first global data structure to a target device; receiving a second message sent by the target device, wherein the second message is a reply message generated by the target device according to the first message; storing the second message in a second global data structure; and sending the second message to the master control end under the condition of determining that the message of which the message type is the same as that of the second message exists in the first global data structure.
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 message processing method, apparatus, device and storage medium. Background Art

[0002] The existing OTA system includes the cloud-master-slave-vehicle equipment. During data interaction, the cloud obtains the corresponding message data and sends it to the master. The master sends the message data to the slave, which is then sent to the target vehicle equipment through the slave. After the target vehicle equipment processes the received message data, it sends the corresponding feedback information to the slave, which is then sent to the master.

[0003] In the prior art, the main control end interacts with the target vehicle device through a single thread. When a large number of messages are sent and received, hardware resources are greatly consumed, resulting in a decrease in business processing efficiency. Summary of the Invention

[0004] Embodiments of the present invention provide a message processing method, apparatus, device, and storage medium, which are intended to achieve high-speed and low-resource-consumption communication between a vehicle master terminal and vehicle equipment.

[0005] A first aspect of an embodiment of the present invention provides a message processing method, the method comprising: Receive a first message sent by the master terminal; Storing the first message in a first global data structure, where the first global data structure includes a plurality of data nodes, and the data nodes store data of some or all fields in the message; Sending the first message in the first global data structure to a target device; receiving a second message sent by the target device, where the second message is a reply message generated by the target device according to the first message; storing the second message in a second global data structure; In a case where it is determined that a message of the same message type as the second message exists in the first global data structure, the second message is sent to the master control end.

[0006] Optionally, the method further includes: When the master control end receives the second message, deleting the data nodes corresponding to the first message and the second message; Optionally, the storing the first message in a first global data structure, where the first global data structure includes a plurality of data nodes, and the data nodes store data of some or all fields in the message, includes: Upon receiving the first message, creating a data node corresponding to the first message; The address of the data node corresponding to the first message is added to the last node in the first global data structure.

[0007] Optionally, when it is determined that a message of the same message type as the second message exists in the first global data structure, before sending the second message to the master control end, the method further includes: reading the second message from the second global data structure; Determining a message type identifier of the second message; Traversing all data nodes in the first global data structure, and determining a message type identifier corresponding to each data node; The message type identifier of the data node in the first global data structure is compared with the message type identifier of the second message to determine whether there is a message with the same message type identifier as the second message in the first global data structure.

[0008] Optionally, the method further includes: Obtain a first timestamp of a data node corresponding to the first message and a second timestamp of a data node corresponding to the second message; Determining whether a time difference between the second timestamp and the first timestamp exceeds a preset timeout period; Determine whether a deletion mark exists on the data node corresponding to the first message; If the first timestamp is earlier than the second timestamp, the time difference does not exceed the preset timeout period, and there is no deletion mark on the data node corresponding to the first message, it is determined that the second message has passed the verification.

[0009] Optionally, the method further includes: If the second message fails to pass the verification, sending a timeout message to the master control end; The data node corresponding to the second message and the data node corresponding to the first message are deleted.

[0010] Optionally, the method further includes: When the service processing time corresponding to the first message exceeds the preset processing time, creating an independent thread to pre-process the first message; Storing the data node corresponding to the preprocessed first message in the first global data structure; A corresponding timeout period is set for the first message.

[0011] A second aspect of an embodiment of the present invention provides a message processing device, the device comprising: A first message receiving module, configured to receive a first message sent by a master terminal; A first message storage module, configured to store the first message in a first global data structure, wherein the first global data structure includes a plurality of data nodes, and the data nodes store data of some or all fields in the message; A first message sending module, configured to send the first message in the first global data structure to a target device; a second message receiving module, configured to receive a second message sent by the target device, where the second message is a reply message generated by the target device according to the first message; A second message storage module, configured to store the second message in a second global data structure; The second message sending module is configured to send the second message to the main control end when it is determined that a message of the same message type as the second message exists in the first global data structure.

[0012] Optionally, the device further comprises: A first node deletion module, configured to delete the data nodes corresponding to the first message and the second message when the master control end receives the second message; Optionally, the first message storage module includes: A data node creation submodule corresponding to the first message, configured to create a data node corresponding to the first message upon receiving the first message; The memory address is placed in a submodule, which is used to add the address of the data node corresponding to the first message to the last node in the first global data structure.

[0013] Optionally, the device further comprises: a second message reading module, configured to read the second message from the second global data structure; a message type determination module, configured to determine a message type identifier of the second message; A first global data structure traversal module, configured to traverse all data nodes in the first global data structure and determine a message type identifier corresponding to each data node; The same message determination module is used to compare the message type identifier of the data node in the first global data structure with the message type identifier of the second message to determine whether there is a message in the first global data structure with the same message type identifier as the second message.

[0014] Optionally, the device further comprises: A timestamp determination module, configured to obtain a first timestamp of a data node corresponding to the first message and a second timestamp of a data node corresponding to the second message; a time difference determination module, configured to determine whether a time difference between the second timestamp and the first timestamp exceeds a preset timeout period; a mark determination module, configured to determine whether a deletion mark exists on the data node corresponding to the first message; The verification module is used to determine that the second message has passed the verification when the first timestamp is earlier than the second timestamp, the time difference does not exceed the preset timeout period, and there is no deletion mark on the data node corresponding to the first message.

[0015] Optionally, the device further comprises: A timeout message sending module, configured to send a timeout message to the master control end if the second message fails to pass the verification; The second node deletion module is used to delete the data node corresponding to the second message and the data node corresponding to the first message.

[0016] Optionally, the device further comprises: a preprocessing module, configured to create an independent thread to preprocess the first message when the service processing time corresponding to the first message exceeds a preset processing time; A pre-processed message storage module, configured to store the data node corresponding to the pre-processed first message into the first global data structure; A timeout specifying module is used to set a corresponding timeout for the first message.

[0017] A third aspect of an embodiment of the present invention provides a readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described in the first aspect of the present invention is implemented.

[0018] A fourth aspect of an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in the first aspect of the present invention are implemented.

[0019] The message processing method provided by the present invention is used to receive a first message sent by a main control end; store the first message in a first global data structure, wherein the first global data structure includes multiple data nodes, and the data nodes store data of some or all fields in the message; send the first message in the first global data structure to a target device; receive a second message sent by the target device, wherein the second message is a reply message generated by the target device based on the first message; store the second message in a second global data structure; and when it is determined that there is a message of the same message type as the second message in the first global data structure, send the second message to the main control end.

[0020] In the present invention, the message sent by the master end is received through the first global data structure, and the reply message of the target device is received through the second global data structure. By comparing the message types of the messages in the second global data structure and the first global data structure, the reply message corresponding to the message sent by the master end is determined. In this way, the consumption of network and memory resources is greatly reduced, and at the same time, it is ensured that efficient communication between the master end and the target device can still be achieved when a large number of messages appear at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0022] Figure 1 It is the network topology of OTA software; Figure 2 is a flow chart of a message processing method proposed in one embodiment of the present invention; Figure 3 This is a schematic diagram of a linked list structure proposed in one embodiment of the present invention; Figure 4 This is a schematic diagram comparing message types proposed in one embodiment of the present invention; Figure 5 This is a schematic diagram of a message processing flow proposed in one embodiment of the present invention; Figure 6 is a schematic diagram of a message processing device proposed in one embodiment of the present invention; Figure 7 FIG. 1 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without creative work are within the scope of protection of the present invention.

[0024] refer to Figure 1 , Figure 1 is the network topology of the OTA software, such as Figure 1 As shown in the figure, the communication path of OTA software is cloud-OTA master-OTA slave-vehicle device. When the cloud sends a message, the message flow process is as follows (taking the query of the vehicle version number as an example): The cloud sends a command to query the vehicle version number through the MQTT (Message Queuing Telemetry Transport, a lightweight message transmission protocol based on the publish / subscribe model). After the OTA master receives the subscription message pushed by MQTT, it parses the MQTT message and generates a ZMQ (ZeroMQ, zero message queue) message. The ZMQ message is sent to the slave through the master proxy layer. After the slave receives the ZMQ message, it sends the message to the vehicle device. After receiving the message, the vehicle device returns the corresponding vehicle version number. After obtaining the returned vehicle version number, the slave sends the corresponding message to the master through the master proxy layer. The master sends the message to the cloud through MQTT, completing the data flow of the entire query command.

[0025] refer to Figure 2 , Figure 2 This is a flow chart of a message processing method proposed in one embodiment of the present invention. This method is a message processing method between a master terminal and a slave terminal. It can be deployed on the master terminal, the slave terminal or the proxy layer. The proxy layer is connected to the master terminal and the slave terminal respectively. Figure 2 As shown, the specific steps include: S11: Receive a first message sent by the master terminal.

[0026] In this embodiment, the master control terminal of the OTA software has the functions of controlling upgrades, downloads, version detection, vehicle-cloud protocol interaction, DoIP message sending, and managing the slave control of each target device. The first message is the message sent by the master control terminal to the target device.

[0027] In this embodiment, when the master end sends the first message to the target device, it first sends the first message to the slave end, and creates a dedicated thread from the control to receive the message sent by the master end. Then, the thread receives the first message sent by the master end and stores the first message in a sending message queue. The sending message queue is used to store messages sent by the master end.

[0028] For example, a thread 1 is created to receive messages sent by the master through the message receiving function (zmq_recive, the core function for receiving messages from the socket in ZeroMQ), and after receiving the master message, the received message is stored in the send message queue.

[0029] S12: Store the first message in a first global data structure, where the first global data structure includes multiple data nodes, and the data nodes store data of part or all fields in the message.

[0030] In this embodiment, the data node corresponding to the first message is a data node for storing the first message and is a storage space allocated in memory. The first global data structure is a data structure for receiving messages sent by the master control terminal, and includes multiple data nodes, each of which stores data for some or all fields in the message.

[0031] For example, the first global data structure is a linked list structure, storing data in non-contiguous storage blocks and connecting them in series via addresses. The global linked list refers to a set of data shared by all threads during the execution of the entire software, and the entire data is a linked list header address. Received data is stored in the nodes of the linked list. Each node is linked by connecting the addresses of the nodes in series to form the entire received global linked list. The first global structure can also be a variable, a database, a file, etc.

[0032] In this embodiment, a thread 2 is created to receive the first message from the master's send message queue and store the data carried in the first message in the first global data structure. Upon receiving the first message, the thread 2 applies for the corresponding storage space and adds the corresponding data node to the first global data structure. When the node is mounted, the node is stamped with the latest timestamp.

[0033] S13: Send the first message in the first global data structure to a target device.

[0034] In this embodiment, the target devices are various intelligent components in the vehicle, which are hardware vehicle devices controlled by software.

[0035] In this embodiment, after the first message is placed into the first global data structure, a thread is created to continuously read the node data in the first global data structure. After identifying the newly added first message, the first message is placed into the sending message queue corresponding to the target device, and then a thread is created to read the messages in the sending message queue of the target device. When the first message is received, it is forwarded to the target device.

[0036] For example, a thread 3 is created. This thread is used to continuously read the data nodes in the first global data structure. After reading the node data in the first global data structure, the data of this node is sent to the send message queue of the target device. A thread 4 is created to continuously receive messages from the message queue to be sent to the target device and send this message to the target device through the subscribed topic specified by zmq. At the same time, the result returned by zmq_send (the function used by ZeroMQ to send messages) is saved in the first global data structure.

[0037] S14: Receive a second message sent by the target device, where the second message is a reply message generated by the target device according to the first message.

[0038] In this embodiment, the second message is a reply message generated by the target device according to the first message.

[0039] In this embodiment, a thread is created from the control end to receive the second message sent by the target device and store the message in the result message queue.

[0040] For example, if the first message is "Query the vehicle version number," the corresponding second message is "The vehicle version number is xxxxxx." Create a thread 5 that uses the message receiving function (zmq_recive) to continuously receive messages from the subscribed topic (zmqtopic). After receiving the topic message from the target device, it stores the received message in the result message queue.

[0041] S15: Store the second message in a second global data structure.

[0042] In this embodiment, the second global data structure is used to store message data replied by the target device to the control end.

[0043] In this embodiment, after the target device sends the second message, the second message is received from the result message queue of the target device, and the corresponding space is also created in the memory to create a second node, and then the address of the second node is placed in the last data node of the second global data structure.

[0044] For example, the second global data structure is a linked list. Thread 6 is created to continuously receive messages from a message queue and add the timestamp of the data carried in the message queue to the linked list. Queue dequeues and linked list additions and deletions are all handled by queue processing thread 6. The processing of this linked list requires a global read-write lock to ensure timing. The second global data structure can also be a variable, database, file, etc.

[0045] S16: When it is determined that a message of the same message type as the second message exists in the first global data structure, the second message is sent to the master control end.

[0046] In this embodiment, the message type is used to identify the type of each message and is a pre-set tag. The message sent by each master terminal is of the same type as the message replied by the target device according to the message.

[0047] In this embodiment, after the second message is stored in the second global data structure, a thread is created to read the node data on the second global data structure. The thread also obtains the node data on the first global data structure. The message corresponding to the data on each node is set with a message type when it is sent, and the message replied by the target device is also the same as the message type of the message. That is to say, the message type of each pair of the first message and the replied second message is the same.

[0048] In this embodiment, a thread 7 is created to read the second global data structure and obtain the second message in the second global data structure. The thread will also traverse the first global data structure to obtain the message type corresponding to all node data in the first global data structure. When node data with the same message type as the second message is found, it means that the message sent by the main control end has generated a corresponding reply message. At this time, the second message is sent to the main control end. When the second message is sent to the main control end, the second message is sent to the main control end's send message queue. The main control end's send message queue stores the messages in the second global data structure that need to be sent to the main control end. Then a thread 8 is created to continuously receive messages from the main control end's send message queue. After parsing, the messages are packaged into json (JavaScript Object Notation, using key-value pairs and hierarchical nesting to describe data, supporting basic types such as strings, numbers, Boolean values, arrays and objects) format and sent to the main control end.

[0049] For example, the first message is "query vehicle version number", and the second message is "vehicle version number bit XXXX". When the message type of the second message is found to be the same as the message type of the first message in the first global data structure, the second message is sent to the main control end.

[0050] In this embodiment, a corresponding thread is set in each link. When the main control end sends a message, the message sent by the main control end is stored through the first global data structure, and the second global data structure is used to store the message of the intelligent agent's reply. The message is then transmitted through the corresponding thread and queue. The slave end and the intelligent agent exchange information through the global linked list. After the reply information is determined, it is transmitted to the main control end, which reduces the resource usage during the data transmission process and is suitable for the impact of a large number of network messages after the zmq-based transceiver model wakes up from sleep, saving a large number of threads and network resources, and achieving the function of low resource usage while meeting business requirements.

[0051] In another embodiment of the present invention, the method further comprises: S21: When the master control end receives the second message, the master control end deletes the data nodes corresponding to the first message and the second message.

[0052] In this embodiment, when the master control end receives the second message, the first global data structure and the second global data structure no longer need to store the data nodes corresponding to the first message and the data nodes corresponding to the second message. At this time, the data nodes corresponding to the first message and the data nodes corresponding to the second message are deleted.

[0053] For example, a deletion mark is added to the data node corresponding to the first message and the data node corresponding to the second message. The deletion mark is a field added to the node, which is used to indicate that the node needs to be removed. The first global data structure is traversed by one thread. When the deletion mark is read, the data node corresponding to the first message is deleted. Then, the second global data structure is traversed by another thread. When the deletion mark is read, the data node corresponding to the second message is deleted.

[0054] In this embodiment, a deletion mark is added to the corresponding data node when the message is delivered, so that the node in the global linked list is deleted in time, the global linked list is updated in time, and memory resources are saved.

[0055] In another embodiment of the present invention, when it is determined that a message of the same message type as the second message exists in the first global data structure, before sending the second message to the master control end, the method further includes: S31: Read the second message from the second global data structure.

[0056] In this embodiment, after the second message is stored in the second global data structure, a thread is created to read the second message in the second global data structure.

[0057] S32: Determine the message type identifier of the second message.

[0058] In this embodiment, each message includes a message type field, and the message type field includes a message type identifier. The message type identifiers corresponding to the first message sent by each master terminal and the second message replied by the target device are unique.

[0059] In this embodiment, after the message type field of the second message is read, the message type identifier of the second message is determined.

[0060] S33: Traverse all data nodes in the first global data structure and determine the message type identifier corresponding to each data node.

[0061] In this embodiment, all data nodes in the first global data structure are traversed by the created thread, and the message type field of each data node is read to further determine the message type identifier corresponding to each data node in the first global data structure.

[0062] S34: Compare the message type identifier of the data node in the first global data structure with the message type identifier of the second message to determine whether there is a message in the first global data structure with the same message type identifier as the second message.

[0063] In this embodiment, after determining the message type identifier of each data node in the first global data structure, the message type identifier of the data node in the first global data structure is compared with the message type identifier of the second message to determine whether there is a message in the first global data structure that has the same message type identifier as the second message.

[0064] For example, refer to Figure 4 , Figure 4 This is a schematic diagram comparing message types proposed in one embodiment of the present invention. Figure 4 As shown, each time the main control end sends information, a corresponding message type identifier is stored in each node. After receiving the second message in the second global data structure, the message type identifier of the first global data structure is traversed to determine whether there is the same message type identifier as the second message. If there is the same message type identifier, it means that the software corresponding to the intelligent body has replied to the message.

[0065] For example, the first message is to query vehicle information, and the message type identifier is "2". The message type of the second message replied by the software corresponding to the intelligent agent is the same as the message type of the first message, which is also "2". After the software corresponding to the intelligent agent replies to the message, it receives the vehicle information reply message in the second global data structure, and then queries the first global data structure. It is found that the message type identifiers of both are "2", and the matching is completed at this time.

[0066] In this embodiment, the message type is set to ensure that the first message and the second message can correspond to each other, thereby ensuring the accuracy of information transmission between the master terminal and the target device.

[0067] In another embodiment of the present invention, the method further comprises: S35: Obtain a first timestamp of the data node corresponding to the first message and a second timestamp of the data node corresponding to the second message.

[0068] In this embodiment, the timestamp is used to mark the time when the node is created, that is, the time when the first message or the second message is received.

[0069] In this embodiment, when the second message is received through the corresponding thread, the corresponding timestamp will be read. After the corresponding first message is determined, the corresponding timestamp can also be read. It is necessary to determine that the timestamp of the data node corresponding to the second message is earlier than the timestamp of the data node corresponding to the first message. This is in line with the logic of message initiation and reply. Otherwise, the message content may be wrong.

[0070] S36: Determine whether the time difference between the second timestamp and the first timestamp exceeds a preset timeout period.

[0071] In this embodiment, the preset timeout period is used to set the reply time of the message. If the target device does not reply to the message within the timeout period, it is considered a timeout, and the difference between the second message time and the first message time exceeds the preset timeout period.

[0072] In this embodiment, after determining the timestamp of the data node corresponding to the second message and the timestamp of the data node corresponding to the first message, the time difference between the two can be obtained. At this time, the time difference between the two must not exceed the preset timeout period before the second message can be identified as a normal message to ensure that the main control end receives the correct reply message.

[0073] S37: Determine whether there is a deletion mark on the data node corresponding to the first message.

[0074] In this embodiment, it is necessary to determine whether there is a deletion mark on the data node corresponding to the second message. If there is a deletion mark on the data node corresponding to the first message, it proves that the second message corresponding to the first message has been sent to the master control end and does not need to be sent again.

[0075] S38: When the first timestamp is earlier than the second timestamp, the time difference does not exceed a preset timeout period, and there is no deletion mark on the data node corresponding to the first message, it is determined that the second message has passed the verification.

[0076] In this embodiment, if the first timestamp is earlier than the second timestamp, the first message and the second message comply with the message initiation and reply logic, and the time difference between the first timestamp and the second timestamp does not exceed the preset timeout period, which means that the message reply has not timed out. If there is no deletion mark on the data node corresponding to the first message, it means that the second message corresponding to the first message has not been sent to the master control end. At this time, the second message passes the verification and can be sent to the master control end.

[0077] In this embodiment, the method further includes: S39: If the second message fails to pass the verification, a timeout message is sent to the master terminal. In this embodiment, when the second message fails to pass the verification, for example, the time difference between the data node corresponding to the second message and the data node corresponding to the first message exceeds the preset timeout period, or there is a deletion mark on the first message, or the timestamp of the message node corresponding to the first message is later than the timestamp of the data node corresponding to the second message, a timeout message is sent to the main control end to notify the main control end that the reply timeout has occurred, and please choose to re-initiate the message or give up sending the message.

[0078] S310: Delete the data node corresponding to the second message and the data node corresponding to the first message.

[0079] In this embodiment, when it is determined that the second message reply has timed out, the data node corresponding to the second message and the data node corresponding to the first message are deleted to release memory space.

[0080] In this embodiment, the time difference between the second message and the first message is determined, and it is determined that there is no deletion mark on the data node corresponding to the second message. When the second message reply times out, the data node corresponding to the second message and the data node corresponding to the first message are deleted, which is conducive to ensuring the timeliness and accuracy of data transmission.

[0081] In another embodiment of the present invention, the method further comprises: S41: When the service processing time corresponding to the first message exceeds a preset processing time, create an independent thread to pre-process the first message.

[0082] In this embodiment, the preset processing time is the maximum time for pre-set business processing. If it exceeds this time, it means that the business processing time corresponding to the first message is long and must be pre-processed before being placed in the linked list, otherwise a reply timeout will inevitably occur.

[0083] In this embodiment, when a first message is received through a corresponding thread, the data corresponding to the first message is read. When the data corresponding to the first message is large and the processing time is long, it is determined that the business processing time corresponding to the message exceeds the preset processing time. At this time, an independent thread is created to pre-process the first message.

[0084] For example, the data corresponding to the first message is a data packet, and an independent thread is created to decompress the data packet.

[0085] S42: Store the data node corresponding to the preprocessed first message into the first global data structure.

[0086] In this embodiment, after pre-processing the data corresponding to the first message, the corresponding memory is invented to store the data node corresponding to the first message in the first global data structure.

[0087] For example, the data corresponding to the first message is a data packet, and the data obtained after decompressing the data packet is stored in the first global data structure.

[0088] S43: Setting a corresponding timeout period for the first message.

[0089] In this embodiment, after the data node corresponding to the pre-processed first message is stored in a linked list, a corresponding timeout period is specified for the first message. This timeout period is different from the preset timeout period. It is the timeout period for data whose business processing time exceeds the preset business processing time, depending on the actual size of the data.

[0090] In this embodiment, when the data corresponding to the received first message is large, preprocessing is performed and a corresponding timeout period is specified to ensure that a timeout reply does not occur when the data is large, while also saving computing resources.

[0091] In another embodiment of the present invention, the step of storing the data node corresponding to the first message in the first global data structure includes: S51: When the first message is received, a data node corresponding to the first message is created.

[0092] In this embodiment, when the slave terminal receives the first message through the corresponding thread, it applies for corresponding memory from the system, stores the data included in the first message in the applied memory space, and creates a data node corresponding to the first message.

[0093] For example, if the data size of the first message is 500 KB, a space of 500 KB is requested from the memory.

[0094] S52: Add the address of the data node corresponding to the first message to the last node in the first global data structure.

[0095] In this embodiment, after the memory space is invented, the address of the invented memory space is determined. The address is the address of the data node corresponding to the first message. The memory address of the data node corresponding to the first message is placed in the last node in the first global data structure, and then each data node in the first global data structure is connected in series.

[0096] For example, refer to Figure 3 , Figure 3 This is a schematic diagram of a linked list structure proposed in one embodiment of the present invention. Figure 3 As shown, the nodes in the linked list are arranged in the order of received messages. A node is created for each message received, and the nodes are connected in series to the head node. The nodes are added in sequence afterwards. When a node is invented, a memory address is obtained. This memory address is stored in the previous node, and the traversal can be started from the head node according to the order in which the addresses are stored.

[0097] In this embodiment, the first message is stored in the first global data structure, and the received messages are first stored uniformly and then processed in sequence, thereby realizing asynchronous processing of messages and saving computing resources.

[0098] In another embodiment of the present invention, Figure 5 , Figure 5 This is a schematic diagram of a message processing flow proposed in one embodiment of the present invention. Figure 5 As shown, a zmq_client-based (zmq client) receives the message sent by the OTA master (OTA MASTER), and then puts the message into the message queue for receiving the message. The message queue sends the message to the global sending linked list (first global data structure), and then reads the node data in the global sending linked list through another thread, puts the data into the message queue for sending the message, and sends the message in the queue to the target device. The target device sends the reply message to another thread for receiving the message, and then the thread puts it into another message queue for receiving the message. The message queue puts the reply message into the global receiving linked list (second global data structure), and then a thread compares the message type of the message sent by the master with the message replied by the target device. When a result is detected or a timeout is reached, a message is sent to the master. When sending a message to the master, the message is first put into the message queue, and then put into the thread that replies to the master, and then sent to the master.

[0099] In the above embodiment of the present invention, during data transmission, messages are uniformly received and transmitted through corresponding threads, which solves the synchronization problem of the three-layer data flow. The master control end does not need to wait for a reply after sending data. Two linked lists are added between the slave control end and the vehicle equipment to store the sent messages and the reply messages. The message transmission is uniformly processed by the thread, which will greatly reduce the network and memory resource consumption when running the OTA function on a resource-constrained embedded platform. After waking up from network hibernation, a large number of messages are blocked by the network. The high-speed issuance of control messages can ensure the normal operation of the business. It does not rely on the joint development of the vehicle equipment that carries the OTA function. The synchronous control of sending and receiving messages is guaranteed by the slave control end, which reduces manpower investment and realizes high-speed and low-resource consumption communication between the vehicle master control end and the vehicle equipment.

[0100] Based on the same inventive concept, an embodiment of the present invention provides a message processing device. Figure 6 , Figure 6 FIG is a schematic diagram of a message processing device 600 proposed in one embodiment of the present invention. Figure 6 As shown, the device includes: A first message receiving module 601 is configured to receive a first message sent by a master terminal; A first message storage module 602 is configured to store the first message in a first global data structure, where the first global data structure includes a plurality of data nodes, each of which stores data of some or all fields in the message; A first message sending module 603, configured to send the first message in the first global data structure to a target device; A second message receiving module 604 is configured to receive a second message sent by the target device, where the second message is a reply message generated by the target device according to the first message; A second message storage module 605 is configured to store the second message in a second global data structure; The second message sending module 606 is configured to send the second message to the master control end if it is determined that a message of the same message type as the second message exists in the first global data structure.

[0101] Optionally, the device further comprises: A first node deletion module, configured to delete the data nodes corresponding to the first message and the second message when the master control end receives the second message; Optionally, the first message storage module includes: A data node creation submodule corresponding to the first message, configured to create a data node corresponding to the first message upon receiving the first message; The memory address is placed in a submodule, which is used to add the address of the data node corresponding to the first message to the last node in the first global data structure.

[0102] Optionally, the device further comprises: a second message reading module, configured to read the second message from the second global data structure; a message type determination module, configured to determine a message type identifier of the second message; A first global data structure traversal module, configured to traverse all data nodes in the first global data structure and determine a message type identifier corresponding to each data node; The same message determination module is used to compare the message type identifier of the data node in the first global data structure with the message type identifier of the second message to determine whether there is a message in the first global data structure with the same message type identifier as the second message.

[0103] Optionally, the device further comprises: A timestamp determination module, configured to obtain a first timestamp of a data node corresponding to the first message and a second timestamp of a data node corresponding to the second message; a time difference determination module, configured to determine whether a time difference between the second timestamp and the first timestamp exceeds a preset timeout period; a mark determination module, configured to determine whether a deletion mark exists on the data node corresponding to the first message; The verification module is used to determine that the second message has passed the verification when the first timestamp is earlier than the second timestamp, the time difference does not exceed the preset timeout period, and there is no deletion mark on the data node corresponding to the first message.

[0104] Optionally, the device further comprises: A timeout message sending module, configured to send a timeout message to the master control end if the second message fails to pass the verification; The second node deletion module is used to delete the data node corresponding to the second message and the data node corresponding to the first message.

[0105] Optionally, the device further comprises: a preprocessing module, configured to create an independent thread to preprocess the first message when the service processing time corresponding to the first message exceeds a preset processing time; A pre-processed message storage module, configured to store the data node corresponding to the pre-processed first message into the first global data structure; A timeout specifying module is used to set a corresponding timeout for the first message.

[0106] Based on the same inventive concept, another embodiment of the present invention provides a readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the message processing method as described in any of the above embodiments of the present invention.

[0107] Based on the same inventive concept, another embodiment of the present invention provides an electronic device, Figure 7 It is a schematic diagram of an electronic device 700 proposed in one embodiment of the present invention, including a memory 702, a processor 701 and a computer program stored in the memory and executable on the processor, wherein the processor implements the message processing method described in any of the above embodiments of the present invention when executed.

[0108] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0109] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0110] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0111] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0112] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0113] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0114] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0115] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0116] The message processing method, apparatus, device and storage medium provided by the present invention are introduced in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.

Claims

1. A message processing method, characterized in that: The method comprises: Receive a first message sent by the master terminal; Storing the first message in a first global data structure, where the global data structure includes a plurality of data nodes, and the data nodes store data of some or all fields in the message; Sending the first message in the first global data structure to a target device; receiving a second message sent by the target device, where the second message is a reply message generated by the target device according to the first message; storing the second message in a second global data structure; In a case where it is determined that a message of the same message type as the second message exists in the first global data structure, the second message is sent to the master control end.

2. The message processing method according to claim 1, wherein: The method further comprises: When the master control end receives the second message, the master control end deletes the data nodes corresponding to the first message and the second message.

3. The message processing method according to claim 1, wherein: Storing the first message in a first global data structure includes: Upon receiving the first message, creating a data node corresponding to the first message; The address of the data node corresponding to the first message is added to the last node in the first global data structure.

4. The message processing method according to claim 1, wherein: Determining that a message having the same message type as the second message exists in the first global data structure includes: reading the second message from the second global data structure; Determining a message type identifier of the second message; Traversing all data nodes in the first global data structure, and determining a message type identifier corresponding to each data node; The message type identifier of the data node in the first global data structure is compared with the message type identifier of the second message to determine whether there is a message with the same message type identifier as the second message in the first global data structure.

5. The message processing method according to claim 4, characterized in that: The method further comprises: Obtain a first timestamp of a data node corresponding to the first message and a second timestamp of a data node corresponding to the second message; Determining whether a time difference between the second timestamp and the first timestamp exceeds a preset timeout period; Determine whether a deletion mark exists on the data node corresponding to the first message; If the first timestamp is earlier than the second timestamp, the time difference does not exceed the preset timeout period, and there is no deletion mark on the data node corresponding to the first message, it is determined that the second message has passed the verification.

6. The message processing method according to claim 5, characterized in that: The method further comprises: If the second message fails to pass the verification, sending a timeout message to the master control end; The data node corresponding to the second message and the data node corresponding to the first message are deleted.

7. The message processing method according to claim 1, characterized in that: The method further comprises: When the service processing time corresponding to the first message exceeds the preset processing time, creating an independent thread to pre-process the first message; Storing the data node corresponding to the preprocessed first message in the first global data structure; A corresponding timeout period is set for the first message.

8. A message processing device, characterized in that: The device comprises: A first message receiving module, configured to receive a first message sent by a master terminal; A first message storage module, configured to store the first message in a first global data structure, wherein the first global data structure includes a plurality of data nodes, and the data nodes store data of some or all fields in the message; A first message sending module, configured to send the first message in the first global data structure to a target device; a second message receiving module, configured to receive a second message sent by the target device, where the second message is a reply message generated by the target device according to the first message; A second message storage module, configured to store the second message in a second global data structure; The second message sending module is configured to send the second message to the main control end when it is determined that a message of the same message type as the second message exists in the first global data structure.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.