Message forwarding method and device

By obtaining the forwarding instruction and the preset message ID, the forwarding flag bit and the modification flag bit are determined, and the message is forwarded directly, which solves the problem of low message forwarding efficiency and achieves a more efficient forwarding process.

CN118612306APending Publication Date: 2024-09-06BEIJING JINGWEI HIRAIN TECH CO INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410826253.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

In the existing technology, serialization and deserialization are required during message forwarding, which results in large computing resource usage and time consumption, and low efficiency.

Method used

By obtaining the forwarding instruction and the preset message ID, the forwarding flag bit and the modification flag bit are determined, and the message to be forwarded is decided whether to modify and forward it, and the sending function is directly called for forwarding, avoiding the serialization and deserialization process.

Benefits of technology

It improves the efficiency of message forwarding and reduces the occupation of computing resources and time consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118612306A
    Figure CN118612306A
Patent Text Reader

Abstract

The invention discloses a message forwarding method and device, and the method comprises the steps: obtaining a forwarding instruction in an instruction set, and a message ID of a preset message pre-stored in a structural body when a to-be-forwarded message sent by a bus is received; when the message ID of the to-be-forwarded message is consistent with the message ID of the preset message, judging whether a forwarding flag bit contained in the forwarding instruction is a preset numerical value or not; if the forwarding flag bit contained in the forwarding instruction is the preset numerical value, judging whether a modification flag bit contained in the forwarding instruction is the preset numerical value or not; if the modification flag bit contained in the forwarding instruction is a preset numerical value, modifying the message to be forwarded; and calling a sending function to forward the modified message to be forwarded. When the to-be-forwarded message is received, the to-be-forwarded message is forwarded or directly forwarded after being modified according to the forwarding rule, and the to-be-forwarded message does not need to be forwarded after being serialized and deserialized, so that the message forwarding efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a message forwarding method and device. Background Art

[0002] At present, modern automobiles generally use multiple Electronic Control Units (ECUs) for data exchange and communication. In order to achieve communication between different ECUs, data exchange can be performed between different ECUs in some specific ways.

[0003] At present, middleware or message queues are generally used to forward messages. The sender encapsulates the message to be forwarded into a message and sends it to the message queue. The middleware or message queue will receive the message sent by the sender and store the message in the message queue. The receiver will pull the message from the message queue. However, during the message sending and receiving process, the message needs to be serialized and deserialized, that is, the message is converted into the message format, and the message is converted back to the original message format at the receiving end. This process involves encoding and decoding of the message, which may take up a certain amount of computing resources and time, resulting in low efficiency in message forwarding.

[0004] Therefore, how to improve the efficiency of message forwarding has become an urgent problem to be solved in this field. Summary of the invention

[0005] The present application provides a message forwarding method and device, the purpose of which is to improve the message forwarding efficiency.

[0006] In order to achieve the above objectives, this application provides the following technical solutions:

[0007] A message forwarding method, applied to a lower computer, comprising:

[0008] When receiving a message to be forwarded sent by the bus, obtaining a forwarding instruction in the instruction set and a message ID of a preset message pre-stored in the structure;

[0009] When the message ID of the message to be forwarded is consistent with the message ID of the preset message, determining whether the forwarding flag bit included in the forwarding instruction is a preset value;

[0010] If the forwarding flag bit included in the forwarding instruction is the preset value, determining whether the modification flag bit included in the forwarding instruction is the preset value;

[0011] If the modification flag bit included in the forwarding instruction is the preset value, modifying the message to be forwarded to obtain a modified message to be forwarded;

[0012] The sending function is called to forward the modified message to be forwarded.

[0013] Optionally, when receiving a message to be forwarded sent by the bus, obtaining a forwarding instruction in the instruction set and a message ID of a preset message pre-stored in the structure, includes:

[0014] When a message to be forwarded sent by the bus is received, a read interrupt is triggered;

[0015] When the read interrupt is triggered, a message ID of a preset message pre-stored in a structure is selected from a channel corresponding to the read interrupt.

[0016] Optionally, the modifying the message to be forwarded to obtain a modified message to be forwarded includes:

[0017] Obtaining a modification field contained in the forwarding instruction;

[0018] The message to be forwarded is modified according to the modification field to obtain a modified message to be forwarded.

