CAN bus message analysis method based on pole climbing algorithm

By using the rod climbing algorithm in CAN bus message analysis, the problem of repeated sending of messages when data flow is blocked is solved, the integrity and periodic sharing of measurement point data is realized, and the accuracy and stability of analysis are improved.

CN119697290APending Publication Date: 2025-03-25NO 703 RES INST OF CHINA SHIPBUILDING IND CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411716495.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

When the data flow is blocked, the traditional CAN message analysis method will cause the message to be sent repeatedly, affecting the classification and analysis of subsequent messages, resulting in the loss of measurement point data and incomplete analysis.

Method used

The CAN bus message analysis method based on the rod climbing algorithm is adopted to ensure that all measurement point information is collected within one cycle and repeated messages are isolated when the data flow is blocked.

Benefits of technology

It realizes accurate analysis of measurement point data in the case of blockage of data flow, ensures the integrity and periodic sharing of measurement point information, and improves the accuracy and stability of packet analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697290A_ABST
    Figure CN119697290A_ABST
Patent Text Reader

Abstract

The invention aims to provide a CAN (Controller Area Network) bus message analysis method based on a pole climbing algorithm. The CAN bus message analysis method is characterized by comprising the following steps of receiving a CAN message; preprocessing frame information, performing information extraction on the received CAN message, and extracting a frame ID and frame data of the frame of CAN message; frame ID judgment is carried out, the current frame ID is compared with the last cycle frame ID, and if the current frame ID is larger than the last cycle frame ID, current frame information is analyzed and stored in a queue; if the current frame ID is greater than or equal to the last cycle frame ID, abandoning the current frame information, and entering the next cycle to carry out frame information preprocessing; when the frame ID is reset, the current period is ended, and CAN message receiving of the next period is started; and analyzing the message, decrypting and restoring all the measuring point data in the same period into a floating point number, and storing the data. According to the invention, periodical separation of the message is completed, and integrity of the measuring point data in a cyclic transmission process is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a communication method, in particular to a CAN message parsing method. Background Art

[0002] The quality of the equipment communication method depends not only on the choice of hardware, but also on the process of message generation and analysis. The two complement each other. The CAN bus protocol is used to transmit the equipment measurement point data, and an independent algorithm is provided for message analysis, which improves the message analysis rate and integrity, and fully utilizes the convenience brought by the CAN bus protocol.

[0003] Traditional CAN message parsing uses the cycle length (i.e., the number of messages) to periodically separate continuously received CAN messages. In the case of repeated message transmission caused by data flow congestion, it will affect the classification and parsing of all subsequently received messages. Summary of the invention

[0004] The purpose of the present invention is to provide a CAN bus message parsing method based on a climbing algorithm, which can accurately collect all measurement point information within a cycle and can well isolate duplicate messages when encountering data flow congestion.

[0005] The object of the present invention is achieved in that:

[0006] The present invention provides a CAN bus message parsing method based on a pole climbing algorithm, which is characterized by comprising the following steps:

[0007] (1) CAN message reception;

[0008] (2) Frame information preprocessing: extracting information from the received CAN message and extracting the frame ID and frame data of the CAN message;

[0009] (3) Perform frame ID discrimination, compare the current frame ID with the previous cycle frame ID, if the current frame ID is greater than the previous cycle frame ID, parse the current frame information and store it in the queue; if the current frame ID is greater than or equal to the previous cycle frame ID, discard the current frame information and enter the next cycle for frame information preprocessing;

[0010] (4) When the frame ID is reset, the current cycle ends and the next cycle of CAN message reception begins;

[0011] (5) Message parsing: decrypting all the measurement point data in the same cycle and restoring them into floating point numbers, and then storing the data.

