Message transmission method and device, equipment and storage medium

By using shared memory in electronic devices to store messages from different transmission protocols, the problem of unreasonable allocation of memory areas is solved, and storage space saving and message transmission stability are achieved.

CN120343104APending Publication Date: 2025-07-18GUANGZHOU XIAOPENG CONNECTIVITY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510703159.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-28
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

In the prior art, using message transmission methods with different transmission protocols requires the allocation of independent memory areas, resulting in increased memory load and unstable message transmission.

Method used

By using shared memory to store messages from different transmission protocols in electronic devices, and multiplexed shared memory to store messages under the SHM and RTPS protocols. The target message includes message header fields and message fields. The content is determined based on the subscription message, and sent to different message subscribers through different transmission protocols.

Benefits of technology

Saves storage space, reduces memory load, avoids additional delay and jitter, and improves the stability of message transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120343104A_ABST
    Figure CN120343104A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a message transmission method and device, equipment and a storage medium, and the method comprises the steps: obtaining a target message according to a subscription message after the subscription message sent to a message subscriber is obtained, the target message comprises a message header field and a message field, the message header field comprises a message header field corresponding to a communication protocol adopted between the electronic equipment and the message subscribing party, the message subscribing party at least comprises the message subscribing party in the electronic equipment and the message subscribing party in communication connection with the electronic equipment, and the content in the message field is determined according to the subscription message; and sending the target message to the message subscriber. The message storage space can be saved, and the stability of message transmission is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to communication technologies, including but not limited to a message transmission method, apparatus, device, and storage medium. Background Art

[0002] In an electronic device that uses multiple transmission methods for message transmission, it is usually necessary to send subscription messages to message subscribers. Among them, for message subscribers on the local device and message subscribers on other devices, different transmission protocols are usually required to achieve transmission.

[0003] In the related art, the transmission methods corresponding to different transmission protocols are respectively implemented by storing data in their respective storage spaces and then performing data transmission. However, due to different requirements of different transmission protocols for data formats and memory management, it is necessary to allocate independent memory areas for each transmission method. This not only increases the memory load but also introduces additional latency and jitter, affecting the size of the memory area and the stability of message transmission. Summary of the Invention

[0004] The message transmission method, apparatus, device, and storage medium provided by the embodiments of the present application are implemented as follows:

[0005] On the one hand, an embodiment of the present application provides a message transmission method. The method is applied to an electronic device and includes:

[0006] After obtaining a subscription message sent to a message subscriber, a target message is obtained according to the subscription message. The target message includes a header field and a message field. The header field includes the header field corresponding to the communication protocol adopted between the electronic device and the message subscriber. The message subscriber includes at least: a message subscriber in the electronic device and a message subscriber communicatively connected to the electronic device. The content in the message field is determined according to the subscription message;

[0007] The target message is sent to the message subscriber.

[0008] On the other hand, an embodiment of the present application further provides a message transmission apparatus. The apparatus is applied to an electronic device, and the electronic device includes a shared memory. The apparatus includes: a storage module and a sending module;

[0009] The storage module is configured to obtain a target message according to a subscription message after obtaining the subscription message sent to a message subscriber. The target message includes a header field and a message field. The header field includes the header field corresponding to the communication protocol adopted between the electronic device and the message subscriber. The message subscriber includes at least: a message subscriber in the electronic device and a message subscriber communicatively connected to the electronic device. The content in the message field is determined according to the subscription message;

[0010] A sending module, configured to send a target message to a message subscriber.

[0011] The computer device provided by an embodiment of the present application includes a memory and a processor. The memory stores a computer program that can run on the processor, and when the processor executes the program, the method of the embodiment of the present application is implemented.

[0012] The computer-readable storage medium provided by an embodiment of the present application stores a computer program thereon, and when the computer program is executed by a processor, the method provided by the embodiment of the present application is implemented.

[0013] In the message transmission method, device, equipment, and storage medium provided by the embodiments of the present application, after obtaining a subscription message sent to a message subscriber, a target message can be obtained according to the subscription message; and the target message is sent to the message subscriber. The target message includes a message header field and a message field. The message header field includes the message header field corresponding to the communication protocol adopted between the electronic device and the message subscriber. The message subscriber includes at least: the message subscriber in the electronic device and the message subscriber communicatively connected to the electronic device. The content in the message field is determined according to the subscription message. Since the target message includes the message header field corresponding to the communication protocol matching the message subscriber, the electronic device can send the same target message to different message subscribers. This method not only saves the storage space of the target message in the electronic device, but also reduces the memory load of the electronic device itself, avoiding the additional latency and jitter introduced by repeated storage, thereby improving the stability of message transmission. Description of the Drawings

[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0015] Figure 1 It is a schematic diagram of an application scenario of the message transmission method provided in the embodiment of the present application;

[0016] Figure 2 It is a schematic diagram of the storage method of the target message in the shared memory provided in the embodiment of the present application;

[0017] Figure 3 It is a schematic flowchart of the message transmission method provided in the embodiment of the present application;

[0018] Figure 4 It is a schematic flowchart of the SHM protocol transmission provided in the embodiment of the present application;

[0019] Figure 5 It is a schematic diagram of the RTPS protocol transmission process provided in the embodiments of the present application;

[0020] Figure 6 It is another schematic diagram of the RTPS protocol transmission process provided in the embodiments of the present application;

[0021] Figure 7 It is another schematic diagram of the storage method of the target message in the shared memory provided in the embodiments of the present application;

[0022] Figure 8 It is a schematic diagram of the process of serializing the subscribed message provided in the embodiments of the present application;

[0023] Figure 9 It is a schematic diagram of the process of deserializing the message fields provided in the embodiments of the present application;

[0024] Figure 10 It is another schematic diagram of the storage method of the target message in the shared memory provided in the embodiments of the present application;

[0025] Figure 11 It is a schematic diagram of the process of using SHM transmission to change the counter field provided in the embodiments of the present application;

[0026] Figure 12 It is a schematic diagram of the process of using RTPS transmission to change the counter field provided in the embodiments of the present application;

[0027] Figure 13 It is an overall interaction schematic diagram of the message transmission method provided in the embodiments of the present application;

[0028] Figure 14 It is an overall process schematic diagram of the message transmission method provided in the embodiments of the present application;

[0029] Figure 15 It is a schematic diagram of the structure of the message transmission device provided in the embodiments of the present application;

[0030] Figure 16 It is a schematic diagram of the structure of the computer device provided in the embodiments of the present application. Detailed implementation manners