[0019] Optionally, when receiving a message to be forwarded sent by the bus, before obtaining the forwarding instruction in the instruction set and the message ID of the preset message pre-stored in the structure, the method further includes:

[0020] When receiving the forwarding instruction sent by the host computer, the write interrupt is triggered;

[0021] When the write interrupt is triggered, obtaining an instruction set in the channel corresponding to the write interrupt;

[0022] Determining whether there is a historical forwarding instruction in the instruction set;

[0023] If the historical forwarding instruction exists in the instruction set, comparing the instruction ID of the historical forwarding instruction with the instruction ID of the forwarding instruction;

[0024] If the instruction ID of the historical forwarding instruction is consistent with the instruction ID of the forwarding instruction, determining whether the forwarding flag bit included in the forwarding instruction is a preset value;

[0025] If the forwarding flag bit included in the forwarding instruction is the preset value, determining whether the modification flag bit included in the forwarding instruction is the preset value;

[0026] If the modification flag bit included in the forwarding instruction is the preset value, the historical forwarding instruction is updated according to the forwarding instruction to obtain an updated forwarding instruction;

[0027] The updated forwarding instruction is stored in the instruction set.

[0028] Optionally, after determining whether there is a historical forwarding instruction in the instruction set, the method further includes:

[0029] If the historical forwarding instruction does not exist in the instruction set, the forwarding instruction is stored in the instruction set.

[0030] A message forwarding method, applied to a host computer, comprising:

[0031] When receiving the configuration information, creating a data structure according to the message in the configuration information;

[0032] Mapping the data structure into a structure;

[0033] The structure is assigned a value according to the configuration information to obtain a forwarding instruction, and the forwarding instruction is sent to a lower computer.

[0034] Optionally, assigning a value to the structure according to the configuration information to obtain a forwarding instruction includes:

[0035] Obtain the message ID, source channel, target channel, forwarding information and modification information in the configuration information;

[0036] Assigning values ​​to the structure according to the message ID, the source channel and the target channel to obtain an assigned structure;

[0037] When the forwarding information indicates that the message is to be forwarded, the forwarding flag in the assigned structure is set to a preset value to obtain a set structure;

[0038] When the modification information indicates that the message is to be modified, the modification flag in the set structure is set to the preset value to obtain a forwarding instruction.

[0039] A message forwarding device, applied to a lower computer, comprising:

[0040] An acquisition unit, configured to acquire, when receiving a message to be forwarded sent by the bus, a forwarding instruction in the instruction set and a message ID of a preset message pre-stored in the structure;

[0041] A first judgment unit, configured to judge whether the forwarding flag bit included in the forwarding instruction is a preset value when the message ID of the message to be forwarded is consistent with the message ID of the preset message;

[0042] a second judgment unit, configured to judge whether the modification flag bit included in the forwarding instruction is the preset value if the forwarding flag bit included in the forwarding instruction is the preset value;

[0043] A modification unit, configured to modify the message to be forwarded to obtain a modified message to be forwarded if the modification flag bit included in the forwarding instruction is the preset value;

[0044] The forwarding unit is used to call the sending function to forward the modified message to be forwarded.

[0045] Optionally, the acquiring unit is specifically used for:

[0046] When a message to be forwarded sent by the bus is received, a read interrupt is triggered;

[0047] When the read interrupt is triggered, a message ID of a preset message pre-stored in a structure is selected from a channel corresponding to the read interrupt.

[0048] A message forwarding device, applied to a host computer, comprising:

[0049] A creating unit, configured to create a data structure according to a message in the configuration information when the configuration information is received;

[0050] A mapping unit, used for mapping the data structure into a structure;

[0051] The assignment unit is used to assign a value to the structure according to the configuration information, obtain a forwarding instruction, and send the forwarding instruction to the lower computer.

[0052] The technical solution provided by the present application, when receiving a message to be forwarded sent by the bus, obtains the forwarding instruction in the instruction set and the message ID of the preset message pre-stored in the structure; when the message ID of the message to be forwarded is consistent with the message ID of the preset message, judges whether the forwarding flag bit contained in the forwarding instruction is a preset value; if the forwarding flag bit contained in the forwarding instruction is a preset value, judges whether the modification flag bit contained in the forwarding instruction is a preset value; if the modification flag bit contained in the forwarding instruction is a preset value, the message to be forwarded is modified; and the sending function is called to forward the modified message to be forwarded. When receiving a message to be forwarded, the message to be forwarded is forwarded or forwarded directly after being modified according to the forwarding rules, without the need to serialize and deserialize the message to be forwarded and then perform the forwarding process, thereby improving the message forwarding efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0054] Figure 1 A flowchart of a message forwarding method provided in an embodiment of the present application;