[0012] The advantages of the present invention are: the present invention provides a CAN bus message parsing method based on a climbing pole algorithm, which completes the periodic sharing of the measurement point data in the equipment network by encrypting, transmitting and parsing the measurement point data of the ship power system. A set of CAN bus parsing algorithms is established, and the bionic model is used to complete the periodic separation of messages, so as to ensure that the measurement point data maintains integrity during the cyclic transmission process, and eliminates the message transmission problems caused by unknown factors at the algorithm level. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 is a flow chart of the present invention;

[0014] Figure 2 This is a diagram of the error mode of receiving a message;

[0015] Figure 3 This is a diagram of the bionic pole climbing process;

[0016] Figure 4 This is a core diagram of the pole climbing algorithm. DETAILED DESCRIPTION

[0017] The present invention is described in more detail below with reference to the accompanying drawings:

[0018] Combination Figure 1-4 The principle of the present invention is as follows: the pole climbing algorithm includes assuming that there is a row of long poles, each with a banana hanging on the top of the pole, and a little monkey with fluorescent powder on his hands will climb up along the poles, so that the entire pole is covered with fluorescent powder. When the monkey finishes climbing the first pole, it will jump off the pole and continue to climb the second pole, so that the second pole is also covered with fluorescent powder. In this way, the little monkey can make all the poles covered with fluorescent powder. In this process, when the little monkey jumps off a pole, it is the beginning of climbing the second pole. In addition, the monkey will inevitably slide down a certain distance during the pole climbing process. However, when climbing this distance for the second time, the fluorescent powder in the hand will cover the fluorescent powder applied before sliding down, which will not affect the fluorescent powder covering the pole. The pole climbing process is as follows Figure 3 shown.

[0019] Applying this process to message parsing and classification is the pole climbing algorithm. The long pole represents all the measurement points. Obtaining the banana means completing the transmission of all the measurement points in one cycle. Jumping off the pole represents the start of receiving the measurement point information of the next cycle. The monkey climbing upwards represents the increase of the frame ID. Sliding down represents the reception of duplicate messages. The fluorescent powder coverage indicates the received message.

[0020] The classification and processing of received messages includes the core content of the climbing algorithm. Due to the independence of CAN bus messages, the message measurement points need to be periodically separated when continuously sending and receiving messages. That is, it is necessary to find the starting point and end point of the message within a cycle in the continuous sending and receiving of messages to ensure that a complete set of measurement points is received within a cycle. In order to achieve this goal, traditional CAN messages use a limited cycle length method. According to the length of the measurement points sent by the sender, the number of measurement points of this length is accepted to achieve the reception of complete cycle measurement points.

[0021] This method is simple and effective, but in actual operation, due to the slight jitter between the measurement point data generation time and the CAN message sending time, it is easy to cause the CAN bus to send multiple frames of the same data within the predetermined time. At this time, the method of limiting the cycle by length will not only cause the loss of the measurement point in this cycle, but also disturb all the measurement points in the subsequent cycles. In one cycle, the frame ID is set to increase frame by frame from 1. During analysis, the increase of the frame ID indicates that the current frame information and the previous frame information are still in the same cycle, which is equivalent to the process of the little monkey climbing up the pole. If the current frame ID is reset, it means that this cycle is over and the next cycle frame information begins to be received. This process is equivalent to the little monkey jumping off the pole after climbing one pole and starting to climb the second pole. When the frame ID is less than or equal to the previous frame ID, it means that the message sender generates the message in time, resulting in a frame of data being sent multiple times. Therefore, this frame information is directly discarded to ensure that the measurement points in the cycle are complete and do not affect the next cycle. This process is equivalent to the little monkey slipping while climbing the pole.