[0031] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will further describe the specific technical solutions of the present application in detail with reference to the accompanying drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application but are not used to limit the scope of the present application.

[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terms used herein are for the purpose of describing embodiments of this application only and are not intended to limit this application.

[0033] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with each other without conflict.

[0034] It should be noted that the terms "first / second / third" involved in the embodiments of this application are used to distinguish similar or different objects and do not represent a specific order for the objects. It can be understood that "first / second / third" can be interchanged in a specific order or sequence when allowed, so that the embodiments of this application described here can be implemented in an order other than that illustrated or described here.

[0035] In an electronic device that uses multiple transmission methods for message transmission, the transmission of subscribed messages is usually involved. For example, when a user needs to send a message, it may be necessary to synchronize the message to multiple message subscribers. Depending on different message subscribers, different message transmission methods may be used for message sending. For example, for message subscribers local to the electronic device, the SHM (Shared Memory) protocol can be used for message transmission; for message subscribers on other devices, the RTPS (Real-Time Publish-Subscribe Protocol) protocol can be used for message transmission.

[0036] Next, the application scenarios of the message transmission method provided in the embodiments of this application will be specifically explained.

[0037] Figure 1 For the application scenario schematic diagram of the message transmission method provided in the embodiments of this application, please refer to Figure 1 , which includes an electronic device 100 and multiple message subscribers. Among them, the message subscribers include message subscribers in the electronic device and message subscribers of other electronic devices. For message subscribers within the electronic device, one of the transmission methods can be used to implement message transmission; for message subscribers of other electronic devices, another transmission method can be used to implement message transmission.

[0038] A storage device for storing messages can be set in the electronic device 100. For example, it can be Figure 1 the shared memory shown in, or it can also be other types of storage devices, which are not specifically limited here. Figure 1Taking shared memory as one feasible example, for the messages to be transmitted, they can be stored in the shared memory and then transmitted to multiple message subscribers through the shared memory.

[0039] Among them, the electronic device may include but is not limited to mobile phones, wearable devices (such as smart watches, smart bracelets, smart glasses, etc.), tablet computers, laptop computers, vehicle-mounted terminals, PCs (Personal Computers), etc. The functions implemented by this method can be achieved by a processor in the electronic device calling program code. Of course, the program code can be stored in a computer storage medium. It can be seen that the electronic device at least includes a processor and a storage medium.

[0040] In the embodiment of the present application, the electronic device may be, for example, a vehicle-mounted terminal.

[0041] In the related art, the transmission methods corresponding to different transmission protocols are to store data through their respective storage spaces and then achieve data transmission. However, due to different requirements of different transmission protocols for data formats and memory management, it is necessary to allocate independent memory areas for each transmission method. This not only increases the memory load but also introduces additional latency and jitter, affecting the size of the memory area and the stability of message transmission.

[0042] For example, in the related art, for the transmission methods corresponding to the SHM protocol and the RTPS protocol, the corresponding memory can be set respectively. When performing message transmission, data can be read from the memory corresponding to the SHM protocol and sent to the message subscribers in the electronic device; data can be read from the memory corresponding to the RTPS protocol and sent to the message subscribers of other electronic devices communicatively connected to the electronic device.

[0043] In the message transmission method provided in the embodiment of the present application, messages under two different transmission protocols can be stored simultaneously by multiplexing the shared memory.

[0044] It should be noted that due to different requirements of different transmission protocols for data formats and memory management, in order to adapt to multiple different transmission protocols, it is necessary to adjust the storage method of messages in the shared memory. The following explains the storage method of the target messages in the shared memory provided in the embodiment of the present application.

[0045] Figure 2 For the schematic diagram of the storage method of the target messages in the shared memory provided in the embodiment of the present application, please refer to Figure 2 , Figure 2 The storage method set to adapt to two different transmission protocols, where these two transmission protocols may be, for example, the above-mentioned SHM protocol and RTPS protocol.

[0046] During the process of storing messages in shared memory, the target messages to be stored can include the following three fields: the SHM message header field, the RTPS message header field, and the message field.

[0047] Among them, the SHM message header field is used to carry the header information corresponding to the SHM protocol. Such information can, for example, define the format and structure of the data in the shared memory, and can include information such as data type and size, so as to facilitate the correct parsing of the message by the process. In addition, such information may also include mechanisms for inter-process synchronization, such as mutexes or semaphores, etc., to avoid race conditions and data inconsistency problems. Or, such information may also include information for identifying the version or the last modification time of the data, which can facilitate the process to identify the freshness of the data or perform version control.

[0048] The RTPS header text field is used to carry the header information corresponding to the RTPS protocol. Such information can, for example, identify that the message belongs to the RTPS protocol. Or, identify the version of the RTPS protocol. Or, it can identify the middleware vendor implementing the RTPS protocol and allow the vendor to add specific extensions to the protocol.

[0049] The message field can be the specific subscription message to be transmitted, can be the default storage format, or can also be a specific storage format set according to the needs of the message subscriber, which is not specifically limited here.

[0050] It should be noted that Figure 2 The storage method shown is only one example. During the actual implementation process, corresponding settings can be made according to the protocol fields actually needed, and it is not limited by Figure 2 the format shown.

[0051] After storing using the above storage method, the message transmission method provided in the embodiments of the present application can be implemented. Now, let's explain the specific implementation process of the message transmission method provided in the embodiments of the present application.

[0052] Figure 3 For the flow schematic diagram of the message transmission method provided in the embodiments of the present application, please refer to Figure 3 and the method includes:

[0053] S310: After obtaining the subscription message sent to the message subscriber, obtain the target message according to the subscription message.

[0054] It should be noted that the execution subject of this method can be the above-mentioned electronic device. For example, this step can be executed through the middleware set in the electronic device.

[0055] Optionally, the subscription message may be a message that needs to be sent to the message subscriber. For example, it may be a message input by the user, or it may be a message automatically generated after the user performs an operation, or it may be a message automatically generated by some application programs, etc. There is no specific limitation here, and one or more of these messages may be used as the above-mentioned subscription message according to actual needs.

[0056] There can be multiple types of message subscribers. For example, the message subscribers at least include: message subscribers in the electronic device, and message subscribers communicatively connected to the electronic device.

[0057] Among them, the message subscriber in the electronic device can be, for example, an application program in the electronic device, a specific function module, etc., and there is no specific limitation here; the message subscriber communicatively connected to the electronic device can be another electronic device itself, or it can also be an application program or a specific function module in another electronic device, etc., and there is no specific limitation here.

[0058] After the electronic device obtains the subscription message that needs to be sent to the message subscriber, a target message can be obtained based on the subscription message.

[0059] It should be noted that the target message may include a header field and a message field. Among them, the header field includes the header field corresponding to the communication protocol adopted between the electronic device and the message subscriber.

[0060] It should be noted that the header field corresponding to the communication protocol can be, for example, Figure 2 the SHM header field and the RTPS header field shown in, and the message field can store the above-mentioned subscription message. Among them, the subscription message can be directly used as the message field, or it can also be used as the message field after processing the subscription message, such as: serialization processing, or specific format conversion, etc. There is no specific limitation here.

[0061] In one embodiment, the above-mentioned target message can be obtained by storing the subscription message in a preset format. For example, the subscription message can be stored in a memory space, such as a shared memory, or any preset storage space. There is no specific limitation here.

[0062] The subscription message can be stored in the format of the target message, generate the above-mentioned header field, and store the subscription message in the message field, so that the above-mentioned target message can be obtained.

[0063] In one embodiment, taking the storage of the target message through a shared memory as an example, multiple target messages can be stored in the same shared memory, and each target message can be in accordance with Figure 2It is stored in the storage mode shown in the figure, that is, it is stored in the form of a combination of a message header field and a message field.

[0064] S320: Send the target message to the message subscriber.

[0065] Optionally, after sending the subscription message to the message subscriber, the message subscriber can parse the target message to obtain the above-mentioned subscription message.

[0066] Among them, if the target message is stored in the corresponding storage space, such as the above-mentioned shared memory, the target message can be read from the shared memory first, and then the target message is sent to the message subscriber.

[0067] In one embodiment, for different message subscribers, different message transmission methods can be used to transmit to the corresponding message subscribers.

[0068] Exemplarily, for the message subscriber in the electronic device, the target message can be sent to the message subscriber based on the SHM protocol; for the message subscriber of other devices communicatively connected to the electronic device, the target message can be sent to the message subscriber based on the RTPS protocol.

[0069] Since the target message includes the message header fields corresponding to the above two communication protocols, the transmission of the corresponding communication protocol can be realized, so that the target message can be sent to different message subscribers.

[0070] In the message transmission method provided by the embodiment of the present application, after obtaining the subscription message sent to the message subscriber, the target message can be obtained according to the subscription message; the target message is sent to the message subscriber, where the target message includes a message header field and a message field, and the message header field is the message header field corresponding to the communication protocol adopted between the electronic device and the message subscriber. The message subscribers include: the message subscriber in the electronic device and the message subscriber communicatively connected to the electronic device. The content in the message field is determined according to the subscription message. Since the target message includes the message header field corresponding to the communication protocol matching the message subscriber, the electronic device can send the same target message to different message subscribers. This method not only saves the storage space of the target message in the electronic device, but also reduces the memory load of the electronic device itself, and avoids the additional delay and jitter introduced by repeated storage, thereby improving the stability of message transmission.

[0071] Next, the message transmission method for the SHM protocol and the message transmission method for the RTPS protocol will be explained separately.

[0072] Figure 4 For the flow diagram of the SHM protocol transmission provided in the embodiment of the present application, please refer toFigure 4 The message header fields include: SHM message header fields corresponding to the shared memory SHM protocol; sending the target message to the message subscriber includes: when the message subscriber is the message subscriber in the electronic device, modifying the content of the SHM message header field in the target message to the first preset information, and sending the target message to the message subscriber.

[0073] It should be noted that for the SHM protocol transmission method, the message header fields of the target message may include SHM message header fields, at least one message header field of other transmission methods different from the SHM transmission method, and the above-mentioned message fields.

[0074] Among them, default information can be stored in the shared memory in the SHM message header field. For example, the placeholder with all 0s in the field. During the process of sending the target message, the SHM message header field can be filled. For example, the above-mentioned first preset information can be filled into the SHM message header field, where the first preset information is determined according to the SHM protocol.

[0075] For example: For the SHM message header field, there may be a fixed filling format, and the corresponding first preset information can be filled in according to the corresponding filling format.

[0076] After filling, the filled target message can be sent to the message subscriber. The message subscriber receives the target message and can parse the target message based on the SHM message header field in the target message, so as to obtain the subscribed message required by the message subscriber.

[0077] In the message transmission method provided in the embodiments of the present application, when the message subscriber is the message subscriber in the electronic device, the content of the SHM message header field in the target message can be modified to the first preset information, and the target message can be sent to the message subscriber. Among them, by filling the SHM message header field, the message subscriber can normally parse the target message, so as to stably and accurately implement the transmission of the target message based on the SHM protocol transmission method.

[0078] Figure 5 For the flow diagram of the RTPS protocol transmission provided in the embodiments of the present application, please refer to Figure 5 The message header fields include: RTPS message header fields corresponding to the implementation of the subscription and publication RTPS protocol; sending the target message to the message subscriber includes: when the message subscriber is the message subscriber communicatively connected to the electronic device, modifying the content of the RTPS message header field in the target message to the second preset information, and sending the transmission message to the message subscriber, where the transmission message includes the RTPS message header field and the message field in the target message.

[0079] It should be noted that for the RTPS protocol transmission mode, the message header fields of the target message may include RTPS message header fields, at least one message header field of other transmission modes different from the RTPS transmission mode, and the above-mentioned message fields.

[0080] In one embodiment, since the RTPS protocol is used for message transmission between different electronic devices, a corresponding message sending queue can be set in the electronic device. This queue can be used for data caching. For example, a part of the fields in the target message can be transmitted to the message subscriber.

[0081] Among them, default information can be stored in the shared memory in the RTPS message header fields. For example, the fields are all placeholder 0s. During the process of sending the target message, the RTPS message header fields can be filled. For example, the above-mentioned second preset information can be filled into the SHM message header fields, where the second preset information is determined according to the RTPS protocol.

[0082] For example, the RTPS message header fields can have a fixed filling format, and the corresponding second preset information can be filled in according to the corresponding filling format.

[0083] After filling, a transmission message can be generated according to the filled RTPS message header fields. The transmission message can include: the filled message header fields and the message fields.

[0084] The above-mentioned transmission message can be added to the message sending queue, and the message sending queue sends the transmission message to the message subscriber. The message subscriber can parse the transmission message based on the RTPS message header fields in the transmission message, so as to obtain the subscribed message required by the message subscriber.

[0085] In the message transmission method provided by the embodiments of the present application, when the message subscriber is a message subscriber communicatively connected to the electronic device, the content of the RTPS message header fields in the target message can be modified to the second preset information, and the transmission message is sent to the message subscriber. The transmission message includes the RTPS message header fields and the message fields in the target message. Among them, by filling the RTPS message header fields, the message subscriber can normally parse the transmission message, so that the message subscriber can stably and accurately obtain the subscribed message based on the RTPS protocol transmission mode.

[0086] It should be noted that during the process of message transmission using the RTPS protocol transmission mode, if the length of the message fields in the transmission message is less than the preset length, the transmission message can be directly sent to the message subscriber; if the length of the message fields in the transmission message is greater than or equal to the preset length, the transmission message can be further processed. The specific processing method is as follows:

[0087] Figure 6 This is another schematic diagram of the transmission of the RTPS protocol provided in the embodiments of the present application. Please refer to Figure 6 , and send the transmission message to the message subscriber, including: when the length of the message field of the transmission message is greater than or equal to the preset length, send at least two transmission sub-messages obtained by fragmenting the message field to the message subscriber, and each transmission sub-message includes an RTPS message header field and the fragmented message field.

[0088] It should be noted that the RTPS protocol stipulates the longest transmission length, and this longest transmission length can be limited in the RTPS message header field. For example: assuming that the RTPS message header field indicates that the maximum length of the message field is 64 kb, then for a message field exceeding 64 kb, fragmentation processing can be performed.

[0089] For example: assuming that the length of the message field is 80 kb, the sub-message field of the first fragment obtained by fragmentation can be 64 kb, and the sub-message field of the second fragment can be 16 kb.

[0090] Each transmission sub-message can be obtained by fragmentation, and each transmission sub-message can include an RTPS message header field and the fragmented message field.

[0091] It should be noted that the target message will not be fragmented during the storage process in the shared memory. During the message transmission process, the corresponding fragmentation operation can be completed during the process of obtaining the transmission message from the target message.

[0092] In one embodiment, if the length of the message field is greater than or equal to the preset length, multiple transmission sub-messages can be obtained according to the target message; if the length of the message field is less than the preset length, the corresponding transmission message can be obtained according to the target message.

[0093] In the message transmission method provided by the embodiments of the present application, when the length of the message field of the transmission message is greater than or equal to the preset length, at least two transmission sub-messages obtained by fragmenting the message field can be sent to the message subscriber, and each transmission sub-message includes an RTPS message header field and the fragmented message field. Among them, through the method of fragmenting the message field, the transmission of transmission messages of different lengths can be realized, so that message fields of different lengths can be sent to the message subscriber.

[0094] It should be noted that for the RTPS protocol transmission method, the RTPS message header field can include various information. For example: it can include a main header field and a sub-header field.

[0095] Figure 7This is another schematic diagram of the storage method of the target message provided in the embodiments of this application. Please refer to Figure 7 , the RTPS message header field includes an RTPS main header field and at least one RTPS sub-header field, the message field includes at least one, and each message field corresponds to an RTPS sub-header field.

[0096] Among them, there can be one or more RTPS sub-header fields. After each RTPS sub-header field, a message field can be carried. Figure 7 The left side in [figure reference] shows a schematic diagram of transmitting a message in the case of one sub-header field, and the right side shows a schematic diagram of transmitting a message in the case of two sub-header fields. Among them, the left side can be to transmit message 1, and the right side can be to transmit message 2. Message 2 can include message field 1 and message field 2. In the actual implementation process, more sub-header fields and the message fields corresponding to the sub-header fields can be selected and set according to the actual situation.

[0097] In one embodiment, modifying the content of the RTPS message header field in the target message to the second preset information includes: modifying the content of the RTPS main header field and at least one RTPS sub-header field to the second preset information.

[0098] It should be noted that during the process of filling in the second preset information, the RTPS main header field and each sub-header field can be filled. After filling is completed, a corresponding transmission message can be generated according to the filled RTPS message header field and at least one message field, and the transmission message can be sent to the message subscriber.

[0099] In the message transmission method provided by the embodiments of this application, the content of the RTPS main header field and at least one RTPS sub-header field can be modified to the second preset information. Among them, the RTPS message header field includes an RTPS main header field and at least one RTPS sub-header field, the message field includes at least one, and each message field corresponds to an RTPS sub-header field. By setting the sub-header field, one or more subscription messages can be carried in the target message, so that one or more subscription messages can be sent to the message subscriber at one time, improving the efficiency of message transmission.

[0100] It should be noted that during the process of storing the subscription message in the shared memory, corresponding message processing work can be performed.

[0101] In one embodiment, obtaining the target message according to the subscription message includes: performing serialization processing on the subscription message, and using the serialized subscription message as the message field in the target message.

[0102] It should be noted that the subscription message itself can be stored in the form of the original data structure. During the message transmission process, serialized data is usually required for transmission. Therefore, the subscription message can be serialized and then stored in the shared memory. Subsequently, during the message transmission process, the serialized subscription message can be read from the shared memory and sent to the message subscriber.

[0103] Next, one feasible implementation process for serializing the subscription message in the embodiment of the present application will be explained.

[0104] Figure 8 The flowchart for serializing the subscription message provided in the embodiment of the present application is shown in Figure 8 , the initial format of the subscription message can be a file format, such as XML, JSON, etc. The serialization process can be a process of converting the corresponding file format into a binary sequence, and the subscription message in the file format can be converted into a binary sequence.

[0105] It should be noted that the obtained binary sequence can be the message field in the target message stored in the shared memory.

[0106] In the message transmission method provided by the embodiment of the present application, the subscription message can be serialized, and the serialized subscription message can be used as the message field in the target message. By serializing the subscription message, it is convenient for message storage and transmission, and the transmission efficiency of the subscription message is improved.

[0107] In one embodiment, serializing the subscription message and using the serialized subscription message as the message field in the target message includes:

[0108] When the SHM header field and the RTPS header field are header fields with a fixed length, determine the position of the message field according to the fixed length, and serialize the subscription message to obtain the serialized message field; when the SHM header field and the RTPS header field are header fields with a non-fixed length, determine the actual length of the header field according to the SHM protocol and the RTPS protocol, determine the position of the message field according to the actual length, and serialize the subscription message to obtain the serialized message field.

[0109] It should be noted that for the header fields corresponding to two different communication protocols, they can be set to a fixed length or a non-fixed length. For the header fields with a fixed length, since the length is fixed, the position of the message field can be found according to the corresponding length, and then the subscription message can be serialized to obtain the serialized subscription message. After filling the serialized subscription message into the position corresponding to the message field, the serialized message field can be obtained.

[0110] For the header fields with a non-fixed length, since the length is not fixed, the actual length of the header field can be determined according to the regulations of the SHM protocol and the RTPS protocol. Then, the position of the message field in the target message can be determined according to the actual length, and the subscription message can be serialized to obtain the serialized subscription message. After filling the serialized subscription message into the position corresponding to the message field, the serialized message field can be obtained.

[0111] In the message transmission method provided by the embodiments of the present application, when the SHM header field and the RTPS header field are header fields with a fixed length, the position of the message field can be determined according to the fixed length, and the subscription message can be serialized to obtain the serialized message field; when the SHM header field and the RTPS header field are header fields with a non-fixed length, the actual length of the header field can be determined according to the SHM protocol and the RTPS protocol, the position of the message field can be determined according to the actual length, and the subscription message can be serialized to obtain the serialized message field. Among them, for the header fields with a fixed length and the header fields with a non-fixed length, the position of the message field can be determined in a corresponding manner, so that after filling the serialized subscription message into the position of the message field, the serialized message field can be quickly obtained.

[0112] It should be noted that for the SHM protocol transmission mode, since the receiving party is also the message subscriber in the electronic device, after receiving the target message, the message subscriber can deserialize the message field in the target message.

[0113] In one embodiment, after sending the target message to the message subscriber, the method further includes: when the message subscriber is the message subscriber in the electronic device, the message subscriber deserializes the message field according to the SHM header field to obtain the subscription message.

[0114] Figure 9 For the flow diagram of deserializing the message field provided in the embodiments of the present application, please refer to Figure 9, the deserialization process can be a process of converting a binary sequence into a corresponding file format, that is, converting the message field back to the original format of the subscribed message through deserialization, so that the message subscriber can obtain the subscribed message.

[0115] Correspondingly, for message subscribers on other devices, the message subscriber can also deserialize the message field according to the RTPS packet header field to obtain the required subscribed message.

[0116] In the message transmission method provided by the embodiments of the present application, when the message subscriber is a message subscriber in an electronic device, the message subscriber can deserialize the message field according to the SHM packet header field to obtain the subscribed message. Among them, through the deserialization process of the message field, the message subscriber can accurately receive the subscribed message.

[0117] It should be noted that for the target message stored in the shared memory, in addition to Figure 2 and Figure 7 the two storage methods shown in the above, other data storage methods can also be adopted, for example, other fields can be added.

[0118] Figure 10 For another schematic diagram of the storage method of the target message in the shared memory provided by the embodiments of the present application, please refer to Figure 10 , the target message further includes a counter field, and the counter field is used to identify the message transmission status of the target message in the shared memory. The message transmission status includes: a transmissible state and a non-transmissible state.

[0119] It should be noted that the counter field can be a one-bit binary field, that is to say, the counter field can include two states of 0 and 1. Among them, 0 indicates that the target message is in a transmissible state in the shared memory; 1 indicates that the target message is in a non-transmissible state in the shared memory.

[0120] Among them, the counter field can be set as the first field of the target message. During the process of reading the shared memory, it can be determined whether the target message can be transmitted according to the status indicated by the counter field in the target message.

[0121] For example: if the counter field is read as 0, it means that the target message is in a transmissible state, and the target message can be sent to the message subscriber by using the corresponding transmission method; if the counter field is read as 1, it means that the target message is in a non-transmissible state, and the target message cannot be sent to the message subscriber by using the corresponding transmission method.

[0122] It should be noted that the states represented by 0 and 1 are only one feasible example. In the actual implementation process, 1 can also represent the transmittable state and 0 can represent the non-transmittable state, and no specific restrictions are made here.

[0123] In the message transmission method provided by the embodiments of the present application, the message transmission state of the target message in the shared memory can be identified through the counter field, so as to facilitate determining whether the target message can be transmitted during the transmission of the target message, thereby improving the message transmission efficiency.

[0124] Next, the corresponding conditions for the change of the counter field in the message transmission method provided by the embodiments of the present application will be described separately.

[0125] In one embodiment, the method further includes: after storing the target message in the shared memory, setting the counter field to indicate the transmittable state; after sending the target message to the message subscriber, changing the counter field from indicating the transmittable state to indicating the non-transmittable state.

[0126] It should be noted that during the process of generating the target message, the counter field can be set to indicate the transmittable state. For example: it can be set to the transmittable state after serializing the subscription message and obtaining the filled content in the message field, that is, set to 0.

[0127] Optionally, after generating any target message, the initial state of the counter field in the target message can be set to indicate the transmittable state.

[0128] It should be noted that after sending the target message to the message subscriber, the counter field can be changed from indicating the transmittable state to indicating the non-transmittable state.

[0129] For the SHM protocol transmission mode, the status of the counter field can be changed after sending the target message to the message subscriber; for the RTPS protocol transmission mode, the status of the counter field can be changed after adding the target message to the message sending queue and generating the transmission message.

[0130] In the message transmission method provided by the embodiments of the present application, after storing the target message in the shared memory, the counter field is set to indicate the transmittable state; after sending the target message to the message subscriber, the counter field is changed from indicating the transmittable state to indicating the non-transmittable state. Among them, by setting the message transmission state indicated by the counter field and changing the message transmission state indicated by the counter field after meeting the corresponding conditions, the state of each target message can be recorded more accurately, thereby improving the message transmission efficiency.

[0131] The following explains another feasible implementation manner for changing the message transmission status provided in the embodiments of the present application.

[0132] Figure 11 For the schematic flowchart of the process of changing the counter field by using SHM transmission provided in the embodiments of the present application, please refer to Figure 11 , the method further includes: when the message subscriber is the message subscriber in the electronic device, after the message subscriber deserializes the message field, changing the counter field from indicating the non-transmissible state to indicating the transmissible state.

[0133] It should be noted that when the message subscriber is the message subscriber in the electronic device, in the case of using the SHM protocol transmission mode, after the target message is sent to the message subscriber through the SHM transmission mode, the message transmission state indicated by the counter field in the corresponding target message in the shared memory can be changed to the non-transmissible state; after the message subscriber receives the target message and performs the deserialization process on the message field, the message transmission state indicated by the counter field in the corresponding target message in the shared memory can be changed to the transmissible state.

[0134] Exemplarily: after the target message is sent to the message subscriber, the counter field can be changed from 0 to 1; after the message subscriber performs the deserialization process, the counter field can be changed from 1 to 0.

[0135] Among them, since the message subscriber is also an application program in the electronic device, the electronic device can determine the timing when the message subscriber completes the deserialization process, so as to realize the change of the message transmission state indicated by the counter field in the target message.

[0136] In the message transmission method provided in the embodiments of the present application, when the message subscriber is the message subscriber in the electronic device, after the message subscriber deserializes the message field, the counter field can be changed from indicating the non-transmissible state to indicating the transmissible state. Among them, by changing the message transmission state indicated by the counter field after meeting the corresponding conditions, the state of each target message during the transmission of the target message through the SHM protocol transmission mode can be recorded more accurately, thereby improving the message transmission efficiency.

[0137] The following explains another feasible implementation manner for changing the message transmission status provided in the embodiments of the present application.

[0138] Figure 12 For the schematic flowchart of the process of changing the counter field by using RTPS transmission provided in the embodiments of the present application, please refer to Figure 12, the method further includes: when the message subscriber is a message subscriber communicatively connected to the electronic device, after the message sending queue of the electronic device is emptied, changing the counter field from indicating a non-transmittable state to indicating a transmittable state.

[0139] It should be noted that when the message subscriber is a message subscriber communicatively connected to the electronic device, in the RTPS protocol transmission mode, the transmission message can be obtained from the target message according to the RTPS transmission mode and added to the message sending queue. After adding the transmission message to the message sending queue, the message transmission state indicated by the counter field in the corresponding target message in the shared memory can be changed to a non-transmittable state; after clearing the cache in the message sending queue, the message transmission state indicated by the counter field in the corresponding target message in the shared memory can be changed to a transmittable state.

[0140] Exemplarily: after sending the target message to the message subscriber, the counter field can be changed from 0 to 1; after the message subscriber performs deserialization processing, the counter field can be changed from 1 to 0.

[0141] Among them, since the message subscriber is not an application program in the electronic device, the electronic device can implement the change of the message transmission state indicated by the counter field in the target message according to the timing of adding the transmission message to the message sending queue.

[0142] In the message transmission method provided by the embodiments of the present application, when the message subscriber is a message subscriber communicatively connected to the electronic device, after the message sending queue of the electronic device is emptied, the counter field can be changed from indicating a non-transmittable state to indicating a transmittable state. Among them, by changing the message transmission state indicated by the counter field after meeting the corresponding conditions, the state of each target message during the transmission of the target message through the RTPS protocol transmission mode can be recorded more accurately, thereby improving the message transmission efficiency.

[0143] Next, an interaction relationship diagram is used to explain the feasible implementation process of the message transmission method provided in the embodiments of the present application.

[0144] Figure 13 This is the overall interaction schematic diagram of the message transmission method provided in the embodiments of the present application. Please refer to Figure 13 , Figure 13The process shown is the interaction process of the message transmission method provided in the embodiment of the present application. In this scenario, an electronic device and multiple message subscribers may be included. A shared memory may be set in the electronic device. For the message subscribers in the electronic device, the target message stored in the shared memory may be sent to the message subscriber through the SHM protocol; for the message subscribers of other electronic devices, the transmission message may be obtained according to the target message through the RTPS protocol, and the transmission message may be added to the message sending queue, and then the transmission message may be sent to the message subscriber through the message sending queue.

[0145] Next, the overall implementation process of the message transmission method provided in the embodiment of the present application will be explained.

[0146] Figure 14 It is a schematic diagram of the overall process of the message transmission method provided in the embodiment of the present application. Please refer to Figure 14 , and the method includes:

[0147] After the subscription message is generated, memory can be applied for the subscription message, and after the subscription message is serialized, it can be filled into the message field of the target message to obtain the corresponding target message. In the process of applying for memory, it can be determined whether each target message in the shared memory is in a transmissible state. If so, the content of the corresponding target message can be recycled, and the corresponding memory can be allocated to the new target message.

[0148] Different transmission methods can be adopted according to different message subscribers. For the message subscribers in the electronic device, the SHM protocol transmission method can be used to send the target message to the message subscriber. After the message subscriber receives the target message, the count of the counter field can be increased to change the message transmission state indicated by the counter field to non-transmissible state; after the message subscriber performs deserialization, the subscription message can be obtained, and the count of the counter field can be decreased to change the message transmission state indicated by the counter field to transmissible state.

[0149] For the message subscribers of other electronic devices, the RTPS protocol transmission method can be used to obtain the transmission message according to the target message, add the transmission message to the message sending queue, and increase the count of the counter field to change the message transmission state indicated by the counter field to non-transmissible state; after the message queue clears the cache, the count of the counter field can be decreased to change the message transmission state indicated by the counter field to transmissible state, and the message subscriber can receive the transmission message and perform deserialization processing to obtain the subscription message.

[0150] Among them, the subscription message can be, for example, an IDL message (Interface Definition Language Message).

[0151] In the embodiments of the present application, the shared memory can be managed in a manner of intelligent memory management, dynamically adjusting the memory block size and allocation strategy, thereby reducing memory fragmentation, and garbage collection can be automatically performed to periodically scan and recycle unused memory blocks.

[0152] For the counter field provided in the embodiments of the present application, the mark-sweep algorithm can also be used to replace this field, which can reduce the overhead of counter updates.

[0153] During the process of message transmission, in addition to directly transmitting the target message or the transmission message, the content to be transmitted can also be compressed to obtain a message that occupies less space, thereby improving the transmission efficiency.

[0154] In addition to the transmission methods of the two communication protocols exemplified in the embodiments of the present application, a lightweight transmission protocol can also be designed to reduce protocol overhead and improve transmission efficiency. For example, a custom transmission protocol can be designed according to specific application scenarios to optimize data transmission performance.

[0155] It should be understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above flowcharts may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.

[0156] Based on the foregoing embodiments, the embodiments of the present application provide a message transmission device, which includes each module included and each unit included in each module, and can be implemented by a processor; of course, it can also be implemented by specific logic circuits; during implementation, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.

[0157] Figure 15 For the structural schematic diagram of the message transmission device provided in the embodiments of the present application, please refer to Figure 15 This device includes: a storage module 1510 and a sending module 1520;

[0158] A storage module 1510, configured to, after obtaining a subscription message sent to a message subscriber, obtain a target message according to the subscription message, where the target message includes a message header field and a message field, the message header field includes a message header field corresponding to a communication protocol adopted between the electronic device and the message subscriber, and the message subscriber includes at least: a message subscriber in the electronic device, and a message subscriber communicatively connected to the electronic device, and the content in the message field is determined according to the subscription message;

[0159] A sending module 1520, configured to send the target message to the message subscriber.

[0160] In one embodiment, the message header field includes: an SHM message header field corresponding to the shared memory SHM protocol; the sending module 1520 is specifically configured to, when the message subscriber is a message subscriber in the electronic device, modify the content of the SHM message header field in the target message to a first preset message, and send the target message to the message subscriber, where the first preset message is determined according to the SHM protocol.

[0161] In one embodiment, the message header field includes: an RTPS message header field corresponding to the implementation of the publish-subscribe RTPS protocol; the sending module 1520 is specifically configured to, when the message subscriber is a message subscriber communicatively connected to the electronic device, modify the content of the RTPS message header field in the target message to a second preset message, and send the transmission message to the message subscriber, where the transmission message includes the RTPS message header field and the message field in the target message, and the second preset message is determined according to the RTPS protocol.

[0162] In one embodiment, the RTPS message header field includes an RTPS main header field and at least one RTPS sub-header field, the message field includes at least one, and each message field corresponds to an RTPS sub-header field; the sending module 1520 is specifically configured to modify the content of the RTPS main header field and at least one RTPS sub-header field to a second preset message.

[0163] In one embodiment, the sending module 1520 is specifically configured to, when the length of the message field in the transmission message is greater than or equal to a preset length, send at least two transmission sub-messages obtained by fragmenting the message field to the message subscriber, and each transmission sub-message includes an RTPS message header field and the fragmented message field.

[0164] In one embodiment, the storage module 1510 is specifically configured to perform serialization processing on the subscription message, and use the serialized subscription message as the message field in the target message.

[0165] In one embodiment, the storage module 1510 is specifically configured to, when the SHM message header field and the RTPS message header field are fixed-length header fields, determine the position of the message field according to the fixed length and perform serialization processing on the subscription message to obtain the serialized message field; when the SHM message header field and the RTPS message header field are non-fixed-length header fields, determine the actual length of the header field according to the SHM protocol and the RTPS protocol, determine the position of the message field according to the actual length, and perform serialization processing on the subscription message to obtain the serialized message field.

[0166] In one embodiment, the apparatus further includes a receiving module. The receiving module is configured to, when the message subscriber is the message subscriber in the electronic device, perform deserialization processing on the message field by the message subscriber according to the SHM message header field to obtain the subscription message.

[0167] In one embodiment, the apparatus further includes a counting module. The counting module is used when the target message further includes a counter field, and the counter field is used to identify the message transmission state of the target message in the shared memory. The message transmission states include: a transmissible state and a non-transmissible state.

[0168] In one embodiment, the counting module is specifically configured to, after storing the target message in the shared memory, set the counter field to indicate the transmissible state; after sending the target message to the message subscriber, change the counter field from indicating the transmissible state to indicating the non-transmissible state.

[0169] In one embodiment, the counting module is further configured to, when the message subscriber is the message subscriber in the electronic device, after the message subscriber performs deserialization on the message field, change the counter field from indicating the non-transmissible state to indicating the transmissible state.

[0170] In one embodiment, the counting module is further configured to, when the message subscriber is the message subscriber communicatively connected to the electronic device, after the message sending queue of the electronic device is emptied, change the counter field from indicating the non-transmissible state to indicating the transmissible state.

[0171] In the message transmission device provided by the embodiments of the present application, after obtaining a subscription message sent to a message subscriber, a target message can be obtained according to the subscription message; and the target message is sent to the message subscriber, where the target message includes a message header field and a message field. The message header field includes the message header field corresponding to the communication protocol adopted between the electronic device and the message subscriber. The message subscriber includes at least: the message subscriber in the electronic device and the message subscriber communicatively connected to the electronic device. The content in the message field is determined according to the subscription message. Since the target message includes the message header field corresponding to the communication protocol matching the message subscriber, the electronic device can send the same target message to different message subscribers. This method not only saves the storage space of the target message in the electronic device, but also reduces the memory load of the electronic device itself, and avoids the additional latency and jitter introduced by repeated storage, thereby improving the stability of message transmission.

[0172] The description of the above device embodiments is similar to that of the above method embodiments and has similar beneficial effects to the method embodiments. For the technical details not disclosed in the device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.

[0173] It should be noted that in the embodiments of the present application Figure 15 The division of the modules in the shown message transmission device is illustrative, and is only a logical function division. In actual implementation, there may be other division methods. In addition, each functional unit in the various embodiments of the present application may be integrated into one processing unit, may exist separately physically, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware, or in the form of a software functional unit, or in the form of a combination of software and hardware.

[0174] It should be noted that in the embodiments of the present application, if the above method is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the related technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing an electronic device to execute all or part of the methods described in the various embodiments of the present application. The foregoing storage medium includes: various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disc that can store program codes. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0175] Figure 16The following is a schematic structural diagram of the computer device provided in the embodiments of the present application. Please refer to Figure 16 , the embodiments of the present application provide a computer device, which may be the above-mentioned electronic device, and its internal structural diagram may be as shown in Figure 16 . The computer device includes a processor 1620, a memory, and a network interface 1640 connected through a system bus 1610. Among them, the processor 1620 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium 1631 and an internal memory 1632. The non-volatile storage medium 1631 stores an operating system, a computer program, and a database. The internal memory 1632 provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium 1631. The database of the computer device is used to store data. The network interface 1640 of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the above method is implemented.