[0055] Figure 2 A flowchart of a method for storing a forwarding instruction provided in an embodiment of the present application;

[0056] Figure 3 A flowchart of another message forwarding method provided in an embodiment of the present application;

[0057] Figure 4 A schematic diagram of a structure provided in an embodiment of the present application;

[0058] Figure 5 A flowchart of a structure assignment method provided in an embodiment of the present application;

[0059] Figure 6 A schematic diagram of the architecture of a message forwarding device provided in an embodiment of the present application;

[0060] Figure 7 A schematic diagram of the architecture of another message forwarding device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0062] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0063] like Figure 1As shown, it is a flowchart of a message forwarding method provided in an embodiment of the present application, which is applied to a lower computer and includes the following steps:

[0064] It should be noted that the lower computer is a real hardware device that can simulate the controller accessing the vehicle network. The upper computer has 6 channels that can be connected to the real vehicle bus to collect and send data. Different channels are connected to different controllers, so that data between different controllers can be forwarded, exchanged and shared, realizing the function of gateway routing.

[0065] S101: When a message to be forwarded sent by the bus is received, a forwarding instruction in an instruction set and a message ID of a preset message pre-stored in a structure are obtained.

[0066] The structure includes but is not limited to: CanTransConfig structure.

[0067] It can be understood that when a message to be forwarded is received from the bus, the forwarding instruction in the instruction set and the message ID of the preset message pre-stored in the structure are obtained, so as to subsequently determine whether the message to be forwarded needs to be forwarded based on the forwarding instruction and the message ID of the preset message.

[0068] Optionally, before step S101, in order to enable the lower computer to obtain the forwarding instruction from the instruction set, it is necessary to store the forwarding instruction sent by the upper computer in the instruction set in advance, so as to obtain the forwarding instruction from the instruction set later. Therefore, in another embodiment of the present application, a method for storing forwarding instructions is provided, such as Figure 2 As shown, the following steps are included:

[0069] S201: When receiving a forwarding instruction sent by the host computer, a write interrupt is triggered.

[0070] The forwarding instruction includes but is not limited to: a gateway instruction.

[0071] It is understandable that when receiving the forwarding instruction sent by the host computer, it is mirrored according to the GateWay communication protocol format and mapped and extracted into the pre-defined CanTransConfig structure. Since the lower computer has multiple channels, the instruction is sent to the lower computer, but the instruction content is channel-oriented. The embedded end code is developed in C language, and there is no container similar to MAP key-value pair available, so the CanTransConfig structure is accessed in the form of a two-dimensional array, and then the two-dimensional array GateWayStrcut is stored in the preset memory space (for example, 16K).

[0072] It should be noted that the implementation method of using a two-dimensional array to store key-value pairs is relatively simple, and the search speed is very fast. The index of any position can be obtained through simple mathematical operations. The key value key in the two-dimensional array can represent 0 to n channels, and the value is each CanTransConfig structure. When processing the instructions later, the address symbol can be directly used to obtain the instruction set on a certain channel. There is no need to traverse each instruction one by one. The search efficiency is very fast, which improves the real-time processing of the lower computer.

[0073] S202: When the write interrupt is triggered, obtain the instruction set in the channel corresponding to the write interrupt.

[0074] The instruction set in the channel corresponding to the write interrupt includes but is not limited to: Can_ForwardMsg.count.

[0075] Optionally, after obtaining the instruction set in the channel corresponding to the write interrupt, the new protocol instruction flag newflag is set to 0.

[0076] S203: Determine whether there is a historical forwarding instruction in the instruction set.

[0077] If there is a historical forwarding instruction in the instruction set, step S204 is executed.

[0078] Among them, the purpose of judging whether there is a historical forwarding instruction in the instruction set is to determine whether the forwarding instruction can be directly stored in the instruction set. If not, it means that it can be directly stored in the instruction set at this time. If it exists, it is necessary to determine whether the forwarding instruction needs to be changed accordingly based on the historical forwarding instruction before it can be stored in the instruction set.

