Bus message conversion method and device, equipment and storage medium
By optimizing the processing mechanism of message forwarding in the underlying framework, obtaining LIN bus message information and converting it according to the target message structure of CAN bus, the technical problem of data forwarding from LIN bus to CAN bus is solved, and efficient and accurate data forwarding is achieved.
Patent Information
- Application Number
- CN202411768448.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-04-04
AI Technical Summary
When the prior art realizes data forwarding from the LIN bus to the CAN bus, there are problems such as high hardware and software complexity, rising costs, increasing potential failure points, limited processing capabilities, and difficulty in ensuring the real-time and accuracy of data.
By obtaining the message information on the first bus message and the target message structure on the second bus, a conversion mapping table is established, and the message information is converted according to the preset conversion function to generate the target bus message.
It reduces the cost of message forwarding, improves the efficiency and accuracy of message data forwarding, and solves the real-time and reliability of data forwarding.
Smart Images

Figure CN119766904A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of bus message communication, and in particular to a bus message conversion method, device, equipment and storage medium. Background Art
[0002] In automotive electronic control systems, bus technology plays a vital role, among which LIN (Local Interconnect Network) bus and CAN (Controller Area Network) bus are the two most commonly used communication protocols. LIN bus is widely used in the communication between distributed electronic control systems inside the car due to its low cost and simple serial communication characteristics, especially for those scenarios where the data transmission rate is not high. CAN bus, on the other hand, is known for its high reliability and real-time performance, and is the first choice for automotive real-time control systems, suitable for long-distance, high-speed data transmission. However, in practical applications, due to the differences in the characteristics and application scenarios of LIN and CAN buses, it is often necessary to forward data on one bus to another bus to achieve information sharing and collaborative work between different electronic control units. This demand is particularly urgent in the integration and optimization of automotive electronic systems. Existing technical solutions, such as using gateway devices for data format conversion and protocol parsing, although they have achieved the conversion of bus messages to a certain extent, have many shortcomings. First, the hardware and software complexity of gateway devices is high, resulting in increased costs. Second, as an additional system component, the gateway increases potential failure points and may reduce the overall reliability of the system. Moreover, the processing capacity of the gateway is limited, and it is difficult to ensure the real-time and accuracy of the data when the data transmission volume is large.
[0003] Therefore, how to efficiently realize data forwarding from LIN bus to CAN bus is a problem that needs to be solved urgently. Summary of the invention
[0004] The main purpose of this application is to provide a bus message conversion method, device, equipment and storage medium, aiming to solve the technical problem of how to efficiently realize data forwarding from LIN bus to CAN bus.
[0005] To achieve the above object, the present application proposes a bus message conversion method, the method comprising:
[0006] Acquire message information on the first bus message and a target message structure on the second bus;
[0007] Obtaining a conversion mapping table according to the message information and the target message structure;
[0008] The message information is converted according to a preset conversion function and the conversion mapping table to obtain a target bus message.
[0009] In one embodiment, the step of converting the message information according to the preset conversion function and the conversion mapping table to obtain the target bus message includes:
[0010] Obtaining a data segment, an identifier, a checksum, and message format data according to the message information;
[0011] Copy the data segment of the message information according to a preset conversion function to obtain a target data segment;
[0012] Convert the identifier, the checksum and the message format data according to the conversion mapping table to obtain a target identifier, a target checksum and a target message format data;
[0013] A target bus message is obtained according to the target data segment, the target identifier, the target check code and the target message format data.
[0014] In one embodiment, the step of obtaining a conversion mapping table according to the message information and the target message structure includes:
[0015] Extracting the original message structure according to the message information;
[0016] A conversion mapping table is constructed according to the original message structure and the target message structure.
[0017] In one embodiment, the step of constructing a conversion mapping table according to the original message structure and the target message structure includes:
[0018] Analyze the original message structure and the target message structure to obtain an original identifier format, a target identifier format, a checksum format, a target checksum format, a frame format, and a target frame format;
[0019] Obtain an identifier conversion rule, a checksum conversion rule, and a format conversion rule according to at least two of the original identifier format, the target identifier format, the checksum format, the target checksum format, the frame format, and the target frame format;
[0020] A conversion mapping table is constructed according to the identifier conversion rule, the verification conversion rule and the format conversion rule.
[0021] In one embodiment, the step of obtaining an identifier conversion rule, a checksum conversion rule, and a format conversion rule according to at least two of the original identifier format, the target identifier format, the checksum format, the target checksum format, the frame format, and the target frame format comprises:
[0022] Constructing an identifier conversion rule according to the original identifier format and the target identifier format;
[0023] Constructing a checksum conversion rule according to the checksum format and the target checksum format;
[0024] A format conversion rule is constructed according to the frame format and the target frame format.
[0025] In one embodiment, after the step of converting the message information according to the preset conversion function and the conversion mapping table to obtain the target bus message, the method further includes:
[0026] Obtain the message forwarding time, message forwarding quantity, message error quantity, message sending time, and message receiving time;
[0027] Obtaining a forwarding rate according to the message forwarding time and the message forwarding quantity;
[0028] Obtaining a forwarding delay according to the message sending time and the message receiving time;
[0029] Obtaining an error rate according to the number of message forwardings and the number of message errors;
[0030] Message forwarding monitoring is performed according to the forwarding rate, the forwarding delay, and the error rate.
[0031] In one embodiment, the step of monitoring message forwarding according to the forwarding rate, the forwarding delay and the error rate includes:
[0032] When any one of the following conditions is met: the message forwarding rate is less than a preset forwarding rate threshold, the forwarding delay is greater than a preset forwarding delay threshold, and the error rate is greater than a preset forwarding error rate threshold, message forwarding is stopped and an early warning is issued to the user.
[0033] In addition, to achieve the above purpose, the present application also proposes a bus message conversion device, the device comprising:
[0034] A data acquisition module, used to acquire message information on the first bus message and a target message structure on the second bus;
[0035] A conversion construction module, used to obtain a conversion mapping table according to the message information and the target message structure;
[0036] The message conversion module is used to convert the message information according to a preset conversion function and the conversion mapping table to obtain a target bus message.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a bus message conversion device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the bus message conversion method described above.
[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the bus message conversion method described above are implemented.
[0039] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the bus message conversion method described above are implemented.
[0040] The present application provides a bus message conversion method, which obtains message information on a first bus message and a target message structure on a second bus; obtains a conversion mapping table according to the message information and the target message structure; and converts the message information according to a preset conversion function and the conversion mapping table to obtain a target bus message. In summary, the present application solves the problem of how to implement data forwarding from a LIN bus to a CAN bus by optimizing the message forwarding processing mechanism in the underlying framework, reduces the cost of message forwarding, and improves the efficiency and accuracy of message data forwarding. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0042] 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0043] Figure 1 A flowchart of the first embodiment of the bus message conversion method of the present application is provided;
[0044] Figure 2 A flowchart of the second embodiment of the bus message conversion method of the present application is provided;
[0045] Figure 3 A flowchart of the third embodiment of the bus message conversion method of the present application is provided;
[0046] Figure 4 This is a schematic diagram of the module structure of the bus message conversion device according to an embodiment of the present application;
[0047] Figure 5 A schematic diagram of the device structure of the hardware operating environment involved in the bus message conversion method in the embodiment of the present application.
[0048] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0049] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0050] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0051] The main solution of the embodiment of the present application is: obtaining message information on the first bus message and the target message structure on the second bus; obtaining a conversion mapping table based on the message information and the target message structure; converting the message information according to a preset conversion function and the conversion mapping table to obtain a target bus message.
[0052] In automotive electronic control systems, bus technology plays a vital role, among which LIN bus and CAN bus are the two most commonly used communication protocols. LIN bus is widely used in the communication between distributed electronic control systems inside the car due to its low cost and simple serial communication characteristics, especially for those scenarios where the data transmission rate is not high. CAN bus, on the other hand, is known for its high reliability and real-time performance, and is the first choice for automotive real-time control systems, suitable for long-distance, high-speed data transmission. However, in practical applications, due to the differences in the characteristics and application scenarios of LIN and CAN buses, it is often necessary to forward data on one bus to another bus to achieve information sharing and collaborative work between different electronic control units. This demand is particularly urgent in the integration and optimization of automotive electronic systems. Existing technical solutions, such as using gateway devices for data format conversion and protocol parsing, although they have achieved the conversion of bus messages to a certain extent, have many shortcomings. First, the hardware and software complexity of gateway devices is high, resulting in increased costs. Second, as an additional system component, the gateway increases potential failure points and may reduce the overall reliability of the system. Moreover, the processing capacity of the gateway is limited, and it is difficult to ensure the real-time and accuracy of the data when the data transmission volume is large. Therefore, how to efficiently realize data forwarding from LIN bus to CAN bus is a problem that needs to be solved urgently.
[0053] The present application solves the problem of how to realize data forwarding from LIN bus to CAN bus by optimizing the processing mechanism of message forwarding in the underlying framework, reduces the cost of message forwarding, and improves the efficiency and accuracy of message data forwarding.
[0054] It should be noted that the execution subject of this embodiment can be a bus message conversion system, or a computing service device with data processing, network communication and program running functions, or an electronic device capable of realizing the above-mentioned bus message conversion function, etc., and this embodiment does not specifically limit this. The following takes the bus message conversion system as an example to illustrate this embodiment and the following embodiments.
[0055] Based on this, the embodiment of the present application provides a bus message conversion method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the bus message conversion method of the present application.
[0056] In this embodiment, the bus message conversion method includes steps S10 to S30:
[0057] Step S10: Acquire the message information on the first bus message and the target message structure on the second bus.
[0058] It should be noted that the first bus refers to the LIN bus and the second bus refers to the CAN bus. Specifically, in this step, the system receives a message from the LIN bus. The message includes a message header, a message ID, a data field, and check information. The system parses the message and extracts key information such as the message ID and the data field as message information. At the same time, the system determines the structure of the CAN bus message (i.e., the target message structure) according to the communication protocol specification of the CAN bus. The target message structure includes components such as the identifier (ID) of the CAN message, the data field, and the CRC check code. For example, in an automobile control system, the LIN bus transmits a message containing vehicle speed information, and the CAN bus needs to receive and process the vehicle speed information. At this time, the system first receives the vehicle speed message through the LIN bus, parses the message ID and the data field, and then determines the target message structure according to the communication protocol of the CAN bus, including assigning a unique CAN message ID to the vehicle speed information, preparing the data field for storing the vehicle speed value, and reserving space for calculating the CRC check code.
[0059] Step S20: Obtain a conversion mapping table according to the message information and the target message structure.
[0060] It should be noted that the target message structure refers to the structure of the CAN bus message. In this step, the system will establish a conversion mapping table based on the acquired message information and the target message structure. The conversion mapping table is used to record the correspondence between the message ID, data field and other information in the LIN message and the identifier (ID), data field and other information in the CAN message. For example, based on the message ID and data field length of the vehicle speed message, the system will randomly assign a unique CAN message ID to the vehicle speed information in the conversion mapping table, and determine the starting position and length of the data field in the CAN message. In this way, when the system receives the vehicle speed message, it can quickly forward the vehicle speed information to the CAN bus according to the conversion mapping table.
[0061] In addition, it should be noted that the conversion mapping table is a table used to record the conversion relationship between different bus messages. Since different automotive electronic systems may use different LIN and CAN message specifications, the conversion mapping table also needs to be adjusted according to specific system requirements.
[0062] Step S30: converting the message information according to a preset conversion function and the conversion mapping table to obtain a target bus message.
[0063] It should be noted that in this step, the system will convert the acquired LIN message information according to the preset conversion function and conversion mapping table. The conversion process includes steps such as replacing the message ID, copying the data field, and calculating the CRC check code. Finally, the system generates a target bus message that complies with the CAN bus communication protocol specification. For example, in an automotive electronic control system, the system will use a preset conversion function (such as the memcpy function) to copy the vehicle speed information from the LIN message to the CAN message according to the conversion mapping table. During the copying process, the system will determine the starting position and length of the vehicle speed information in the CAN message according to the conversion mapping table, and ensure that the integrity of the data field remains unchanged. At the same time, the system will also calculate and add the CRC check code according to the specification of the CAN message to ensure the correctness and reliability of the message. Finally, the system generates a CAN message containing the vehicle speed information and sends it out through the CAN bus interface.
[0064] In addition, it should be noted that the preset conversion function refers to an algorithm or program for realizing message information conversion. In the present embodiment, the preset conversion function may include functions such as memcpy function for data replication, CRC check code calculation function, etc. for generating check code. These functions can be selected and adjusted according to actual needs to meet the needs of different application scenarios. The target bus message refers to a message that conforms to the CAN bus communication protocol specification after conversion. It will be sent to the CAN bus for other electronic control units to receive and process.
[0065] In a feasible implementation manner, the step S20 specifically includes:
[0066] Step S201: extracting the original message structure according to the message information.
[0067] It should be noted that the original message structure refers to the format and structure used by the LIN message when it is sent. It contains all the basic information and data structure of the message, generally including components such as the message header, data field and check bit. Specifically, in this step, the system will parse the LIN message header to obtain the message identifier (ID) and length information. The message identifier is used to distinguish different message types, and the length information indicates the length of the data field. Then the system will extract the data field from the LIN message based on the length information in the message header. The data field contains the actual communication data, which will be arranged in a specific format. Finally, the system will construct the original message structure of the LIN message based on the extracted message header and data field. This structure will be used for subsequent mapping conversion with the target message structure.
[0068] Step S202: construct a conversion mapping table according to the original message structure and the target message structure.
[0069] It should be noted that the system will clarify the structure of the target CAN message based on the target message structure. Then the message identifier in the LIN message structure (i.e., the original message structure) is matched with the message identifier of the target CAN message to determine the target message type for conversion. According to the data field format of the LIN message and the target CAN message, a mapping relationship of the data fields is constructed. Based on the above matching and mapping relationship, the system will construct a conversion mapping table. This table maps each data field in the original LIN message structure to the corresponding position in the target CAN message structure. It can be understood that this step constructs a conversion mapping table by establishing a mapping relationship between the original message structure and the target message structure for use in subsequent message conversion processes.
[0070] In a feasible implementation manner, the step S202 specifically includes:
[0071] Step A10: Analyze the original message structure and the target message structure to obtain an original identifier format, a target identifier format, a checksum format, a target check code format, a frame format, and a target frame format.
[0072] It should be noted that the original identifier format refers to the protected ID segment format in the LIN message, while the target identifier format refers to the ID segment format in the CAN message. The checksum format refers to the format of the checksum field in the LIN message, while the target check code format refers to the CRC check code format in the CAN message. The frame format refers to the overall structure of the LIN message, and the target frame format refers to the overall structure of the CAN message. Specifically, in this step, the system will analyze the structure of the LIN message (original message) and the CAN message (target message) in detail. The LIN message structure includes a message header, a data segment, and a checksum, wherein the message header includes a synchronization interval segment, a synchronization segment, and a protected ID segment. The CAN message structure includes a frame start bit, an identifier, a data length code, a data field, a check code, and a frame end bit.
[0073] Step A20: Obtain identifier conversion rules, check conversion rules and format conversion rules according to at least two of the original identifier format, the target identifier format, the checksum format, the target check code format, the frame format and the target frame format.
[0074] It should be noted that the identifier conversion rule refers to mapping the frame ID in the LIN message to the identifier (ID) in the CAN message. The check conversion rule refers to calculating a new CRC checksum to replace the original checksum when converting the LIN message to the CAN message. The format conversion rule refers to the rules formulated based on the frame format differences between the LIN message and the CAN message. For example, there are no frame start bits and frame end bits in the LIN message, but these bits need to be added in the CAN message. Similarly, the checksum field in the LIN message needs to be replaced by the CRC checksum in the CAN message. It can be understood that the formulation of the conversion rules needs to be flexibly adjusted according to the specific application scenarios to ensure that the converted CAN message complies with the communication protocol specifications of the CAN bus.
[0075] In addition, it should be noted that, in this embodiment, the system can construct identifier conversion rules based on the original identifier format and the target identifier format; construct check conversion rules based on the checksum format and the target check code format; and construct format conversion rules based on the frame format and the target frame format.
[0076] Step A30: construct a conversion mapping table according to the identifier conversion rule, the verification conversion rule and the format conversion rule.
[0077] It should be noted that in this step, the system will construct a conversion mapping table based on the identifier conversion rule, the check conversion rule and the format conversion rule. Specifically, the conversion mapping table includes the identifier conversion rule, that is, mapping the frame ID in the LIN message to the identifier of the CAN message through a random number conversion algorithm; the check conversion rule is to calculate the CRC checksum based on the checksum field of the LIN message and add it to the CAN message. The checksum can be obtained by performing binary addition on the data field in the LIN message and negating it; the format conversion rule is to make necessary format adjustments to the message based on the difference between the frame format and the target frame format of the LIN message and the CAN message. For example, add the frame start bit and the frame end bit to the CAN message.
[0078] This embodiment provides a bus message conversion method, and the method of this embodiment includes: obtaining message information on a first bus message and a target message structure on a second bus; obtaining a conversion mapping table according to the message information and the target message structure; converting the message information according to a preset conversion function and the conversion mapping table to obtain a target bus message. In summary, this embodiment solves the problem of how to implement data forwarding from a LIN bus to a CAN bus by optimizing the message forwarding processing mechanism in the underlying framework, thereby reducing the cost of message forwarding and improving the efficiency and accuracy of message data forwarding.
[0079] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 2 , Figure 2 This is a flow chart of the second embodiment of the bus message conversion method of the present application, wherein step S30 specifically includes:
[0080] Step S301: Obtain data segments, identifiers, checksums and message format data according to the message information.
[0081] It should be noted that in this step, the system will parse the received LIN bus message information. Specifically, the system will do this by parsing the various components of the LIN message, including the message header (Header), data segment (Data Field) and checksum field (Checksum Field). The protected ID segment in the message header contains the frame ID and parity bit. The system extracts the data segment of the LIN message, which contains 1 to 8 bytes of actual data and is the core information that needs to be forwarded to the CAN bus. At the same time, the system also reads and saves the checksum and message format data of the LIN message to ensure that the integrity and consistency of the data can be maintained during the conversion process.
[0082] In addition, it should be noted that the data segment is the part of the LIN message that carries the actual information, while the checksum is used to verify the integrity of the data at the receiving end. The message format data includes information such as the structure and encoding method of the message.
[0083] Step S302: copying the data segment of the message information according to a preset conversion function to obtain a target data segment.
[0084] It should be noted that in this step, the system uses a preset conversion function to process the data segment of the LIN message. Since the data segment structures of the LIN message and the CAN message are similar to each other, the system can directly copy the data segment of the LIN message to the data domain of the CAN message. This step is implemented by calling the memcpy function, which can copy the contents of the source memory block to the target memory block, thereby completing the data segment copy process.
[0085] In addition, it should be noted that the memcpy function is an efficient memory copy function, which can quickly complete the data copy process without changing the data content. In this embodiment, the memcpy function is used to copy the data segment in order to ensure the accuracy and integrity of the data.
[0086] Step S303: converting the identifier, the checksum and the message format data according to the conversion mapping table to obtain a target identifier, a target checksum and a target message format data.
[0087] It should be noted that in this step, the system will process the identifier, checksum and message format data of the LIN message according to the constructed conversion mapping table. The conversion mapping table is a data table containing the correspondence between LIN messages and CAN messages. According to the conversion mapping table, the system converts the identifier of the LIN message into the identifier (ID) of the CAN message, converts the checksum into a checksum (CRC) that complies with the CAN bus specification, and adjusts the message format data according to the message format requirements of the CAN bus.
[0088] In addition, it should be noted that the conversion mapping table can ensure that the LIN message can be correctly converted into the CAN message. It contains all the necessary correspondences between the two bus messages, so that the system can accurately complete the conversion process.
[0089] Step S304: Obtain a target bus message according to the target data segment, the target identifier, the target check code and the target message format data.
[0090] It should be noted that in this step, the system will construct and send the target bus message (i.e., CAN message). Specifically, the system will construct a complete CAN message based on the obtained target identifier, target data segment, target check code, and target message format data. This CAN message contains the frame start bit (SOF, obtained according to the target message format data), identifier (ID), remote transmission request bit (RTR, which should be set to 0 here to indicate a data frame), data length code (DLC, set according to the length of the target data segment), data field (Data Field, i.e., target data segment), CRC check code (i.e., target check code), and frame end bit (EOF, obtained according to the target message format data).
[0091] In this embodiment, LIN messages are converted in real time through preset conversion functions and constructed conversion mapping tables, realizing format conversion and data forwarding from LIN messages to CAN messages, ensuring efficient and accurate data transmission, and improving the reliability and real-time performance of the system.
[0092] Based on the first and second embodiments of the present application, in the third embodiment of the present application, the same or similar contents as those in the first and second embodiments can be referred to the above description, and will not be described in detail later. Figure 3 , Figure 3 This is a flow chart of the third embodiment of the bus message conversion method of the present application. After step S30, steps S40 to S80 are also included:
[0093] Step S40: Acquire the message forwarding time, the message forwarding quantity, the message error quantity, the message sending time and the message receiving time.
[0094] It should be noted that in this step, the system will record the relevant information of message forwarding in real time through the set timer and counter modules. Specifically, when the LIN message is successfully forwarded to the CAN bus, the system records the total time spent as the message forwarding time, and increases the counter of the number of message forwardings. At the same time, the system also monitors the message errors that occur during the message forwarding process, such as data verification failure, timeout and no response, and records the number of message errors. In addition, the system also records the message sending time when the message is sent from the LIN bus to the CAN bus, and the message receiving time when the CAN bus receives and confirms the message reception.
[0095] In addition, it should be noted that the message forwarding time refers to the time required to forward all LIN messages, while the message sending time and message receiving time both refer to the timestamps within the system, which are uniformly managed and recorded through the system clock. The number of message forwardings refers to the total number of messages forwarded within the message forwarding time, and the number of message errors refers to the total number of forwarding errors that occur during this period.
[0096] Step S50: Obtain a forwarding rate according to the message forwarding time and the message forwarding quantity.
[0097] It should be noted that in this step, the system will calculate the number of message forwardings within the message forwarding time. Specifically, the system will use the number of message forwardings within the message forwarding time (i.e., the total number of message forwardings) divided by the time interval (seconds) to obtain the message forwarding rate (messages / second). This rate reflects the system's ability to process messages per unit time.
[0098] In addition, it should be noted that the packet forwarding rate is a dynamically changing value, which is affected by many factors such as system load, hardware configuration, software algorithm, etc. Therefore, in practical applications, it is necessary to continuously monitor this indicator and adjust and optimize it as needed.
[0099] Step S60: Obtain forwarding delay according to the message sending time and the message receiving time.
[0100] It should be noted that in this step, the system will calculate the message forwarding delay (milliseconds or microseconds) by comparing the difference between the message sending time and the message receiving time. This delay reflects the time required for the message to be sent from the LIN bus to the CAN bus and received. For example, if the sending time of a LIN message is 12:00:00.000 and the receiving time of the CAN bus is 12:00:00.010, then the message forwarding delay is 10 milliseconds. It can be understood that this delay value can be used to evaluate the real-time performance and response speed of the system. In practical applications, it is necessary to reduce this delay value as much as possible to improve the overall performance of the system.
[0101] Step S70: Obtain an error rate according to the number of message forwardings and the number of message errors.
[0102] It should be noted that in this step, the system will calculate the error rate based on the number of message forwarding and the number of message errors. The calculation formula for the error rate is: Error rate = number of message errors / number of message forwarding. It can be understood that the role of this step is that by calculating the error rate, the stability and accuracy of the message forwarding process can be intuitively reflected, providing a basis for subsequent monitoring and optimization.
[0103] In addition, it should be noted that the number of message forwarding and the number of message errors are two key parameters for evaluating the performance of the message forwarding process. The number of message forwarding reflects the processing capacity of the system, while the number of message errors is directly related to the stability and accuracy of the system. The error rate, as the ratio of these two numbers, can more comprehensively reflect the overall performance of the system.
[0104] Step S80: Perform message forwarding monitoring according to the forwarding rate, the forwarding delay and the error rate.
[0105] It should be noted that in this step, the system will monitor and record the three key indicators of forwarding rate, forwarding delay and error rate in real time. The forwarding rate reflects the speed at which the system processes messages, the forwarding delay reflects the real-time nature of message forwarding, and the error rate reflects the accuracy of message forwarding. The system will monitor the message forwarding process in real time according to the changes in these three indicators. For example, in actual applications, the system can set a series of thresholds to determine whether the message forwarding process is normal. If the forwarding rate is lower than a certain threshold, it means that the system processing capacity is insufficient; if the forwarding delay exceeds a certain threshold, it indicates that there is a delay problem in the system; if the error rate is higher than a certain threshold, it indicates that there is a problem with the stability or accuracy of the system. Once these abnormal conditions are detected, the system can immediately issue an alarm and take corresponding measures to repair or optimize.
[0106] In a feasible implementation manner, the step S80 specifically includes:
[0107] Step S801: When any one of the following conditions is met: the message forwarding rate is less than a preset forwarding rate threshold, the forwarding delay is greater than a preset forwarding delay threshold, and the error rate is greater than a preset forwarding error rate threshold, message forwarding is stopped and an early warning is issued to the user.
[0108] It should be noted that in this step, the preset forwarding rate threshold refers to the minimum requirement for the number of messages from the LIN bus message to the CAN bus per unit time. When the actual forwarding rate is lower than the threshold, it indicates that the message forwarding speed is too slow and cannot meet the real-time requirements of the system. The preset forwarding delay threshold refers to the maximum allowable value of the time required for the message to be forwarded from the LIN bus to the CAN bus and received. When the actual forwarding delay exceeds the threshold, it indicates that there is a delay in message forwarding, which will affect the response speed of the system. The preset forwarding error rate threshold refers to the maximum allowable proportion of the number of messages that failed to be converted to the total number of messages during the message forwarding process. When the actual error rate exceeds the threshold, it indicates that there is a high error rate in message forwarding, which will affect the accuracy and reliability of the message data. When any of the above three conditions is met, the message forwarding monitoring module will immediately stop message forwarding and issue an early warning to the user through the display screen of the car or sound and light alarm. In this way, the user can promptly understand the problems that occur during the message forwarding process and take corresponding measures to solve them.
[0109] In this embodiment, by comprehensively monitoring and evaluating performance indicators such as forwarding rate, forwarding delay, and error rate of the message forwarding process, potential problems can be quickly discovered and resolved, thereby ensuring the stability and accuracy of message forwarding.
[0110] The present application also provides a bus message conversion device, please refer to Figure 4 , the bus message conversion device comprises:
[0111] A data acquisition module 10, used to acquire message information on the first bus message and a target message structure on the second bus;
[0112] A conversion construction module 20, configured to obtain a conversion mapping table according to the message information and the target message structure;
[0113] The message conversion module 30 is used to convert the message information according to a preset conversion function and the conversion mapping table to obtain a target bus message.
[0114] The bus message conversion device provided by the present application adopts the bus message conversion method in the above embodiment, which can solve the technical problem of how to efficiently realize data forwarding from the LIN bus to the CAN bus. Compared with the prior art, the beneficial effects of the bus message conversion device provided by the present application are the same as the beneficial effects of the bus message conversion method provided by the above embodiment, and other technical features in the bus message conversion device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0115] In one embodiment, the conversion construction module 20 is further used to extract the original message structure according to the message information; and construct a conversion mapping table according to the original message structure and the target message structure.
[0116] In one embodiment, the conversion construction module 20 is further used to analyze the original message structure and the target message structure to obtain the original identifier format, the target identifier format, the checksum format, the target check code format, the frame format and the target frame format; obtain the identifier conversion rule, the check conversion rule and the format conversion rule according to at least two of the original identifier format, the target identifier format, the checksum format, the target check code format, the frame format and the target frame format; and construct a conversion mapping table according to the identifier conversion rule, the check conversion rule and the format conversion rule.
[0117] In one embodiment, the conversion construction module 20 is further used to construct an identifier conversion rule according to the original identifier format and the target identifier format; to construct a checksum conversion rule according to the checksum format and the target checksum format; and to construct a format conversion rule according to the frame format and the target frame format.
[0118] In one embodiment, the message conversion module 30 is also used to obtain a data segment, an identifier, a checksum and a message format data according to the message information; copy the data segment of the message information according to a preset conversion function to obtain a target data segment; convert the identifier, the checksum and the message format data according to the conversion mapping table to obtain a target identifier, a target check code and a target message format data; obtain a target bus message according to the target data segment, the target identifier, the target check code and the target message format data.
[0119] In one embodiment, the bus message conversion device also includes a forwarding monitoring module, which is used to obtain the message forwarding time, the number of message forwardings, the number of message errors, the message sending time and the message receiving time; obtain the forwarding rate according to the message forwarding time and the message forwarding number; obtain the forwarding delay according to the message sending time and the message receiving time; obtain the error rate according to the message forwarding number and the message error number; and perform message forwarding monitoring according to the forwarding rate, the forwarding delay and the error rate.
[0120] In one embodiment, the forwarding monitoring module is also used to stop message forwarding and issue an early warning to the user when any one of the following conditions is met: the message forwarding rate is less than a preset forwarding rate threshold, the forwarding delay is greater than a preset forwarding delay threshold, and the error rate is greater than a preset forwarding error rate threshold.
[0121] The present application provides a bus message conversion device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the bus message conversion method in the above-mentioned embodiment one.
[0122] Reference below Figure 5 , which shows a schematic diagram of the structure of a bus message conversion device suitable for implementing the embodiment of the present application. The bus message conversion device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5The bus message conversion device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0123] like Figure 5 As shown, the bus message conversion device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the bus message conversion device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the bus message conversion device to communicate wirelessly or wired with other devices to exchange data. Although the bus message conversion device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0124] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0125] The bus message conversion device provided by the present application adopts the bus message conversion method in the above embodiment, which can solve the technical problem of how to efficiently realize data forwarding from the LIN bus to the CAN bus. Compared with the prior art, the beneficial effects of the bus message conversion device provided by the present application are the same as the beneficial effects of the bus message conversion method provided by the above embodiment, and the other technical features in the bus message conversion device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0126] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0127] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0128] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the bus message conversion method in the above-mentioned embodiment.
[0129] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0130] The computer-readable storage medium may be included in the bus message conversion device; or may exist independently without being assembled into the bus message conversion device.
[0131] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the bus message conversion device, the bus message conversion device: obtains the message information on the first bus message and the target message structure on the second bus; obtains a conversion mapping table according to the message information and the target message structure; converts the message information according to a preset conversion function and the conversion mapping table to obtain a target bus message.
[0132] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0133] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0134] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0135] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned bus message conversion method, and can solve the technical problem of how to efficiently realize data forwarding from the LIN bus to the CAN bus. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the bus message conversion method provided by the above-mentioned embodiment, and will not be repeated here.
[0136] The present application also provides a computer program product, including a computer program, which implements the steps of the bus message conversion method as described above when executed by a processor.
[0137] The computer program product provided by the present application can solve the technical problem of how to efficiently realize data forwarding from the LIN bus to the CAN bus. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the bus message conversion method provided by the above embodiment, which will not be repeated here.
[0138] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A bus message conversion method, characterized in that: The method comprises: Acquire message information on the first bus message and a target message structure on the second bus; Obtaining a conversion mapping table according to the message information and the target message structure; The message information is converted according to a preset conversion function and the conversion mapping table to obtain a target bus message.
2. The method according to claim 1, characterized in that The step of converting the message information to obtain the target bus message according to the preset conversion function and the conversion mapping table comprises: Obtaining a data segment, an identifier, a checksum, and message format data according to the message information; Copy the data segment of the message information according to a preset conversion function to obtain a target data segment; Convert the identifier, the checksum and the message format data according to the conversion mapping table to obtain a target identifier, a target checksum and a target message format data; A target bus message is obtained according to the target data segment, the target identifier, the target check code and the target message format data.
3. The method according to claim 1, characterized in that The step of obtaining a conversion mapping table according to the message information and the target message structure comprises: Extracting the original message structure according to the message information; A conversion mapping table is constructed according to the original message structure and the target message structure.
4. The method according to claim 3, characterized in that The first message structure includes the step of constructing a conversion mapping table according to the original message structure and the target message structure, including: Analyze the original message structure and the target message structure to obtain an original identifier format, a target identifier format, a checksum format, a target checksum format, a frame format, and a target frame format; Obtain an identifier conversion rule, a checksum conversion rule, and a format conversion rule according to at least two of the original identifier format, the target identifier format, the checksum format, the target checksum format, the frame format, and the target frame format; A conversion mapping table is constructed according to the identifier conversion rule, the verification conversion rule and the format conversion rule.
5. The method according to claim 4, characterized in that The step of obtaining an identifier conversion rule, a checksum conversion rule and a format conversion rule according to at least two of the original identifier format, the target identifier format, the checksum format, the target checksum format, the frame format and the target frame format comprises: Constructing an identifier conversion rule according to the original identifier format and the target identifier format; Constructing a checksum conversion rule according to the checksum format and the target checksum format; A format conversion rule is constructed according to the frame format and the target frame format.
6. The method according to claim 1, characterized in that After the step of converting the message information according to the preset conversion function and the conversion mapping table to obtain the target bus message, the method further includes: Obtain the message forwarding time, message forwarding quantity, message error quantity, message sending time, and message receiving time; Obtaining a forwarding rate according to the message forwarding time and the message forwarding quantity; Obtaining a forwarding delay according to the message sending time and the message receiving time; Obtaining an error rate according to the number of message forwardings and the number of message errors; Message forwarding monitoring is performed according to the forwarding rate, the forwarding delay, and the error rate.
7. The method according to claim 6, characterized in that The step of monitoring message forwarding according to the forwarding rate, the forwarding delay and the error rate comprises: When any one of the following conditions is met: the message forwarding rate is less than a preset forwarding rate threshold, the forwarding delay is greater than a preset forwarding delay threshold, and the error rate is greater than a preset forwarding error rate threshold, message forwarding is stopped and an early warning is issued to the user.
8. A bus message conversion device, characterized in that: The device comprises: A data acquisition module, used to acquire message information on the first bus message and a target message structure on the second bus; A conversion construction module, used to obtain a conversion mapping table according to the message information and the target message structure; The message conversion module is used to convert the message information according to a preset conversion function and the conversion mapping table to obtain a target bus message.
9. A bus message conversion device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the bus message conversion method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the bus message conversion method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Interface message conversion method and device and storage medium
CN109831440A
Message conversion method and device, computer readable storage medium and processor
CN113132371A
CAN message database establishment method and device, vehicle-mounted electronic equipment and storage medium
CN115277882A
Message conversion method and message conversion device
CN115866086A