[0176] The embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the method provided in the above embodiments are implemented.

[0177] The embodiments of the present application provide a computer program product containing instructions. When it runs on a computer, the computer is caused to execute the steps in the method provided in the above method embodiments.

[0178] Those skilled in the art can understand that Figure 16 the structure shown in is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.

[0179] In one embodiment, the message transmission device provided in the present application may be implemented in the form of a computer program, and the computer program can run on a computer device as shown in Figure 16 . Each program module constituting the device may be stored in the memory of the computer device. The computer program constituted by each program module causes the processor to execute the steps in the methods of the various embodiments of the present application described in this specification.

[0180] It should be noted here that: the descriptions of the above storage medium and device embodiments are similar to the descriptions of the above method embodiments, and have beneficial effects similar to those of the method embodiments. For the technical details not disclosed in the storage medium, storage medium and device embodiments of the present application, please refer to the descriptions of the method embodiments of the present application for understanding.

[0181] It should be understood that the "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the "in one embodiment" or "in an embodiment" or "in some embodiments" that appear throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the magnitudes of the sequence numbers of the above processes do not mean the sequence of execution. The execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application. The sequence numbers of the embodiments of the present application above are only for description and do not represent the superiority or inferiority of the embodiments. The descriptions of the above embodiments tend to emphasize the differences between the embodiments, and their similarities or similarities can be referred to each other. For the sake of brevity, they will not be repeated herein.