[0079] Optionally, after step S203, the method further includes:

[0080] If there is no historical forwarding instruction in the instruction set, the forwarding instruction is stored in the instruction set.

[0081] It is understandable that if there is no historical forwarding instruction in the forwarding instruction, it means that no operation needs to be performed on the forwarding instruction at this time, and the forwarding instruction can be directly stored in the instruction set.

[0082] S204: Compare the instruction ID of the historical forwarding instruction with the instruction ID of the forwarding instruction.

[0083] Among them, the instruction ID of the historical forwarding instruction is compared with the instruction ID of the forwarding instruction. Specifically, all historical instructions in the instruction set are traversed, and it is searched from all historical instructions whether there is an instruction ID that is consistent with the instruction ID of the forwarding instruction. That is, the instruction ID of each historical forwarding instruction is compared one by one with the instruction ID of the forwarding instruction to see if they are the same (for example, whether the ID in the GateWayStrcut structure is the same as the ID of Can_ForwardMsg.count(i), where i is any historical forwarding instruction).

[0084] It should be noted that if the instruction ID of the historical forwarding instruction is inconsistent with the instruction ID of the forwarding instruction, the forwarding instruction is directly stored.

[0085] S205: If the instruction ID of the historical forwarding instruction is consistent with the instruction ID of the forwarding instruction, it is determined whether the forwarding flag bit included in the forwarding instruction is a preset value.

[0086] If the forwarding flag included in the forwarding instruction is a preset value, step S206 is executed.

[0087] Optionally, the preset value includes but is not limited to: 1.

[0088] If the instruction ID of the historical forwarding instruction is consistent with the instruction ID of the forwarding instruction, the new protocol instruction flag newflag is set to 1, and then it is determined whether the forwarding flag included in the forwarding instruction is a preset value (eg, forwarding flag changeflag=1).

[0089] It should be noted that if the forwarding flag contained in the forwarding instruction is not a preset value, the GateWayStrcut structure is deleted, and the forwarding instruction is deleted from the instruction set.

[0090] S206: Determine whether the modification flag bit included in the forwarding instruction is a preset value.

[0091] If the modification flag included in the forwarding instruction is a preset value, step S207 is executed.

[0092] It should be noted that if the modification flag bit included in the forwarding instruction is not a preset value, there is no need to update the historical forwarding instruction, and the forwarding instruction can be directly stored.

[0093] S207: Update the historical forwarding instruction according to the forwarding instruction to obtain an updated forwarding instruction.

[0094] The data in the historical forwarding instruction is updated according to the modification instruction in the forwarding instruction to obtain an updated forwarding instruction.

[0095] S208: Store the updated forwarding instruction into the instruction set.

[0096] It can be understood that the updated forwarding instruction is stored in the instruction set so that the forwarding instruction can be obtained from the instruction set later and the step of forwarding the message is executed according to the forwarding instruction.

[0097] Optionally, in another embodiment of the present application, the specific implementation of step S101 includes:

[0098] When a message to be forwarded sent by the bus is received, a read interrupt is triggered.

[0099] Two hardware interrupts are set separately in each channel, one is a read interrupt and the other is a write interrupt. The read interrupt is responsible for reading data from the bus, and the write interrupt is responsible for sending data to the bus. Whenever the host computer issues a forwarding instruction, the write interrupt will be triggered; whenever a message to be forwarded is received from the bus, the read interrupt will be triggered.

[0100] It should be noted that when a message to be forwarded sent by the bus is received, the gatewayprocess function in the read interrupt is triggered. The gatewayprocess function can compare the message ID and determine whether the message needs to be forwarded and modified.

[0101] When the read interrupt is triggered, the message ID of the preset message pre-stored in the structure is selected from the channel corresponding to the read interrupt.

[0102] Among them, since the message ID of the preset message is pre-stored in the structure (such as CanTransConfig), when the read interrupt is triggered, the message ID of the preset message pre-stored in CanTransConfig is selected in the channel corresponding to the read interrupt for subsequent comparison of the message ID.

[0103] S102: When the message ID of the message to be forwarded is consistent with the message ID of the preset message, it is determined whether the forwarding flag bit included in the forwarding instruction is a preset value.

