Diagnostic data communication method and device and electronic equipment
By acquiring and numbering diagnostic data, generating a diagnostic header, sending it to the receiving end and determining frame loss faults, the problem of low reliability of message transmission in the existing technology is solved, and more efficient message fault detection and transmission reliability are achieved.
Patent Information
- Application Number
- CN202410756334.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-08-23
AI Technical Summary
Existing technology is difficult to effectively detect packet frame loss failures, resulting in low reliability of packet transmission during communication between devices.
By obtaining the occupied bytes of the header template and diagnostic data, numbering and filling, a diagnostic header is generated, and sent to the receiving end. Based on the received confirmation message, it is judged whether there is a frame loss failure, and resends or generates a fault code.
It effectively improves the detection efficiency of message faults, improves the reliability of message transmission, and ensures the integrity of communication between devices.
Smart Images

Figure CN118540245A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data, and in particular to a method, device and electronic equipment for communicating diagnostic data. Background Art
[0002] With the development of communication technology and the development of smart Internet of Things technology, devices still communicate with each other in the form of messages, but the number of communication messages has increased exponentially. In various fields, in order to ensure the smooth execution of device functions, ensuring the integrity of message communications between devices has become one of the conditions for ensuring the smooth execution of device functions. However, due to the increase in the number of messages, message frame loss failures are inevitable when devices communicate with each other. It is difficult to detect message frame loss failures in related technologies, which results in incomplete messages received by devices during communication and low reliability of message transmission.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present invention provide a method, device and electronic device for communicating diagnostic data, so as to at least solve the technical problem of low reliability of message transmission caused by difficulty in detecting message frame loss failure.
[0005] According to one aspect of an embodiment of the present invention, a method for communicating diagnostic data is provided, comprising: in response to receiving diagnostic data to be sent, obtaining a header template and occupied bytes of the diagnostic data; numbering the diagnostic data based on the occupied bytes to obtain a first data frame and a first byte sequence number corresponding to the first data frame, wherein the first byte sequence number includes a start byte sequence number of the first data frame and an end byte sequence number of the first data frame; filling the header template according to the first byte sequence number to obtain a first diagnostic header corresponding to the first data frame; sending the first data frame and the first diagnostic header corresponding to the first data frame to a receiving end to obtain a communication result, wherein the communication result is used to indicate whether a confirmation message fed back by the receiving end is received, and the confirmation message is used to fill the header template according to a preset byte sequence number corresponding to the first byte sequence number.
[0006] Further, in the case that the first data frame is a single data frame, the confirmation message includes a first confirmation message corresponding to the single data frame, and the method also includes: in response to the communication result being the reception of the first confirmation message fed back by the receiving end, determining the second data frame of the diagnostic data and the second byte number corresponding to the second data frame according to the preset byte number recorded in the first confirmation message, wherein the second byte number includes the starting byte number of the second data frame and the ending byte number of the second data frame, and the starting byte number of the second data frame is the preset byte number; filling the header template according to the second byte number to obtain a second diagnostic header corresponding to the second data frame; and sending the second data frame and the second diagnostic header to the receiving end.
[0007] Furthermore, the method also includes: in response to the communication result being that the first confirmation message fed back by the receiving end is not received within the first preset time period, resending the first data frame and the first diagnostic header to the receiving end based on a preset number of transmissions to obtain a transmission result; if the transmission result is that the first confirmation message fed back by the receiving end is received within the second preset time period, executing the step of numbering the diagnostic data according to the preset byte sequence number of the first confirmation message to obtain a second data frame and a second byte sequence number corresponding to the second data frame; if the transmission result is that the first confirmation message fed back by the receiving end is not received within the second preset time period, generating a fault code for the first data frame.
[0008] Further, in the case where the first data frame is multiple data frames, the confirmation message includes a second confirmation message corresponding to the multiple data frames, and the method also includes: in response to the communication result being the receipt of a second confirmation message fed back by the receiving end, determining whether there is a target data frame among the multiple data frames according to the second confirmation message, wherein the target data frame is a data frame that has not been received by the receiving end; if the target data frame exists among the multiple data frames, sending the target data frame to the receiving end.
[0009] Furthermore, determining whether there is a target data frame among multiple data frames based on the second confirmation message, the method also includes: judging whether the preset byte sequence number recorded in the second confirmation message contains the starting byte sequence number of multiple data frames; if the preset byte sequence number does not contain the starting byte sequence number corresponding to any one of the multiple data frames, determining that there is a target data frame among the multiple data frames; if the preset byte sequence number contains the starting byte sequence numbers corresponding to multiple data frames, determining that there is no target data frame among the multiple data frames.
[0010] Furthermore, the method further includes: in response to receiving a pause message fed back by the receiving end, suspending sending a third data frame of the diagnostic data, wherein the third data frame is a data frame to be sent in the diagnostic data.
[0011] Furthermore, the method further includes: in response to receiving a continue-sending message fed back by the receiving end, sending a third data frame to the receiving end.
[0012] According to another aspect of an embodiment of the present invention, a communication device for diagnostic data is also provided, including: an acquisition module, used to acquire a header template and occupied bytes of the diagnostic data in response to receiving diagnostic data to be sent; a numbering module, used to number the diagnostic data based on the occupied bytes, and obtain a first data frame and a first byte sequence number corresponding to the first data frame, wherein the first byte sequence number includes a starting byte sequence number of the first data frame and an ending byte sequence number of the first data frame; a filling module, used to fill the header template according to the first byte sequence number, and obtain a first diagnostic header corresponding to the first data frame; a sending module, used to send the first data frame and the first diagnostic header corresponding to the first data frame to a receiving end, and obtain a communication result, wherein the communication result is used to indicate whether a confirmation message fed back by the receiving end is received, and the confirmation message is used to fill the header template according to a preset byte sequence number corresponding to the first byte sequence number.
[0013] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the method in each embodiment of the present invention is executed when the program is running.
[0014] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0015] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0016] In an embodiment of the present invention, in response to receiving diagnostic data to be sent, a header template and occupied bytes of diagnostic data are obtained; the diagnostic data is numbered based on the occupied bytes to obtain a first data frame and a first byte sequence number corresponding to the first data frame; the header template is filled according to the first byte sequence number to obtain a first diagnostic header corresponding to the first data frame; the first data frame and the first diagnostic header corresponding to the first data frame are sent to the receiving end to obtain a communication result. The present application uses the occupied bytes of the diagnostic data to number the diagnostic data to obtain a first data frame and a first byte sequence number corresponding to the first data frame, and fills the header template of the diagnostic data with the first byte sequence number, and obtains the communication result after the receiving end receives the first data frame and the first diagnostic header. Based on the communication result, it can be judged whether the message length received by the receiving end is consistent with the message length sent by the sending end to determine whether the problem of message frame loss occurs, which effectively improves the detection efficiency of message faults, thereby solving the technical problem of low reliability of message transmission caused by the difficulty in detecting the fault of message frame loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0018] Figure 1 is a flow chart of an optional method for communicating diagnostic data according to an embodiment of the present invention;
[0019] Figure 2 is a schematic structural diagram of an optional header template according to an embodiment of the present invention;
[0020] Figure 3 is an optional schematic diagram of sending a single data frame according to an embodiment of the present invention;
[0021] Figure 4 is a schematic diagram of an optional transmission of multiple data frames according to an embodiment of the present invention;
[0022] Figure 5 is a schematic diagram of a software implementation structure of an optional diagnostic data communication method according to an embodiment of the present invention;
[0023] Figure 6 It is a schematic diagram of the structure of an optional diagnostic data communication device according to an embodiment of the present invention.
[0024] Among them, the above-mentioned drawings include the following drawing marks: 21, start index or confirmation index bit; 22, stop index bit; 23, confirmation bit; 24, write confirmation bit; 25, pause bit; 26, continue bit; 31, sending end; 32, receiving end; 411, first data frame; 412, first confirmation message; 421, second data frame; 411, multiple data frames; 412, second confirmation message. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] Example 1
[0028] According to an embodiment of the present invention, an embodiment of a method for communicating diagnostic data is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] Figure 1 is a flow chart of an optional method for communicating diagnostic data according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0030] Step S102: in response to receiving the diagnostic data to be sent, obtaining the header template and the occupied bytes of the diagnostic data.
[0031] The above-mentioned diagnostic data refers to the data in the message for information exchange between devices, including but not limited to the diagnostic data in the CAN bus.
[0032] The above header template is a data template that is manually set or automatically generated and contains basic information of the diagnostic data. The basic information of the above diagnostic data includes but is not limited to the number of bits of the diagnostic data, the sequence number of the data frame in the diagnostic data, etc.
[0033] The above-mentioned byte is the basic unit of computer storage and information representation. A byte consists of 8 bits, where each bit can represent a binary number 0 or 1. The bytes mentioned in this application are occupied bytes of diagnostic data, which characterize the length of the diagnostic data.
[0034] In an optional embodiment, after receiving the diagnostic data to be sent from the sending end to the receiving end, the sending end identifies the diagnostic data to be sent, and obtains the header template corresponding to the diagnostic data by manual setting or automatic generation, and obtains the number of bytes occupied by the diagnostic data through the receiving end to obtain the length of the diagnostic output and the header template containing the diagnostic data information, wherein the basic information of the diagnostic data includes but is not limited to the number of bits of the diagnostic data, the sequence number of the data frame in the diagnostic data, etc.
[0035] Exemplarily, the header template can be set as 0-8 bits as the start index or confirmation index bit, 9-16 bits as the stop index bit, 17-24 bits as the confirmation bit, 18 bits as the write confirmation bit, 19 bits as the pause bit, 20 bits as the continue bit, and 21-24 bits as zero. The above values are for example only and are not limited here.
[0036] In the present application, the number of occupied bytes of the diagnostic data is obtained to obtain a standard for judging whether the diagnostic data has frame loss. When the length of the diagnostic data received by the receiving end is less than the obtained number of occupied bytes, it is judged that a frame loss fault has occurred; when the length of the diagnostic data received by the receiving end is equal to the obtained number of occupied bytes, it is judged that no frame loss fault has occurred.
[0037] Step S104, numbering the diagnostic data based on the occupied bytes to obtain a first data frame and a first byte sequence number corresponding to the first data frame, wherein the first byte sequence number includes a start byte sequence number of the first data frame and an end byte sequence number of the first data frame.
[0038] The above number is determined by the number of bytes occupied by the diagnostic data, and the first data frame and the first byte sequence number corresponding to the first data frame are determined.
[0039] The above starting byte sequence number is the byte position of the starting end of the first data frame in the diagnostic data.
[0040] The above-mentioned end byte sequence number is the byte position of the end end of the first data frame in the diagnostic data.
[0041] In an optional embodiment, after the receiving end obtains the bytes occupied by the diagnostic data, the diagnostic data is numbered based on the occupied bytes to obtain the position of the bytes in the diagnostic data. The diagnostic data is divided according to the actual situation in an artificially determined manner to obtain a first data frame. Among them, since the first data frame is a part of the diagnostic data, and the diagnostic data has been numbered based on the occupied bytes, the first byte sequence number of the first data frame is obtained. Among them, the first byte sequence number includes: the starting byte sequence number of the first data frame, that is, the position of the starting end of the first data frame in the diagnostic data; the ending byte sequence number of the first data frame, that is, the position of the ending end of the first data frame in the diagnostic data. Exemplarily, if the first data frame occupies the first 3 bytes of the diagnostic data, that is, the starting byte sequence number of the first data frame is 1, and the ending byte sequence number of the first data frame is 3.
[0042] In the present application, by numbering the diagnostic data based on the occupied bytes to obtain the first data frame and the first byte sequence number corresponding to the first data frame, the receiving end can determine whether the first data frame has a frame loss failure based on the first byte sequence number.
[0043] Step S106: fill the header template according to the first byte sequence number to obtain a first diagnosis header corresponding to the first data frame.
[0044] The above-mentioned filling of the header template according to the first byte sequence number refers to writing the starting byte position and the ending byte position of the first data frame in the diagnostic data in the header template according to the first byte sequence number, so that the receiving end can determine whether a frame loss failure occurs based on the length of the received first data frame.
[0045] The above-mentioned first diagnostic header is a header after filling the header template. The above-mentioned first diagnostic header is located at the front end of the first data frame and is sent to the receiving end together with the first data frame. The receiving end can analyze the first diagnostic header to obtain whether the first data frame has a frame loss failure.
[0046] In an optional embodiment, the sending end fills in the information of the starting byte position and the ending byte position of the first data frame in the diagnostic data, that is, the first byte sequence number, in the header template. The filling position is manually set according to the actual situation. After the first byte sequence number is filled in the header template, the first diagnostic header corresponding to the first data frame is obtained. Among them, the first diagnostic header is used to prompt the receiving end of the length information of the first data frame. Exemplarily, if the first data frame occupies the first 3 bytes of the diagnostic data, that is, the starting byte sequence number of the first data frame is 1, and the ending byte sequence number of the first data frame is 3, wherein, Figure 2is a schematic diagram of the structure of an optional header template according to an embodiment of the present invention, such as Figure 2 As shown, the header template is set to bits 0-8 as the start index or confirmation index bit 21, bits 9-16 as the stop index bit 22, bits 17-24 as the confirmation bit 23, bit 18 as the write confirmation bit 24, bit 19 as the pause bit 25, bit 20 as the continue bit 26, and after bits 21-24 are zero, bits 0-16 of the header template are 0000 0001 0000 0003. The above values are for example only and are not limited here.
[0047] In the present application, the first byte sequence number of the first data frame is filled into the header template to obtain a first diagnostic header for determining whether the first data frame is lost. After the first data frame is sent to the receiving end, the receiving end can provide feedback to the sending end through the first diagnostic header, and the sending end can thereby determine whether a frame loss failure occurs, thereby effectively improving the detection efficiency of frame loss failures.
[0048] Step S108, sending the first data frame and the first diagnostic header corresponding to the first data frame to the receiving end to obtain a communication result, wherein the communication result is used to indicate whether a confirmation message fed back by the receiving end is received, and the confirmation message is used to fill the header template according to the preset byte number corresponding to the first byte number.
[0049] The receiving end is the end that receives data during the data transmission process. It is responsible for receiving data from the sending end and processing it. The receiving end can be a computer, a mobile device, an embedded system, or other message receiving end.
[0050] The above-mentioned confirmation message refers to a message that the receiving end feeds back to the sending end after receiving the message sent by the sending end. The sending end can use the confirmation message to determine whether the receiving end has received the first data frame and whether the first data frame received by the receiving end has a frame loss failure.
[0051] The above communication result refers to whether the sending end has received the confirmation message fed back by the receiving end, wherein the communication result includes whether the sending end has received the confirmation message fed back by the receiving end, and whether the sending end has not received the confirmation message fed back by the receiving end.
[0052] The above-mentioned preset byte sequence number is a preset byte sequence number used to feed back a confirmation message to the sending end, wherein the preset byte sequence number can be a byte sequence number obtained by performing some processing on the first byte sequence number, and the above-mentioned processing includes but is not limited to adding a constant to the first byte sequence number, subtracting a constant from the first byte sequence number, etc., so that the sending end can obtain information on whether the first data frame has a frame loss failure by analyzing the confirmation message.
[0053] In an optional embodiment, the transmitting end sends the first data frame and the first diagnostic message corresponding to the first data frame to the receiving end, wherein the front and rear positions of the first data frame and the first diagnostic message corresponding to the first data frame are manually set according to actual conditions. After receiving the first data frame and the first diagnostic message corresponding to the first data frame, the receiving end extracts the first byte sequence number contained in the first diagnostic message, and fills the header template according to the preset byte sequence number corresponding to the first byte sequence number to obtain a confirmation message, and sends the confirmation message to the transmitting end, and the transmitting end analyzes the confirmation message to obtain a communication result, and the transmitting end can determine whether the first data frame has a frame loss failure.
[0054] Exemplarily, when the preset byte sequence number is the end byte sequence number of the first data frame in the first byte sequence number plus 1, if the first data frame occupies the first 3 bytes of the diagnostic data, that is, the start byte sequence number of the first data frame is 1, the end byte sequence number of the first data frame is 3, and the header template is set to 0-8 bits as the start index or confirmation index bit, 9-16 bits as the stop index bit, 17-24 bits as the confirmation bit, 18 bits as the write confirmation bit, 19 bits as the pause bit, 20 bits as the continue bit, and 21-24 bits as zero, then the 0-16 bits of the header template are 0000 0001 0000 0003, and the preset byte sequence number is 4 at this time, so the 0-16 bits of the confirmation message are 0000 0004 0000 0001, wherein the 1 in the 0-16 bits of the confirmation message means that the byte sequence number of the confirmation message is 1. The above numerical values are for example only and are not limited here.
[0055] In the present application, the header template is filled according to the preset byte number corresponding to the first byte number to obtain a confirmation message, which makes it easier to obtain the confirmation message, effectively improves the feedback speed of the receiving end, makes the communication results more quickly obtained, and effectively improves the user experience.
[0056] Through the above steps, in response to receiving the diagnostic data to be sent, the header template and the occupied bytes of the diagnostic data are obtained; the diagnostic data is numbered based on the occupied bytes to obtain the first data frame and the first byte sequence number corresponding to the first data frame; the header template is filled according to the first byte sequence number to obtain the first diagnostic header corresponding to the first data frame; the first data frame and the first diagnostic header corresponding to the first data frame are sent to the receiving end to obtain the communication result. The present application uses the occupied bytes of the diagnostic data to number the diagnostic data, obtain the first data frame and the first byte sequence number corresponding to the first data frame, and fills the header template of the diagnostic data with the first byte sequence number, and obtains the communication result after the first data frame and the first diagnostic header are received at the receiving end, and determines whether the problem of message frame loss occurs based on the communication result, effectively improving the detection efficiency of message faults, thereby solving the technical problem of low reliability of message transmission caused by low detection efficiency of message frame loss.
[0057] Optionally, in the case that the first data frame is a single data frame, the confirmation message includes a first confirmation message corresponding to the single data frame, and the method further includes: in response to the communication result being the receipt of the first confirmation message fed back by the receiving end, determining the second data frame of the diagnostic data and the second byte number corresponding to the second data frame according to the preset byte number recorded in the first confirmation message, wherein the second byte number includes the starting byte number of the second data frame and the ending byte number of the second data frame, and the starting byte number of the second data frame is the preset byte number; filling the header template according to the second byte number to obtain a second diagnostic header corresponding to the second data frame; and sending the second data frame and the second diagnostic header to the receiving end.
[0058] The above-mentioned second data frame is a data frame determined after determining whether the first data frame has a frame loss failure based on the preset byte sequence number recorded in the first confirmation message. When a frame loss failure occurs when the receiving end receives the first data frame, the second data frame is determined to be the first data frame, that is, the first data frame is resent. When no frame loss failure occurs when the receiving end receives the first data frame, the second data frame is determined to be a data frame after the first data frame.
[0059] The starting byte number of the above-mentioned second data frame is the byte position of the starting end of the second data frame in the diagnostic data. When a frame loss failure occurs when the receiving end receives the first data frame, the starting byte number of the second data frame is determined to be the starting byte number of the first data frame. When no frame loss failure occurs when the receiving end receives the first data frame, the starting byte number of the second data frame is determined to be the next byte number of the end byte number of the first data frame.
[0060] The above-mentioned end byte sequence number is the byte position of the end end of the second data frame in the diagnostic data. When a frame loss failure occurs when the receiving end receives the first data frame, the end byte sequence number of the second data frame is determined to be the end byte sequence number of the first data frame. When no frame loss failure occurs when the receiving end receives the first data frame, the end byte sequence number of the second data frame is determined to be the end byte sequence number of the second data frame.
[0061] Figure 3 is a schematic diagram of an optional single data frame transmission according to an embodiment of the present invention, such as Figure 3 As shown, in the case where the first data frame 321 is a single data frame, the confirmation message is a confirmation message corresponding to a single data frame, that is, a confirmation message is obtained for each data frame sent. After sending the first data frame 311 and the first diagnostic header corresponding to the first data frame to the receiving end 32, the sending end 31 receives the first confirmation message 312, and determines the second data frame 321 of the diagnostic data and the second byte sequence number corresponding to the second data frame according to the preset byte sequence number recorded in the first confirmation message 312, wherein the second byte sequence number includes the starting byte sequence number of the second data frame 321 and the ending byte sequence number of the second data frame 321, and the starting byte sequence number of the second data frame 321 is the next byte sequence number of the ending byte sequence number of the first data frame 311, and fills the header template according to the second byte sequence number to obtain the second diagnostic header corresponding to the second data frame 321, and sends the second data frame 321 and the second diagnostic header to the receiving end. Exemplarily, if the first data frame 311 occupies the first 3 bytes of the diagnostic data, when bits 0-16 of the first confirmation message 312 are 0000 0004 0000 0001, the sending end 31 determines that there is no frame loss failure when the receiving end 32 receives the first data frame 311, and thus the second data frame 321 and the second diagnostic header are normally sent to the receiving end 32. When bits 0-16 of the first confirmation message 312 are 0000 0002 0000 0001, the sending end 31 determines that there is a frame loss failure when the receiving end 32 receives the first data frame 311, and thus the first data frame 311 and the first diagnostic header are resent to the receiving end 32.
[0062] Optionally, the method also includes: in response to the communication result being that the first confirmation message fed back by the receiving end is not received within the first preset time period, resending the first data frame and the first diagnostic header to the receiving end based on a preset number of transmissions to obtain a transmission result; if the transmission result is that the first confirmation message fed back by the receiving end is received within the second preset time period, executing the step of numbering the diagnostic data according to the preset byte sequence number of the first confirmation message to obtain a second data frame and a second byte sequence number corresponding to the second data frame; if the transmission result is that the first confirmation message fed back by the receiving end is not received within the second preset time period, generating a fault code for the first data frame.
[0063] The above-mentioned first preset time period is the time threshold for the sending end to receive the confirmation message. The above-mentioned first preset time period can be set according to the time when the receiving end feeds back the confirmation message. The above-mentioned first preset time period can also be set manually according to experience and needs. The above-mentioned first preset time period can also be set according to the actual application scenario.
[0064] The above-mentioned preset number of transmissions is a threshold value of the number of times the transmitter sends data frames and diagnostic headers. The above-mentioned preset number of transmissions can be manually set according to experience and needs. The above-mentioned preset number of transmissions can also be set according to actual application scenarios.
[0065] The second preset time period is a time period during which the sending end waits for the receiving end to feed back a first confirmation message after the sending end sends the first data frame and the first diagnosis header to the receiving end again.
[0066] The above fault code is a fault code generated by the sending end to report the fault to the terminal.
[0067] In an optional embodiment, when the communication result is that the first confirmation message is not received within the first preset time period, the sending end determines that the sending fails. If the number of sending times is less than the preset number of sending times at this time, the first data frame and the first diagnostic header are sent to the receiving end again, and the receiving end is waited for to feedback the first confirmation message. If the first confirmation message is received within the second time period, the step of numbering the diagnostic data according to the preset byte sequence number of the first confirmation message to obtain the second data frame and the second byte sequence number corresponding to the second data frame is executed; if the first confirmation message is not received within the second time period, if the number of sending times is greater than or equal to the preset number of sending times at this time, a fault code of the first data frame is generated.
[0068] In the present invention, by setting a first preset time period, a second preset time period and a preset number of sending times, the number of times the sending end sends the first data frame and the first diagnostic header is limited, and the time for the sending end to receive feedback is limited, so that it is possible to timely determine whether the receiving end and the sending end have a fault that causes the first data frame to be unable to be sent normally.
[0069] Optionally, in the case that the first data frame is multiple data frames, the confirmation message includes a second confirmation message corresponding to the multiple data frames, and the method also includes: in response to the communication result being the receipt of the second confirmation message fed back by the receiving end, determining whether there is a target data frame among the multiple data frames according to the second confirmation message, wherein the target data frame is a data frame that has not been received by the receiving end; if the target data frame exists among the multiple data frames, sending the target data frame to the receiving end.
[0070] The first data frame being a plurality of data frames means that when transmitting relatively large data, a plurality of data frames are sent at one time to ensure the data transmission speed.
[0071] The second confirmation message refers to the confirmation message fed back by the receiving end to the sending end after the receiving end receives the first data frame of multiple data frames, wherein the second confirmation message includes information such as the starting byte numbers of the multiple data frames.
[0072] The above-mentioned target data frame refers to the data frame missing from the multiple data frames that the receiving end should receive, and the data frame not received by the receiving end is the target data frame. When the target data frame exists in the multiple data frames, the first data frame is transmitted incorrectly and needs to be resent. Figure 4 is a schematic diagram of an optional transmission of multiple data frames according to an embodiment of the present invention, such as Figure 4 As shown, when transmitting larger data, it is determined that the first data frame sent by the sending end 31 is a plurality of data frames 411. At this time, the confirmation message includes a second confirmation message 412 corresponding to the plurality of data frames 411. After the sending end 31 receives the second confirmation message 412 fed back by the receiving end 32, the second confirmation message 412 is analyzed to determine whether there are any missing data frames, i.e., target data frames, among the plurality of data frames 311. If there are target data frames among the plurality of data frames 411, the first data frame is resent.
[0073] In the present invention, when transmitting relatively large data, by determining whether there is a missing data frame among a plurality of data frames, it is prevented that the missing data frame may cause the receiving end to fail to operate normally.
[0074] Optionally, determining whether there is a target data frame among multiple data frames based on the second confirmation message, the method also includes: judging whether the preset byte sequence number recorded in the second confirmation message contains the starting byte sequence number of multiple data frames; if the preset byte sequence number does not contain the starting byte sequence number corresponding to any one of the multiple data frames, determining that there is a target data frame among the multiple data frames; if the preset byte sequence number contains the starting byte sequence numbers corresponding to multiple data frames, determining that there is no target data frame among the multiple data frames.
[0075] In an optional embodiment, after the transmitting end receives the second confirmation message fed back by the receiving end, the second confirmation message is judged to confirm whether the preset byte sequence number recorded in the second confirmation message contains the starting byte sequence number of multiple data frames. If it is judged that the starting byte sequence number corresponding to any data frame is missing from the preset byte sequence number recorded in the second confirmation message, it is determined that the target data frame exists in the multiple data frames, and the first data frame is resent at this time; if it is judged that the starting byte sequence number corresponding to any data frame is not missing from the preset byte sequence number recorded in the second confirmation message, it is determined that the target data frame does not exist in the multiple data frames, and the second data frame containing multiple data frames is sent at this time.
[0076] In the present invention, by judging the starting byte sequence numbers corresponding to multiple data frames, it is determined whether there is a target data frame in the multiple data frames, thereby effectively improving the judgment speed and accuracy of the target data frame.
[0077] Optionally, the method further includes: in response to receiving a pause message fed back by the receiving end, suspending sending a third data frame of the diagnostic data, wherein the third data frame is a data frame to be sent in the diagnostic data.
[0078] The above-mentioned pause message is one of the confirmation messages fed back by the receiving end, wherein the pause message refers to the confirmation message when the pause bit set in the header template is 1.
[0079] The third data frame is a data frame waiting to be sent at the sending end. When the sending end receives the pause message, it stops sending the third data frame.
[0080] In an optional embodiment, when the transmitting end receives the pause message fed back by the receiving end, the sending of the third data frame waiting to be sent is suspended. Exemplarily, the header template can be set to 0-8 bits as the start index or confirmation index bit, 9-16 bits as the stop index bit, 17-24 bits, 17 bits as the confirmation bit, 18 bits as the write confirmation bit, 19 bits as the pause bit, 20 bits as the continue bit, 21-24 bits as zero, if the 19th bit in the confirmation message is 1, then the confirmation message is a pause message, and the sending of the third data frame waiting to be sent is suspended. The above values are for example only and are not limited here.
[0081] In the present invention, by setting a pause bit in the header template, when a failure occurs at the receiving end or the sending end, the sending can be paused in time to prevent the receiving end from being damaged.
[0082] Optionally, the method further includes: in response to receiving a continue sending message fed back by the receiving end, sending a third data frame to the receiving end.
[0083] The above-mentioned continue-sending message is one of the confirmation messages fed back by the receiving end, wherein the continue-sending message refers to a confirmation message when the continue bit in the header template is set to 1.
[0084] In an optional embodiment, when the transmitting end receives the continue sending message fed back by the receiving end, the third data frame waiting to be sent is continued to be sent. Exemplarily, the header template can be set to 0-8 bits as the start index or confirmation index bit, 9-16 bits as the stop index bit, 17-24 bits as the confirmation bit, 17 bits as the confirmation bit, 18 bits as the write confirmation bit, 19 bits as the pause bit, 20 bits as the continue bit, 21-24 bits as zero, if the 20th bit in the confirmation message is 1, then the confirmation message is a continue sending message, and the third data frame waiting to be sent is continued to be sent.
[0085] Combine the following Figure 5 A preferred embodiment of the present invention is described in detail, wherein: Figure 5 FIG. 1 is a schematic diagram of a software implementation structure of an optional diagnostic data communication method according to an embodiment of the present invention. Figure 5 As shown, the software implementation structure of the communication method for diagnostic data includes: a controller area network, a controller area network (Controller Area Network, referred to as CAN) is a widely used serial communication protocol, mainly used in automobiles, industries and embedded systems. It allows multiple devices to communicate through a shared serial bus to achieve data exchange and control. In the present application, the controller area network also includes a fast controller area network (Controller Area Network with Flexible Data-Rate, referred to as CANFD). The controller area network is connected to a controller area network frame interval (Controller Area Network Inter-Frame Space, referred to as CANIF), and the controller area network frame interval is used to provide a short recovery period for the network to ensure that the controller area network bus is in an idle state before sending a new message. The controller area network frame interval is connected to a re-adjustment transmission module (Retune Transmitter, referred to as ReTx), and the re-adjustment transmission module adjusts the transmission parameters and optimizes the quality of the data sent by the sender. The re-adjustment transmission module is connected to a controller area network physical layer (Controller Area Network Transceiver, referred to as CANTP), which is used to receive and send data. The physical layer of the controller area network is connected to a data concentration module (DCM), which is used to collect data to facilitate data transmission and reception.
[0086] Example 2
[0087] According to another aspect of an embodiment of the present invention, a diagnostic data communication device is also provided, which can execute the diagnostic data communication method of the above embodiment. The specific implementation method and preferred application scenario are the same as the above embodiment and will not be described in detail here.
[0088] Figure 6 is a schematic diagram of the structure of an optional diagnostic data communication device according to an embodiment of the present invention, such as Figure 6As shown, the device includes: an acquisition module 60, which is used to obtain a header template and occupied bytes of the diagnostic data in response to receiving diagnostic data to be sent; a numbering module 62, which is used to number the diagnostic data based on the occupied bytes, and obtain a first data frame and a first byte sequence number corresponding to the first data frame, wherein the first byte sequence number includes a starting byte sequence number of the first data frame and an ending byte sequence number of the first data frame; a filling module 64, which is used to fill the header template according to the first byte sequence number, and obtain a first diagnostic header corresponding to the first data frame; a sending module 66, which is used to send the first data frame and the first diagnostic header corresponding to the first data frame to the receiving end, and obtain a communication result, wherein the communication result is used to indicate whether a confirmation message fed back by the receiving end is received, and the confirmation message is used to fill the header template according to a preset byte sequence number corresponding to the first byte sequence number.
[0089] Optionally, in the case that the first data frame is a single data frame, the confirmation message includes a first confirmation message corresponding to the single data frame, and the device also includes: a first confirmation unit, used to determine the second data frame of the diagnostic data and the second byte number corresponding to the second data frame according to the preset byte number recorded in the first confirmation message in response to the communication result being the receipt of the first confirmation message fed back by the receiving end, wherein the second byte number includes the starting byte number of the second data frame and the ending byte number of the second data frame, and the starting byte number of the second data frame is the preset byte number; a first filling unit, used to fill the header template according to the second byte number to obtain a second diagnostic header corresponding to the second data frame; and a first sending unit, used to send the second data frame and the second diagnostic header to the receiving end.
[0090] Optionally, the device also includes: a second confirmation unit, used to respond to the communication result that the first confirmation message fed back by the receiving end is not received within the first preset time period, and resend the first data frame and the first diagnostic header to the receiving end based on a preset number of transmissions to obtain a sending result; a first judgment unit, used to execute the step of numbering the diagnostic data according to the preset byte number of the first confirmation message to obtain the second data frame and the second byte number corresponding to the second data frame if the sending result is that the first confirmation message fed back by the receiving end is received within the second preset time period; and a generation unit, which generates a fault code for the first data frame if the sending result is that the first confirmation message fed back by the receiving end is not received within the second preset time period.
[0091] Optionally, in the case where the first data frame is multiple data frames, the confirmation message includes a second confirmation message corresponding to the multiple data frames, and the device also includes: a third confirmation unit, used to determine whether there is a target data frame among the multiple data frames in response to the communication result being the receipt of the second confirmation message fed back by the receiving end, according to the second confirmation message, wherein the target data frame is a data frame that has not been received by the receiving end; and a second sending unit, used to send the target data frame to the receiving end if there is a target data frame among the multiple data frames.
[0092] Optionally, the device also includes: a second judgment unit, used to judge whether the preset byte sequence number recorded in the second confirmation message contains the starting byte sequence numbers of multiple data frames; first, used to determine that there is a target data frame among the multiple data frames if the preset byte sequence number does not contain the starting byte sequence number corresponding to any one of the multiple data frames; second, used to determine that there is no target data frame among the multiple data frames if the preset byte sequence number contains the starting byte sequence numbers corresponding to multiple data frames.
[0093] Optionally, the device further includes: a pause module, configured to pause sending a third data frame of the diagnostic data in response to receiving a pause message fed back by the receiving end, wherein the third data frame is a data frame to be sent in the diagnostic data.
[0094] Optionally, the device further includes: a continuing module, configured to send a third data frame to the receiving end in response to receiving a continue sending message fed back by the receiving end.
[0095] Example 3
[0096] An embodiment of the present application further provides an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of the present invention when running.
[0097] Example 4
[0098] An embodiment of the present application further provides a computer-readable storage medium, which includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0099] Example 5
[0100] An embodiment of the present application further provides a computer program product, including a computer program, which implements the methods in various embodiments of the present invention when executed by a processor.
[0101] Example 6
[0102] The embodiments of the present application further provide a computer program, which implements the methods in the above-mentioned embodiments of the present invention when executed by a processor.
[0103] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0104] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0105] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0106] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0107] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0108] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0109] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for communicating diagnostic data, characterized in that: include: In response to receiving the diagnostic data to be sent, obtaining a header template and occupied bytes of the diagnostic data; Numbering the diagnostic data based on the occupied bytes to obtain a first data frame and a first byte sequence number corresponding to the first data frame, wherein the first byte sequence number includes a start byte sequence number of the first data frame and an end byte sequence number of the first data frame; Filling the header template according to the first byte sequence number to obtain a first diagnostic header corresponding to the first data frame; The first data frame and the first diagnostic header corresponding to the first data frame are sent to a receiving end to obtain a communication result, wherein the communication result is used to indicate whether a confirmation message fed back by the receiving end is received, and the confirmation message is used to fill the header template according to a preset byte number corresponding to the first byte number.
2. The method for communicating diagnostic data according to claim 1, characterized in that: In the case where the first data frame is a single data frame, the confirmation message includes a first confirmation message corresponding to the single data frame, and the method further includes: In response to the communication result being the reception of the first confirmation message fed back by the receiving end, determining the second data frame of the diagnostic data and the second byte sequence number corresponding to the second data frame according to the preset byte sequence number recorded in the first confirmation message, wherein the second byte sequence number includes the starting byte sequence number of the second data frame and the ending byte sequence number of the second data frame, and the starting byte sequence number of the second data frame is the preset byte sequence number; Filling the header template according to the second byte sequence number to obtain a second diagnostic header corresponding to the second data frame; The second data frame and the second diagnosis header are sent to the receiving end.
3. The method for communicating diagnostic data according to claim 2, characterized in that: The method further comprises: In response to the communication result being that the first confirmation message fed back by the receiving end is not received within a first preset time period, resending the first data frame and the first diagnostic header to the receiving end based on a preset number of transmissions to obtain a transmission result; If the sending result is that the first confirmation message fed back by the receiving end is received within a second preset time period, the step of numbering the diagnostic data according to the preset byte sequence number of the first confirmation message to obtain a second data frame and a second byte sequence number corresponding to the second data frame is performed; If the sending result is that the first confirmation message fed back by the receiving end is not received within the second preset time period, a fault code of the first data frame is generated.
4. The method for communicating diagnostic data according to claim 1, characterized in that: In the case where the first data frame is a plurality of data frames, the confirmation message includes a second confirmation message corresponding to the plurality of data frames, and the method further includes: In response to the communication result being receiving a second confirmation message fed back by the receiving end, determining whether there is a target data frame among the multiple data frames according to the second confirmation message, wherein the target data frame is a data frame that has not been received by the receiving end; If the target data frame exists in the multiple data frames, the target data frame is sent to the receiving end.
5. The method for communicating diagnostic data according to claim 4, characterized in that: Determining whether there is a target data frame among the multiple data frames according to the second confirmation message, the method further includes: Determine whether the preset byte sequence number recorded in the second confirmation message includes the starting byte sequence numbers of the multiple data frames; If the preset byte sequence number does not include a starting byte sequence number corresponding to any one of the multiple data frames, determining that the target data frame exists in the multiple data frames; If the preset byte sequence numbers include the starting byte sequence numbers corresponding to the multiple data frames, it is determined that the target data frame does not exist in the multiple data frames.
6. The method for communicating diagnostic data according to claim 1, characterized in that: The method further comprises: In response to receiving the pause message fed back by the receiving end, suspending sending the third data frame of the diagnostic data, wherein the third data frame is a data frame to be sent in the diagnostic data.
7. The method for communicating diagnostic data according to claim 6, characterized in that: The method further comprises: In response to receiving a continue sending message fed back by the receiving end, sending the third data frame to the receiving end.
8. A diagnostic data communication device, characterized in that: include: An acquisition module, configured to acquire, in response to receiving the diagnostic data to be sent, a header template and occupied bytes of the diagnostic data; a numbering module, configured to number the diagnostic data based on the occupied bytes to obtain a first data frame and a first byte sequence number corresponding to the first data frame, wherein the first byte sequence number includes a start byte sequence number of the first data frame and an end byte sequence number of the first data frame; A filling module, used to fill the header template according to the first byte sequence number to obtain a first diagnostic header corresponding to the first data frame; A sending module is used to send the first data frame and the first diagnostic header corresponding to the first data frame to a receiving end to obtain a communication result, wherein the communication result is used to indicate whether a confirmation message fed back by the receiving end is received, and the confirmation message is used to fill the header template according to a preset byte number corresponding to the first byte number.
9. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 7 when running.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 7.