[0182] As used herein, the term "and / or" is merely a description of the relationship between associated objects, indicating that there can be three relationships. For example, object A and / or object B can mean: object A exists alone, object A and object B exist simultaneously, and object B exists alone.

[0183] It should be noted that, as used herein, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article or apparatus comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or apparatus comprising the element.

[0184] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The above-described embodiments are merely illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there can be other division methods, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling or communication connection between the components shown or discussed with each other can be through some interfaces, and the indirect coupling or communication connection of the devices or modules can be electrical, mechanical or other forms.

[0185] The modules described above as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network elements; some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0186] In addition, each functional module in the embodiments of the present application may be all integrated in a processing unit, or each module may be separately used as a unit, or two or more modules may be integrated in a unit; the above-mentioned integrated modules may be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.

[0187] Those of ordinary skill in the art can understand that all or part of the steps to implement the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including the above method embodiments; and the foregoing storage medium includes: removable storage devices, read-only memory (ROM), magnetic disks or optical disks, etc., all kinds of media that can store program codes.

[0188] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the related technology can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable an electronic device to execute all or part of the methods described in the various embodiments of the present application. And the foregoing storage medium includes: removable storage devices, ROM, magnetic disks or optical disks, etc., all kinds of media that can store program codes.

[0189] The methods disclosed in the several method embodiments provided in the present application can be arbitrarily combined without conflict to obtain new method embodiments.