[0104] If the forwarding flag included in the forwarding instruction is a preset value, step S103 is executed.

[0105] Among them, if the forwarding flag contained in the forwarding instruction is a preset value, it means that the message to be forwarded needs to be forwarded at this time, then continue to execute step S103; if the forwarding flag contained in the forwarding instruction is not a preset value, then it means that the message to be forwarded at this time does not need to be forwarded, then the process ends.

[0106] S103: Determine whether the modification flag bit included in the forwarding instruction is a preset value.

[0107] If the modification flag included in the forwarding instruction is a preset value, step S104 is executed.

[0108] Among them, if the modification flag contained in the forwarding instruction is a preset value, it means that the message to be forwarded needs to be modified at this time, then continue to execute step S104; if the modification flag contained in the forwarding instruction is not the preset value 9 (for example, the modification flag is 0), it means that the message to be forwarded at this time does not need to be modified, and the message to be forwarded is directly forwarded.

[0109] S104: Modify the message to be forwarded to obtain a modified message to be forwarded.

[0110] Optionally, the message to be forwarded may be modified through the gatewayprocess function. Specifically, the message to be forwarded may be modified by shifting or performing other operations according to the message modification rule to obtain a modified message.

[0111] Optionally, in another embodiment of the present application, the specific implementation of step S104 includes:

[0112] Get the modified fields contained in the forwarding instruction.

[0113] The modification field indicates a field to be modified in the message to be forwarded.

[0114] The message to be forwarded is modified according to the modification field to obtain a modified message to be forwarded.

[0115] Among them, the modification fields include but are not limited to: bitArray (indicating the CAN message array that needs to be modified), Singal_Value (the physical quantity that needs to be modified), Start_Bit (indicating the starting bit position of the modification), Singal_Length (the signal bit length that needs to be modified), looping bitArray to modify the CAN message data signal value, arrayIndex is used to record the byte array index in the replacement array (arrayIndex = (i+startBit) / 8), bitIndex is used to record the bit index in the replacement array ((i+startBit)%8), bitArray[arrayIndex] and the upper 7-bitIndex are shifted left by 1 bit and then inverted, and then bitArray[arrayIndex] or the upper replaceArray[i / 8] is used to shift right by 7-i%8 and then left by 7-bitIndex with the upper value.

[0116] It can be understood that the message to be forwarded is modified accordingly according to the specific modification field, that is, the message to be forwarded is updated to obtain a modified message to be forwarded.

[0117] S105: calling a sending function to forward the modified message to be forwarded.

[0118] Among them, since the forwarding instruction includes a source channel (ie, a receiving channel) and a target channel (ie, a channel for forwarding), the sending function is called to send the message to be forwarded through the target channel.

[0119] To summarize, since the forwarding rules have been sent from the upper computer to the lower computer in advance, the lower computer has completed the configuration and preparation work. When the lower computer receives the message to be forwarded, it modifies the message to be forwarded according to the forwarding rules and then forwards it or forwards it directly, without the need to serialize and deserialize the message to be forwarded, thereby improving the message forwarding efficiency.

[0120] like Figure 3 As shown, it is a flowchart of another message forwarding method provided in an embodiment of the present application, which is applied to a lower computer and includes the following steps:

[0121] S301: When configuration information is received, a data structure is created according to the message in the configuration information.

[0122] The configuration information includes, but is not limited to: source channel and target channel for gateway forwarding, and modification of message information.

[0123] It can be understood that a data structure is created according to the message in the configuration information. Specifically, the message in the configuration information and the CBC database are mirrored into a data structure (ie, singalist), and the data structure is stored in the code block.

[0124] S302: Map the data structure into the structure.

[0125] It can be understood that the data structure is mapped to the structure (i.e., cantransconfig structure) and converted into instructions for imitating gateway forwarding, i.e., GateWay communication protocol (a special information carrier format formulated for the interaction between the upper computer software and the lower computer hardware). The specific manifestation of the GateWay communication protocol is shown in Table 1.

[0126] Table 1

[0127]

[0128] In Table 1, the communication protocol is divided into three parts. The first part belongs to the protocol header, and the two bytes represent the total length of the entire service instruction data to ensure the integrity of the service data received. The second part belongs to the instruction data part, and the third part is the instruction tail, which contains a 4-byte service request handle for identifying the request source to meet the requirements of multiple processes, and n bytes of padding bits to fill the entire data packet to meet the requirements of USB4.0.