[0022] The climbing algorithm parsing process includes when the CAN message is generated, at all the measurement points within a monitoring cycle, the message frame ID increases from 1 one by one, and after all the measurement point messages are generated, the next cycle starts to generate new measurement point information messages. At the receiving end, the CAN communication program starts the monitoring cycle cycle. After receiving the first frame message in a monitoring cycle, the frame message ID is stored in the ID register (the initial value of the ID register is set to 0), and the frame ID is compared with the value in the ID register. If the frame ID is greater than the value in the ID register at this time, it means that this frame information contains a useful value, and this frame information is parsed and stored in the queue, waiting to be displayed and stored in the database; if the frame ID is greater than or equal to the value in the ID register, the frame information has been parsed at this time, and there is no need to repeat the parsing, and it is directly discarded to start receiving the next frame information; when the ID is 1 again, this monitoring cycle ends, all the measurement points in this cycle are parsed, and the next monitoring cycle of sending and receiving begins.

[0023] The process of the present invention comprises the following steps: CAN message reception, frame information preprocessing, frame ID determination and message parsing.

[0024] The CAN message reception is to receive continuous CAN messages into the algorithm loop for the next step; the USBCAN device is used to receive CAN messages, and the continuously received messages are transmitted to the loop. This loop is a periodic loop called loop one, that is, when one cycle ends and the second cycle starts, it represents entering the second cycle.

[0025] The frame information preprocessing is to extract information from a received CAN message in one cycle, and extract the frame ID and frame data of this frame CAN message;

[0026] The frame ID discrimination stores the current frame ID in one cycle for comparison with the next frame ID, and determines whether the current frame information is in the same transmission cycle as the previous frame by comparing the frame ID with the previous frame ID, and classifies the received messages periodically;

[0027] In loop 2, the frame ID of the received message is first temporarily stored in the register for comparison with the next frame ID, such as Figure 4 As shown in the figure, when the frame ID is reset, it indicates that a cycle has ended, and the measurement points of this cycle are analyzed and the measurement points of the next cycle are received. When the frame ID is greater than the previous frame ID, it indicates that the message is normal and is in the same cycle as the previous frame information. The frame information is stored in the queue and waits for the cycle to end for the next analysis. When the frame ID is less than or equal to the previous frame ID, it indicates that the CAN message is jittering due to an unknown error. The device reads the value in the internal register, that is, the historical data, and sends it. Figure 2 As shown, the data is invalid at this time and is deleted directly;

[0028] The message parsing decrypts all the measurement point data in the same cycle and restores them into floating point numbers, and stores the data.

[0029] Frame ID identification includes frame ID setting, measurement point cycle identification, and CAN device software-level anti-shake.

[0030] The frame ID setting includes a frame ID that is incremented from 1 within a transmission cycle.

[0031] The measurement point cycle determination includes temporarily storing the received frame ID for comparison with the next frame ID to determine whether all measurement points of a cycle are completely received.

[0032] CAN device software-level anti-shake includes comparing the received frame ID with the next frame ID. If the current received ID is less than or equal to the next frame, the frame information is discarded.

[0033] The CAN bus message parsing method based on the pole climbing algorithm provided by the present invention has the following advantages:

[0034] (1) Transmission via the CAN bus enables long distance and high speed information transmission, thus ensuring the integrity of the measurement point information.

[0035] (2) The application of the climbing pole algorithm solves the problem of periodic separation of measurement point messages and achieves a certain degree of resistance to unknown errors in the message transmission process.

Claims

1. A CAN bus message parsing method based on a pole climbing algorithm, characterized in that: The steps include: (1) CAN message reception; (2) Frame information preprocessing: extracting information from the received CAN message and extracting the frame ID and frame data of the CAN message; (3) Perform frame ID discrimination and compare the current frame ID with the previous cycle frame ID. If the current frame ID is greater than the previous cycle frame ID, the current frame information is parsed and stored in the queue; If the current frame ID is greater than or equal to the previous cycle frame ID, the current frame information is discarded and the next cycle is entered for frame information preprocessing; (4) When the frame ID is reset, the current cycle ends and the next cycle of CAN message reception begins; (5) Message parsing: decrypting all the measurement point data in the same cycle and restoring them to floating point numbers, and then storing the data.