[0190] The features disclosed in the several product embodiments provided in the present application can be arbitrarily combined without conflict to obtain new product embodiments.

[0191] The features disclosed in the several method or device embodiments provided in the present application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.

[0192] As described above, it is only the implementation mode of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed by this application can easily think of changes or substitutions, which should all be covered within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims described.

Claims

1. A message transmission method, characterized in that, The method is applied to an electronic device, and the method includes: After obtaining a subscription message sent to a message subscriber, a target message is obtained according to the subscription message. The target message includes a header field and a message field. The header field includes a header field corresponding to a communication protocol adopted between the electronic device and the message subscriber. The message subscriber includes at least: a message subscriber in the electronic device and a message subscriber communicatively connected to the electronic device. The content in the message field is determined according to the subscription message; Send the target message to the message subscriber.

2. The method according to claim 1, wherein The header field includes: an SHM header field corresponding to the shared memory SHM protocol; The sending the target message to the message subscriber includes: When the message subscriber is a message subscriber in the electronic device, modify the content of the SHM header field in the target message to a first preset message, and send the target message to the message subscriber. The first preset message is determined according to the SHM protocol.

3. The method according to claim 1, wherein The header field includes: an RTPS header field corresponding to the implementation of the publish-subscribe RTPS protocol; The sending the target message to the message subscriber includes: When the message subscriber is a message subscriber communicatively connected to the electronic device, modify the content of the RTPS header field in the target message to a second preset message, and send a transmission message to the message subscriber. The transmission message includes the RTPS header field and the message field in the target message. The second preset message is determined according to the RTPS protocol.