[0129] It should be noted that the content of Table 1 above is only for illustration.

[0130] S303: Assign values ​​to the structure according to the configuration information, obtain a forwarding instruction, and send the forwarding instruction to the lower computer.

[0131] It can be understood that the structure is assigned values ​​according to the configuration information to obtain the forwarding instruction. Specifically, one is to directly forward to the target channel or not forward after receiving the source channel message, and the other is to modify some signal data values ​​after receiving the source channel formulated message, and then forward it to the target channel after the modification. The structure is assigned values ​​according to the specific configuration information to obtain the forwarding instruction.

[0132] It should be noted that the maximum length of a CAN message is currently 64 bytes. The message signal of a CAN message is composed of several bits. CAN messages have two formats: Intel and Motorola. The host computer will encapsulate them in a fixed format according to the communication protocol. The fixed format here is the CanTransConfig structure. The specific form of the CanTransConfig structure is as follows: Figure 4 shown.

[0133] Optionally, in order to ensure the accuracy of message signal modification and reduce the computing burden of the lower computer, the upper computer sends the forwarding instruction to the lower computer via the data transmission method USB.

[0134] Optionally, in another embodiment of the present application, in step S303, the structure is assigned a value according to the configuration information to obtain a specific implementation of the forwarding instruction, such as Figure 5 As shown, the following steps are included:

[0135] S501: Obtain the message ID, source channel, target channel, forwarding information and modification information in the configuration information.

[0136] The message ID indicates the message ID of the message forwarded by the gateway.

[0137] The so-called forwarding information is actually information about whether the message needs to be forwarded.

[0138] The so-called modification information is actually information about whether the message needs to be modified before being forwarded.

[0139] S502: Assign values ​​to the structure according to the message ID, the source channel and the target channel to obtain the assigned structure.

[0140] Among them, the structure is assigned according to the message ID, source channel and target channel, that is, the specific information of the message ID, source channel and target channel is added to the structure to obtain the assigned structure.

[0141] S503: When the forwarding information indicates that the message is to be forwarded, the forwarding flag in the assigned structure is set to a preset value to obtain a set structure.

[0142] Among them, when the forwarding information indicates to forward the message, the forwarding flag in the assigned structure is set to a preset value, that is, the Turn_Flag in the structure is set to 1. If the forwarding information indicates to forward the message, the forwarding flag in the assigned structure is set to other values, that is, Turn_Flag is set to 0.

[0143] S504: When the modification information indicates that the message is to be modified, the modification flag in the set structure is set to a preset value to obtain a forwarding instruction.

[0144] Among them, when the modification information indicates that the message is modified, the modification flag in the set structure is set to a preset value, that is, the Change_Flag in the structure is set to 1; when the modification information indicates that the message is modified, the modification flag in the set structure is set to other values, that is, the Change_Flag in the structure is set to 0.

[0145] In summary, by generating a forwarding instruction according to the configuration information, the lower computer forwards the message to be forwarded according to the forwarding instruction of the upper computer, or forwards it after modification, without performing any redundant operations, thereby improving the message forwarding efficiency.

[0146] like Figure 6 As shown, it is a schematic diagram of the architecture of a message forwarding device provided in an embodiment of the present application, which is applied to a lower computer. The forwarding device includes: an acquisition unit 100, a first judgment unit 200, a second judgment unit 300, a modification unit 400 and a forwarding unit 500.

[0147] The acquisition unit 100 is used to acquire the forwarding instruction in the instruction set and the message ID of the preset message pre-stored in the structure when receiving the message to be forwarded sent by the bus.

[0148] The acquisition unit 100 is specifically used to: trigger a read interrupt when receiving a message to be forwarded sent by the bus; when the read interrupt is triggered, select a message ID of a preset message pre-stored in a structure from a channel corresponding to the read interrupt.

[0149] The first judgment unit 200 is used to judge whether the forwarding flag bit included in the forwarding instruction is a preset value when the message ID of the message to be forwarded is consistent with the message ID of the preset message.

[0150] The second judgment unit 300 is used to judge whether the modification flag bit included in the forwarding instruction is a preset value if the forwarding flag bit included in the forwarding instruction is a preset value.