4. The method according to claim 3, wherein The RTPS header field includes an RTPS main header field and at least one RTPS sub-header field. The message field includes at least one, and each message field corresponds to an RTPS sub-header field; The modifying the content of the RTPS header field in the target message to a second preset message includes: Modify the content of the RTPS main header field and at least one RTPS sub-header field to a second preset message.

5. The method according to claim 3, wherein The sending the transmission message to the message subscriber includes: When the length of the message field in the transmission message is greater than or equal to a preset length, send at least two transmission sub-messages obtained by fragmenting the message field to the message subscriber. Each transmission sub-message includes an RTPS header field and a fragmented message field.

6. The method according to claim 1, characterized in that, The obtaining the target message according to the subscription message includes: Perform serialization processing on the subscription message, and use the serialized subscription message as the message field in the target message.

7. The method according to claim 6, wherein The performing serialization processing on the subscription message and using the serialized subscription message as the message field in the target message includes: When the SHM header field and the RTPS header field are header fields of a fixed length, determine the position of the message field according to the fixed length, and perform serialization processing on the subscription message to obtain a serialized message field; When the SHM message header field and the RTPS message header field are variable-length header fields, determine the actual length of the message header field according to the SHM protocol and the RTPS protocol, determine the position of the message field according to the actual length, and perform serialization processing on the subscription message to obtain the serialized message field.

8. The method according to claim 7, wherein After sending the target message to the message subscriber, the method further includes: When the message subscriber is the message subscriber in the electronic device, the message subscriber deserializes the message field according to the SHM message header field to obtain the subscription message.

9. The method according to claim 1, characterized in that, The target message is stored in the shared memory of the electronic device. The target message further includes a counter field, and the counter field is used to identify the message transmission status of the target message in the shared memory. The message transmission status includes: a transmissible state and a non-transmissible state.

10. The method according to claim 9, characterized in that, The method further includes: After storing the target message in the shared memory, set the counter field to indicate the transmissible state; After sending the target message to the message subscriber, change the counter field from indicating the transmissible state to indicating the non-transmissible state.

11. The method according to claim 10, wherein, The method further includes: When the message subscriber is the message subscriber in the electronic device, after the message subscriber deserializes the message field, change the counter field from indicating the non-transmissible state to indicating the transmissible state.

12. The method according to claim 10, characterized in that, The method further includes: When the message subscriber is the message subscriber communicatively connected to the electronic device, after the message sending queue of the electronic device is emptied, change the counter field from indicating the non-transmissible state to indicating the transmissible state.

13. A message transmission device, characterized in that, The apparatus is applied to an electronic device, and the apparatus includes: a storage module and a sending module; The storage module is configured to, after obtaining a subscription message sent to a message subscriber, obtain a target message according to the subscription message. The target message includes a message header field and a message field. The message header field includes the message header field corresponding to the communication protocol adopted between the electronic device and the message subscriber. The message subscriber includes at least: the message subscriber in the electronic device and the message subscriber communicatively connected to the electronic device. The content in the message field is determined according to the subscription message; The sending module is configured to send the target message to the message subscriber.

14. A computer device, comprising a memory and a processor, the memory storing a computer program that can run on the processor, characterized in that, When the processor executes the program, the steps of the method according to any one of claims 1 to 12 are implemented.

15. 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 12 is implemented.