[0151] The modification unit 400 is used to modify the message to be forwarded if the modification flag bit included in the forwarding instruction is a preset value, so as to obtain a modified message to be forwarded.

[0152] The modification unit 400 is specifically used for: obtaining the modification field contained in the forwarding instruction; and modifying the message to be forwarded according to the modification field to obtain the modified message to be forwarded.

[0153] The forwarding unit 500 is used to call the sending function to forward the modified message to be forwarded.

[0154] To summarize, since the forwarding rules have been sent from the upper computer to the lower computer in advance, the lower computer has completed the configuration and preparation work. When the lower computer receives the message to be forwarded, it modifies the message to be forwarded according to the forwarding rules and then forwards it or forwards it directly, without the need to serialize and deserialize the message to be forwarded, thereby improving the message forwarding efficiency.

[0155] Preferably, combined Figure 6 According to the content shown, the forwarding device also includes: a trigger unit, a writing unit, a third judgment unit, a comparison unit, a fourth judgment unit, a fifth judgment unit, an update unit and a storage unit.

[0156] A trigger unit, used to trigger a write interrupt when receiving a forwarding instruction sent by a host computer;

[0157] A write unit, used to obtain an instruction set in a channel corresponding to the write interrupt when the write interrupt is triggered;

[0158] A third judgment unit, used to judge whether there is a historical forwarding instruction in the instruction set;

[0159] a comparing unit, configured to compare the instruction ID of the historical forwarding instruction with the instruction ID of the forwarding instruction if there is a historical forwarding instruction in the instruction set;

[0160] a fourth determination unit, configured to determine whether a forwarding flag bit included in the forwarding instruction is a preset value if the instruction ID of the historical forwarding instruction is consistent with the instruction ID of the forwarding instruction;

[0161] a fifth determination unit, configured to determine whether a modification flag bit included in the forwarding instruction is a preset value if the forwarding flag bit included in the forwarding instruction is a preset value;

[0162] An updating unit, configured to update the historical forwarding instruction according to the forwarding instruction to obtain an updated forwarding instruction if the modification flag bit included in the forwarding instruction is a preset value;

[0163] The storage unit is used to store the updated forwarding instruction into the instruction set.

[0164] Preferably, combined Figure 6 The content shown, the forwarding device also includes: a data storage unit, which is used to store the forwarding instruction in the instruction set if there is no historical forwarding instruction in the instruction set.

[0165] like Figure 7 As shown, it is a schematic diagram of the architecture of another message forwarding device provided in an embodiment of the present application, which is applied to a host computer. The forwarding device includes: a creation unit 110, a mapping unit 210 and an assignment unit 310.

[0166] The creating unit 110 is used to create a data structure according to the message in the configuration information when the configuration information is received.

[0167] The mapping unit 120 is used to map the data structure into a structure.

[0168] The assignment unit 130 is used to assign values ​​to the structure according to the configuration information, obtain a forwarding instruction, and send the forwarding instruction to the lower computer.

[0169] The assignment unit 130 is specifically used to: obtain the message ID, source channel, target channel, forwarding information and modification information in the configuration information; assign values ​​to the structure according to the source channel and the target channel to obtain the assigned structure; when the forwarding information indicates that the message is to be forwarded, the forwarding flag in the assigned structure is set to a preset value to obtain the set structure; when the modification information indicates that the message is to be modified, the modification flag in the set structure is set to a preset value to obtain a forwarding instruction.

[0170] In summary, by generating a forwarding instruction according to the configuration information, the lower computer forwards the message to be forwarded according to the forwarding instruction of the upper computer, or forwards it after modification, without performing any redundant operations, thereby improving the message forwarding efficiency.

[0171] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0172] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0173] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A message forwarding method, characterized in that: Applied to the lower computer, including: When receiving a message to be forwarded sent by the bus, obtaining a forwarding instruction in the instruction set and a message ID of a preset message pre-stored in the structure; When the message ID of the message to be forwarded is consistent with the message ID of the preset message, determining whether the forwarding flag bit included in the forwarding instruction is a preset value; If the forwarding flag bit included in the forwarding instruction is the preset value, determining whether the modification flag bit included in the forwarding instruction is the preset value; If the modification flag bit included in the forwarding instruction is the preset value, modifying the message to be forwarded to obtain a modified message to be forwarded; The sending function is called to forward the modified message to be forwarded.

2. The method according to claim 1, characterized in that: When receiving a message to be forwarded sent by the bus, obtaining a forwarding instruction in the instruction set and a message ID of a preset message pre-stored in the structure, including: When a message to be forwarded sent by the bus is received, a read interrupt is triggered; When the read interrupt is triggered, a message ID of a preset message pre-stored in a structure is selected from a channel corresponding to the read interrupt.

3. The method according to claim 1, characterized in that The step of modifying the message to be forwarded to obtain a modified message to be forwarded includes: Obtaining a modification field contained in the forwarding instruction; The message to be forwarded is modified according to the modification field to obtain a modified message to be forwarded.

4. The method according to claim 1, characterized in that When receiving a message to be forwarded sent by the bus, before obtaining the forwarding instruction in the instruction set and the message ID of the preset message pre-stored in the structure, it also includes: When receiving the forwarding instruction sent by the host computer, the write interrupt is triggered; When the write interrupt is triggered, obtaining an instruction set in the channel corresponding to the write interrupt; Determining whether there is a historical forwarding instruction in the instruction set; If the historical forwarding instruction exists in the instruction set, comparing the instruction ID of the historical forwarding instruction with the instruction ID of the forwarding instruction; If the instruction ID of the historical forwarding instruction is consistent with the instruction ID of the forwarding instruction, determining whether the forwarding flag bit included in the forwarding instruction is a preset value; If the forwarding flag bit included in the forwarding instruction is the preset value, determining whether the modification flag bit included in the forwarding instruction is the preset value; If the modification flag bit included in the forwarding instruction is the preset value, the historical forwarding instruction is updated according to the forwarding instruction to obtain an updated forwarding instruction; The updated forwarding instruction is stored in the instruction set.

5. The method according to claim 4, characterized in that After determining whether there is a historical forwarding instruction in the instruction set, the method further includes: If the historical forwarding instruction does not exist in the instruction set, the forwarding instruction is stored in the instruction set.

6. A message forwarding method, characterized in that: Applied to the host computer, including: When receiving the configuration information, creating a data structure according to the message in the configuration information; Mapping the data structure into a structure; The structure is assigned a value according to the configuration information to obtain a forwarding instruction, and the forwarding instruction is sent to a lower computer.

7. The method according to claim 6, characterized in that The step of assigning a value to the structure according to the configuration information to obtain a forwarding instruction includes: Obtain the message ID, source channel, target channel, forwarding information and modification information in the configuration information; Assigning values ​​to the structure according to the message ID, the source channel and the target channel to obtain an assigned structure; When the forwarding information indicates that the message is to be forwarded, the forwarding flag in the assigned structure is set to a preset value to obtain a set structure; When the modification information indicates that the message is to be modified, the modification flag in the set structure is set to the preset value to obtain a forwarding instruction.

8. A message forwarding device, characterized in that: Applied to the lower computer, including: An acquisition unit, configured to acquire, when receiving a message to be forwarded sent by the bus, a forwarding instruction in the instruction set and a message ID of a preset message pre-stored in the structure; A first judgment unit, configured to judge whether the forwarding flag bit included in the forwarding instruction is a preset value when the message ID of the message to be forwarded is consistent with the message ID of the preset message; a second judgment unit, configured to judge whether the modification flag bit included in the forwarding instruction is the preset value if the forwarding flag bit included in the forwarding instruction is the preset value; A modification unit, configured to modify the message to be forwarded to obtain a modified message to be forwarded if the modification flag bit included in the forwarding instruction is the preset value; The forwarding unit is used to call the sending function to forward the modified message to be forwarded.

9. The device according to claim 8, characterized in that The acquisition unit is specifically used for: When a message to be forwarded sent by the bus is received, a read interrupt is triggered; When the read interrupt is triggered, a message ID of a preset message pre-stored in a structure is selected from a channel corresponding to the read interrupt.

10. A message forwarding device, characterized in that: Applied to the host computer, including: A creating unit, configured to create a data structure according to a message in the configuration information when the configuration information is received; A mapping unit, used for mapping the data structure into a structure; The assignment unit is used to assign a value to the structure according to the configuration information, obtain a forwarding instruction, and send the forwarding instruction to the lower computer.