Data transmission method and device based on CAN bus, storage medium and equipment

Through the custom observation handshake protocol, the upper computer directly exchanges data with the vehicle application layer, solving the loss and security problems of the CCP protocol in data transmission, and achieving more efficient, flexible and secure data transmission.

CN119420823APending Publication Date: 2025-02-11HIGER
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411023014.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The existing CAN Calibration Protocol (CCP) can easily lead to data loss and security difficulties during data transmission, especially during connection and power-off.

Method used

Through a custom observation handshake protocol, the upper computer allows data exchange directly with the application layer of the vehicle, avoiding the need to connect to the VCU first every time the target data is obtained, thereby improving data transmission efficiency and flexibility, and passing the target index value Get data for increased security.

Benefits of technology

It improves data integrity, transmission efficiency, flexibility and security, reduces data loss when connecting to VCUs, and is difficult to crack the observation measurements corresponding to the index value when data is intercepted.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420823A_ABST
    Figure CN119420823A_ABST
Patent Text Reader

Abstract

The invention discloses a data transmission method and device based on a CAN bus, a storage medium and computer equipment, and the method comprises the steps: starting an observation handshake protocol which is a communication protocol which is based on the CAN bus and allows data exchange between an application layer and an upper computer; receiving and replying a data observation request sent by the upper computer so as to establish communication connection with the upper computer; receiving and replying a target list creating request sent by the upper computer so as to establish data connection with the upper computer; and receiving at least one target index value sent by the upper computer, searching target data corresponding to each target index value, creating row data according to each target data, and sequentially sending the row data to the upper computer, so that the upper computer constructs the target list based on the received row data, each target index value is used for indicating one target observed quantity in the target list.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automobile technology, and in particular to a data transmission method and device based on a CAN bus, a storage medium, and a computer device. Background Art

[0002] With the development of modern automobile industry, CAN Calibration Protocol (CCP) is widely used in the industry. CCP is a protocol based on CAN (Controller Area Network) bus, which allows data exchange between the host computer (such as development tools) and the slave computer (such as control unit) to calibrate and collect system parameters during development and testing.

[0003] However, each use of the CCP protocol requires connection to the VCU (Vehicle Control Unit), resulting in a large amount of data being lost or unobservable during the connection and power-on and power-off processes. In addition, data security is difficult to guarantee during data transmission. Summary of the invention

[0004] In view of this, the present application provides a data transmission method and apparatus, storage medium, and computer equipment based on a CAN bus, which can improve data integrity, data transmission efficiency, flexibility, and security.

[0005] According to one aspect of the present application, a data transmission method based on a CAN bus is provided, comprising:

[0006] Starting an observation handshake protocol, wherein the observation handshake protocol is a communication protocol based on the CAN bus that allows data exchange between the application layer and the host computer;

[0007] Receive and reply to the data observation request sent by the host computer to establish a communication connection with the host computer;

[0008] Receive and reply to the request for creating a target list sent by the host computer to establish a data connection with the host computer;

[0009] Receive at least one target index value sent by the host computer, search for target data corresponding to each target index value, create row data according to each target data, and send the row data to the host computer in sequence so that the host computer builds the target list based on the received row data, and each target index value is used to indicate a target observation value in the target list.

[0010] According to another aspect of the present application, a CAN bus-based data transmission device is provided, comprising:

[0011] A startup module, used for starting an observation handshake protocol, wherein the observation handshake protocol is a communication protocol based on a CAN bus that allows data exchange between the application layer and a host computer;

[0012] A communication connection module, used to receive and reply to the data observation request sent by the host computer to establish a communication connection with the host computer;

[0013] A data connection module, used to receive and reply to the request for creating a target list sent by the host computer, so as to establish a data connection with the host computer;

[0014] A data sending module is used to receive at least one target index value sent by the host computer, search for target data corresponding to each target index value, create row data according to each target data, and send the row data to the host computer in sequence so that the host computer builds the target list based on the received row data, and each target index value is used to indicate a target observation value in the target list.

[0015] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned data transmission method based on the CAN bus is implemented.

[0016] According to another aspect of the present application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned CAN bus-based data transmission method when executing the program.

[0017] By means of the above technical solution, the present application provides a data transmission method and device based on the CAN bus, a storage medium, and a computer device, which enables the host computer to directly exchange data with the application layer of the vehicle through a customized observation handshake protocol and after the observation handshake protocol is started. Compared with the use of traditional communication protocols, the present application does not need to connect to the VCU every time the target data is acquired, and then connect the host computer and the application layer through the VCU, thereby improving the efficiency and flexibility of data transmission, reducing the data loss caused by connecting to the VCU, and causing some data to not be observed. In addition, by obtaining the corresponding data through the target index value, it can be difficult to crack the observation value corresponding to the index value when the data is intercepted by an unknown third party, thereby improving the security of the data.

[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0020] Figure 1 A schematic diagram of a data transmission method based on a CAN bus provided in an embodiment of the present application is shown;

[0021] Figure 2 A schematic diagram of the structure of a data transmission device based on a CAN bus provided in an embodiment of the present application is shown;

[0022] Figure 3 A schematic diagram of the device structure of a computer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0023] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.

[0024] In this embodiment, a data transmission method based on CAN bus is provided, which is applied to the application layer, such as Figure 1 As shown, the method includes:

[0025] Step 101 , starting an observation handshake protocol, wherein the observation handshake protocol is a communication protocol based on the CAN bus that allows data exchange between the application layer and a host computer.

[0026] In this embodiment, before the host computer and the application layer of the whole vehicle transmit data, the observation handshake protocol is started first. It should be noted that the host computer can obtain the relevant information of the preset observation quantity in the observation list of the whole vehicle through the observation handshake protocol to achieve the effect of observing the preset observation quantity of the whole vehicle. Among them, the observation list is used to store the preset observation quantity and the corresponding preset index value. The preset observation quantity is the quantity that needs to be observed, which is sorted out by the host computer according to the whole vehicle data observed as needed. The preset index value is an index value corresponding to each preset observation quantity one by one.

[0027] Step 102, receiving and replying to the data observation request sent by the host computer to establish a communication connection with the host computer.

[0028] In this embodiment, the host computer sends a data observation request to the application layer of the vehicle. After receiving the data observation request from the host computer, the application layer of the vehicle sends information in response to the data observation request to the host computer. The host computer establishes a communication connection with the application layer of the vehicle according to the information in response to the data observation request sent by the application layer of the vehicle.

[0029] Step 103, receiving and replying to the target list creation request sent by the host computer to establish a data connection with the host computer.

[0030] In this embodiment, after the host computer establishes a communication connection with the application layer of the whole vehicle, it sends a create target list request to the application layer of the whole vehicle to request the application layer to obtain data corresponding to the preset observation quantity to be observed. The application layer of the whole vehicle sends information in response to the create target list request to the host computer. The host computer establishes a data connection with the application layer of the whole vehicle based on the information in response to the create target list request sent by the application layer of the whole vehicle.

[0031] Step 104, receiving at least one target index value sent by the host computer, searching for target data corresponding to each target index value, creating row data according to each target data, and sending the row data to the host computer in sequence, so that the host computer builds the target list based on the received row data, and each target index value is used to indicate a target observation value in the target list.

[0032] In this embodiment, after the host computer establishes a data connection with the application layer of the whole vehicle, the host computer sends the target index value corresponding to the target observation quantity to the application layer of the whole vehicle. Here, each observation quantity corresponds to an index value. The application layer of the whole vehicle obtains the target data of the corresponding target observation quantity according to each target index value, that is, obtains the target data of the corresponding target observation quantity according to each target index value. The application layer of the whole vehicle establishes corresponding row data according to each target data, and sends the row data to the host computer in sequence. The host computer constructs the target list based on the received row data.

[0033] By applying the technical solution of this embodiment, a customized observation handshake protocol is defined, and after the observation handshake protocol is started, the host computer can directly exchange data with the application layer of the vehicle. Compared with the use of traditional communication protocols, this application does not need to connect to the VCU every time the target data is acquired, and then connect the host computer and the application layer through the VCU, thereby improving the efficiency and flexibility of data transmission, reducing the data loss caused by connecting to the VCU, and causing some data to not be observed. In addition, by obtaining the corresponding data through the target index value, it is difficult to crack the observation value corresponding to the index value when the data is intercepted by an unknown third party, thereby improving the security of the data.

[0034] In the embodiment of the present application, optionally, before step 101, the following is further included:

[0035] Step 201 : reading an observation list, wherein the observation list includes a plurality of preset observation quantities and a preset index value corresponding to each of the preset observation quantities.

[0036] In this embodiment, the host computer sorts out the preset observation quantities that need to be observed based on the vehicle data that needs to be observed, and generates a preset index value corresponding to each preset observation quantity. The host computer stores the preset observation quantities and the corresponding preset index values ​​in an observation list, and sends the observation list to the application layer of the vehicle. The application layer of the vehicle reads the received observation list.

[0037] Step 202: Generate a program corresponding to the observation list that can be flashed into the electronic control unit, wherein the program includes the code and control code of the observation list.

[0038] In this embodiment, the application layer of the whole vehicle generates codes related to the observation list and corresponding control codes. After the application layer of the whole vehicle is integrated with the bottom layer, the above codes are compiled to generate a program that can be flashed into the electronic control unit.

[0039] Accordingly, the step of “searching for target data corresponding to each of the target index values” in step 104 includes: running the program through the electronic control unit to determine the target observation value corresponding to each of the target index values, and searching for target data corresponding to each of the target observation values.

[0040] In this embodiment, the application layer of the vehicle pre-generates a program to be flashed into the electronic control unit, and then runs the program through the electronic control unit to determine the target observation quantity corresponding to each target index value, and find the target data corresponding to each target observation quantity. It can be understood that the target data corresponding to each target observation quantity is the data generated corresponding to each target observation quantity.

[0041] By applying the technical solution of this embodiment and obtaining corresponding data through the target index value, security can be increased, making it difficult to crack the observation value corresponding to the index value when the data is intercepted by an unknown third party, thereby improving data security.

[0042] In the embodiment of the present application, optionally, step 103 includes:

[0043] Step 103-1, receiving a target list creation request sent by the host computer, determining the number of target observations and the list byte length based on the target list creation request, and determining the internal remaining stack space.

[0044] In this embodiment, the host computer sends a request to create a target list to the application layer of the vehicle, as shown in Table 1, which is an example of a request to create a target list. Among them, the first row of Table 1 is used to indicate the number of each byte of the above-mentioned request to create a target list. In the actual sending process, the first row of Table 1 is not sent, nor is the format of the second row of Table 1 sent. The data of the second row of Table 1 will be sent in the form of a string. The odd rows of each table below have the same function as the first row of Table 1, and the format of the even rows is consistent with the second row of Table 1. In the following, it will not be repeated. Byte0 in Table 1 is the instruction code data bit, 0x02 represents the start of sending a request to create a target list; Byte1 in Table 1 is the count bit. If the value corresponding to the count bit of the previous data exchanged between the host computer and the application layer is 0x04, then based on the previous data, Byte1 of this request to create a target list data is increased by 1 based on the previous data, that is, 0x04+1=0x05, so the data of the count bit of Byte1 in Table 1 is 0x05 in this request to create a target list data. Byte2-byte3 represents the number of target observations that need to be observed. In this example, "0x000x14" represents 20 target observations. Byte4-byte7 represents the list byte length, that is, the total byte length of the target index value corresponding to the target observations included in the target list to be created. In this example, "0x00 0x000x0f 0xff" represents that the list byte length is 4095. The application layer of the whole vehicle receives the target list creation request sent by the host computer, determines the number of target observations and the list byte length, and at the same time, the application layer of the whole vehicle can also determine the remaining internal stack space.

[0045] Table 1

[0046] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0x02 0x05 0x00 0x14 0x00 0x00 0x0f 0xff

[0047] Step 103-2, compare the number of the target observations with the total amount of the preset observations to obtain a first comparison result, and compare the internal remaining stack space with the list byte length to obtain a second comparison result.

[0048] In this embodiment, in order to verify the rationality of the request to create a target list sent by the host computer, the number of target observations can be compared with the total amount of preset observations, so as to obtain a first comparison result. In addition, in order to verify whether the application layer has enough stack space to store the target data, the remaining stack space in the application layer and the list byte length can be compared, so as to obtain a second comparison result.

[0049] Step 103-3, based on the first comparison result and the second comparison result, generate a reply message corresponding to the request to create a target list, and send the reply message to the host computer, so that when the host computer parses the first comparison result in the reply message to indicate that the number of target observations is not greater than the total amount of the preset observations, and the internal remaining stack space is not less than the list byte length, establish a data connection with the host computer.

[0050] In this embodiment, the application layer of the vehicle generates a reply message corresponding to the request to create a target list according to the first comparison result and the second comparison result, and sends the reply message to the host computer. As shown in Table 2, an example of the reply message is given. Byte0 in Table 2 is the instruction code data bit, and 0xFF represents the data reply. Byte1 in Table 2 is the count bit, and the count starts from the successful count. On the basis that the value corresponding to the count bit of the previous data is 0x05, the operation 0x05+1=0x06 is performed, and the data of the Byte1 count bit is 0x06 in this request data to create a target list. Byte2 represents the first comparison result. When the first comparison result is 0x01, it means that the number of target observations is not greater than the total amount of preset observations. When the first comparison result is 0x00, it means that the number of target observations is greater than the total amount of preset observations. Byte3 represents the second comparison result. 0x01 represents that the internal remaining stack space in the second comparison result is not less than the list byte length. When the second comparison result is 0x00, it means that the internal remaining stack space is less than the list byte length, and the data overflows. Byte4-byte7 are placeholders and have no meaning. The host computer parses the reply information sent by the vehicle. When Byte2 and Byte3 are both 0x01, that is, the host computer parses the first comparison result in the reply information indicating that the number of target observations is not greater than the total number of preset observations, and the internal remaining stack space is not less than the list byte length, a data connection is established between the host computer and the application layer of the vehicle.

[0051] Table 2

[0052] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xFF 0x06 0x01 0xFF 0x01 0xFF 0xFF 0xFF

[0053] Optionally, the host computer parses the reply information sent by the vehicle. When Byte2 is 0x00, the host computer chooses to disconnect from the application layer of the vehicle and generates a first prompt message so that the operator can check whether the target observation quantity in the target list is correct after seeing the first prompt message.

[0054] Optionally, the host computer parses the reply information sent by the vehicle, and when Byte3 is 0x00, the host computer chooses to disconnect from the application layer of the vehicle and sends a second prompt message so that the operator reduces the number of target observations after receiving the second prompt message.

[0055] Before obtaining target data from the application layer, the embodiment of the present application first verifies the number of target observation quantities and the internal remaining stack space, and only establishes a data connection after the verification is passed, which can ensure the smooth transmission of subsequent target data and improve the accuracy of target data transmission.

[0056] In an embodiment of the present application, optionally, the data observation request also includes a data sending method. In step 104, creating row data according to the target data includes: determining the number of remaining placeholders included in each row of data, and writing each target data into the remaining placeholders of each row in turn according to the data sending method, to obtain multiple row data corresponding to each target data, the first bit in each row of data is used to indicate the row number, and the remaining placeholders are used to write the target data, and when the target data corresponding to any target index value is insufficient to complete the remaining placeholders of each row of data, the target data corresponding to the next target index value continues to be written into the uncompleted remaining placeholders, and the last character in the target data corresponding to any target index value is adjacent to the first character in the target data corresponding to the next target index value.

[0057] In this embodiment, there are two data transmission modes, one is to start from the high bit of the data, and the other is to start from the low bit of the data. In this embodiment, each row of data may include a first bit and remaining bits, and the number of remaining bits may be adjusted according to demand.

[0058] In a specific embodiment, it is assumed that each row of data corresponds to 7 remaining placeholders. Take Table 3 for example, which is target data 1 with 4 placeholders, Table 4 for target data 2 with 2 placeholders, Table 5 for target data 3 with 4 placeholders, and Table 6 for target data 4 with 4 placeholders. In this embodiment, each target data is filled into the remaining placeholders in sequence according to the data sending method. When every 7 remaining placeholders are filled, a row of data is obtained, and then two row data corresponding to the above 4 target data can be obtained. As shown in Table 7, an example of row data is given. Among them, the data sending method in this embodiment is to send from the low bit of the data. For each row of data, the first bit in the row data is used to indicate the row number, that is, which row of data the current row data is; the remaining placeholders, that is, the non-first bit of each row of data, are used to write the target data. As shown in the first row of Table 7, when the target data 1 is not sufficient to complete the remaining placeholders of the corresponding row data, the target data 2 corresponding to the next target index value continues to be written into the remaining placeholders that were not completed last time, and the last character in the target data corresponding to any of the above target index values ​​is adjacent to the first character in the target data corresponding to the next target index value.

[0059] Table 3

[0060] 1-1 1-2 1-3 1-4

[0061] Table 4

[0062] 2-1 2-2

[0063] Table 5

[0064] 3-1 3-2 3-3 3-4

[0065] Table 6

[0066] 4-1 4-2 4-3 4-4

[0067] Table 7

[0068] 1 3-1 2-2 2-1 1-4 1-3 1-2 1-1 2 4-4 4-3 4-2 4-1 3-4 3-3 3-2

[0069] The embodiment of the present application connects each target data end to end. Compared with the previous data transmission method in which each target data occupies a row, the embodiment of the present application can reduce transmission overhead and increase transmission efficiency.

[0070] In an embodiment of the present application, optionally, before determining the remaining number of placeholders included in each row of data, the method further includes: creating a reply list, the reply list including a data reply identifier and a list number identifier, and sending the reply list to the host computer; accordingly, the method further includes: when the number of row data corresponding to the reply list is greater than a preset row number threshold corresponding to the number identifier, creating a new reply list, sending the new reply list to the host computer, and creating row data of the new reply list based on the remaining target data.

[0071] In this embodiment, the present application pre-sets the maximum value of the row data included in each reply list, that is, the preset row number threshold.

[0072] Before using the target data to generate row data, a reply list can be created first. The reply list can include a data reply identifier and a list number identifier, wherein the data reply identifier is used to indicate that the specific function of the list is to reply, and the list number identifier is used to indicate the specific number of the list. The reply list can then be sent to the host computer.

[0073] After creating a reply list and sending the reply list to the host computer, the application layer can generate each row data and send the row data to the host computer in sequence. The application layer can also monitor the number of row data sent. If the monitoring finds that the number of row data that has been sent is greater than the preset row number threshold corresponding to the above-mentioned number identification, then a new reply list can be created at this time. For example, in the first reply list, the list number is identified as 1, and the corresponding preset row number threshold is 200 rows. Then when it is monitored that the number of row data that has been sent is 200, a reply list with a list number identified as 2 can be created at this time, and then the row data under the reply list with the list number identified as 2 can be generated according to the remaining target data. In this way, after the host computer receives the reply list with the list number identified as 2, the row data received thereafter can be defaulted to the row data under the reply list No. 2. As shown in Table 8, a reply list and row data of an embodiment of the present application are shown. Among them, Byte0 in the first row of data in Table 8 is the instruction code data bit, and 0xFF represents data reply; Byte1 is the list number identifier, in this case 0x01 represents the reply list numbered 1, and Byte2-7 are placeholders and meaningless. The third and fifth rows of Table 8 are two rows of data under the reply list numbered 1, respectively. Among them, Byte0 is the row number of each row of data. When the maximum value of the row data in Table 8 is the preset row number threshold and the target data has not been sent, a second reply list can be created, as shown in Table 9. Byte0 of Table 9 is the instruction code data bit, 0xFF represents data reply; Byte1 is the list number identifier, in this case 0x02 represents the reply list numbered 2. The row data under the reply list numbered 2 is in the same format as the row data under the reply list numbered 1, and will not be repeated here.

[0074] Table 8

[0075] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xFF 0x01 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 1 3-1 2-2 2-1 1-4 1-3 1-2 1-1 Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 2 4-4 4-3 4-2 4-1 3-4 3-3 3-2

[0076] Table 9

[0077] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xFF 0x02 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

[0078] In an embodiment of the present application, optionally, after sending the row data to the host computer in sequence, the method further includes: parsing the reissue information sent by the host computer to obtain the list number and target row number of the reply list; obtaining the target byte according to the list number and the target row number; and sending the target byte to the host computer.

[0079] In this embodiment, the host computer parses the received reply list and the corresponding row data, determines the missing information, and sends the list number and target row number corresponding to the missing information as reissue information to the application layer of the whole vehicle. As shown in Table 10, an example of reissue information sent by the host computer is given. Among them, Byte0 of Table 10 is the instruction code data bit, 0x14 represents the need to reissue data; Byte1 represents the list number identifier of the reply list, 0x01 represents the list numbered 1; Byte2 represents the row number, 0x11 represents 17 rows; Byte3-7 are placeholders. The application layer of the whole vehicle parses the reissue information sent by the host computer, obtains the list number and target row number of the reply list, and according to the list number and target row number, the target byte that the host computer has not received can be found, and then the target byte can be sent to the host computer.

[0080] Table 10

[0081] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0x14 0x01 0x11 0xFF 0xFF 0xFF 0xFF 0xFF

[0082] In an embodiment of the present application, optionally, after receiving at least one target index value sent by the host computer, the method also includes: determining the number of the target index values, and comparing the relationship between the number of the target index values ​​and the number of the target observation quantities; when the number of the target index values ​​is equal to the number of the target observation quantities, searching for target data corresponding to each of the target index values.

[0083] Optionally, when the number of target index values ​​is not equal to the number of target observation quantities, the host computer resends the target index values ​​to the application layer of the entire vehicle.

[0084] The embodiment of the present application greatly improves the reliability of data transmission by checking the quantity of target index values.

[0085] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, another data transmission method based on the CAN bus is provided, the method comprising:

[0086] Step 401, generation and application of observation list.

[0087] The host computer sorts out the preset observation quantities that need to be observed according to the vehicle data that needs to be observed, and generates a preset index value corresponding to each preset observation quantity. The host computer stores the above preset observation quantities and the corresponding preset index values ​​in the observation list. As shown in Table 11, an observation quantity table of an embodiment of the present application is shown. The observation list can then be sent to the application layer of the vehicle.

[0088] Table 11

[0089] Preset index value Parameter name (preset observed value) Data type 1 Motor_real_torque float32 2 Motor_real_speed Uint16 3 Parameter_3 Bool 4 Parameter_4 float32 5 Parameter_5 Uint16 6 Parameter_6 Bool 7 Parameter_7 float32

[0090] The application layer of the vehicle reads the received observation list and generates the code related to the observation list and the corresponding control code. After the application layer of the vehicle is integrated with the bottom layer, the above code is compiled to generate a program that can be flashed into the electronic control unit.

[0091] Step 402, data interaction process.

[0092] Before the host computer and the application layer of the vehicle transmit data, the observation handshake protocol is started first. It should be noted that the host computer can establish a communication connection and a data connection with the application layer of the vehicle through the observation handshake protocol to obtain the relevant information of the preset observation quantity in the observation list of the vehicle, so as to achieve the effect of observing the preset observation quantity of the vehicle.

[0093] Step 402-1, establish a communication connection between the host computer and the application layer of the vehicle.

[0094] The host computer sends a data observation request to the application layer of the vehicle through the observation handshake protocol. As shown in Table 12, an example of a data observation request is given. Byte0 of Table 12 is the instruction code data bit, 0x01 represents the connection request; Byte1 represents the count, which represents the number of connection requests in this instruction; Byte2 represents the data sending mode, that is, whether to send from the high bit of the data or from the low bit, 0x01 represents sending from the high bit, and 0x02 represents sending from the low bit; Byte3-Byte7 represent placeholders, and 0xFF must be sent. It should be noted that the odd rows of Table 12 are used to illustrate the labels of the byte placeholders of the above data observation request. In the actual sending process, the odd rows of Table 12 are not sent, nor are the formats of the even rows of Table 12 sent. The data of the even rows of Table 12 will be sent in the form of a string. The odd rows of the tables below have the same function as the odd rows of Table 12, and the format of the even rows is consistent with the even rows of Table 12. In the following, it will not be repeated.

[0095] Table 12

[0096] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0x01 0x01 0x01 0xFF 0xFF 0xFF 0xFF 0xFF

[0097] After receiving the data observation request from the host computer, the application layer of the vehicle sends the information in response to the data observation request to the host computer three times. As shown in Tables 13 to 15, three examples of responding to data observation requests are given to represent successful counting. Byte0 in Table 13 is the instruction code data bit, 0xFF represents the data reply; Byte1 represents the lower computer, i.e. the vehicle identification code, 0x01 represents the device numbered 1; Byte2 represents the count code response, and the count code of the reply is the accumulation of the count code of Byte2 in the host computer.

[0098] Table 13

[0099] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xFF 0x01 0x02 0xFF 0xFF 0xFF 0xFF 0xFF

[0100] Table 14

[0101] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xFF 0x01 0x03 0xFF 0xFF 0xFF 0xFF 0xFF

[0102] Table 15

[0103] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xFF 0x01 0x04 0xFF 0xFF 0xFF 0xFF 0xFF

[0104] The upper computer establishes a communication connection with the vehicle application layer according to the information received in response to the data observation request sent by the vehicle application layer.

[0105] Step 402-2, establish a data connection between the host computer and the application layer of the vehicle.

[0106] The host computer sends a request to create a target list to the application layer of the vehicle, as shown in Table 1. Byte0 in Table 1 is the instruction code data bit, 0x02 represents the start of sending the data list, which is the target index value corresponding to the target observation quantity included in the target list to be created; Byte1 in Table 1 is the count bit, and the count starts from the successful count. If the value corresponding to the count bit of the previous data is 0x04, then based on the previous data, the processing process of Byte1 of this create target list request data is 0x04+1=0x05, that is, the data of the Byte1 count bit in Table 2 is 0x05 in this create target list request data. Byte2-byte3 represents the number of target observation quantities to be observed. In this example, 0x000x14 represents 20 target observation quantities. Byte4-byte7 represents the list byte length, that is, the total byte length of the target index value corresponding to the target observation quantity included in the target list to be created. In this example, "0x000x00 0x0f 0xff" represents that the target list length is 4095.

[0107] In this embodiment, the application layer of the whole vehicle receives the request to create a target list sent by the upper computer, determines the number of target observations and the byte length of the list, and determines the internal remaining stack space. The number of target observations is compared with the total amount of preset observations to obtain a first comparison result, and the internal remaining stack space is compared with the byte length of the list to obtain a second comparison result. According to the first comparison result and the second comparison result, a reply message corresponding to the request to create a target list is generated. As shown in Table 2, an example of the reply message is given. Byte0 in Table 2 is the instruction code data bit, and 0xFF represents the data reply. Byte1 in Table 2 is the counting bit, and the counting starts from the successful counting. On the basis of the previous data of 0x05, the operation 0x05+1=0x06 is performed, and the data of the Byte1 counting bit in this request data to create a target list is 0x06. Byte2 represents the first comparison result, 0x01 means that the number of target observations in the first comparison result is not greater than the total amount of preset observations, and 0x00 means that the number of target observations in the first comparison result is greater than the total amount of preset observations. Byte3 represents the second comparison result. 0x01 represents that the internal remaining stack space in the second comparison result is not less than the list byte length. 0x00 represents that the internal remaining stack space in the second comparison result is less than the list byte length, and the data overflows. Byte4-byte7 are placeholders and have no meaning.

[0108] The host computer parses the reply information sent by the application layer of the whole vehicle. When Byte2 and Byte3 are both 0x01, that is, the first comparison result parsed by the host computer in the reply information indicates that the number of target observations is not greater than the total amount of the preset observations, and the internal remaining stack space is not less than the list byte length, a data connection is established between the host computer and the application layer of the whole vehicle.

[0109] The host computer parses the reply information sent by the vehicle. When Byte2 is 0x00, the host computer will choose to disconnect the application layer of the vehicle and send a prompt message so that the operator will check the observation list after receiving the prompt message.

[0110] The host computer parses the reply information sent by the vehicle. When Byte3 is 0x00, the host computer will choose to disconnect the application layer of the vehicle and send a prompt message to enable the operator to reduce the number of target observations after receiving the prompt message.

[0111] Step 402-3, the host computer sends the target index value to the application layer of the whole vehicle. As shown in Table 16, an example of the host computer sending the target index value to the application layer of the whole vehicle is given. Byte0 of Table 16 is the instruction code data bit, 0x04 represents the start of sending the target index value; Byte1-Byte2 is the target index value 1 corresponding to the target observation quantity 1, in this example, it is "0x00 0x01" or 1; Byte3-4 is the target index value 2 corresponding to the target observation quantity 2, in this example, it is "0x00 0x02" or 2; Byte5-6 is the target index value 3 corresponding to the target observation quantity 3, in this example, it is "0x00 0x03" or 3; Byte7 is a connector, when the data corresponding to Byte7 is 0xee, it means that the target index value corresponding to the target observation quantity in the target list has not been sent, when it is 0xff, it means that the target index value corresponding to the target observation quantity in the target list has been sent.

[0112] Table 16

[0113] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0x04 0x00 0x01 0x00 0x02 0x00 0x03 0xee

[0114] When the data corresponding to Byte7 shown in Table 16 is 0xee, it means that the target index value of the host computer has not been sent out, and the host computer continues to send the remaining target index values. As shown in Table 17, an example of the host computer continuing to send the remaining target index values ​​is given. Byte0 in Table 17 is the instruction code data bit, 0x04 represents the start of sending the target index value; Byte1-Byte2 is the target index value 16 corresponding to the target observation quantity 16, which is "0x00 0x10" or 16 in this example; Byte3-4 is the target index value 17 corresponding to the target observation quantity 17, which is "0x00 0x02" or 17 in this example; Byte5-6 is the target index value 18 corresponding to the target observation quantity 18, which is "0x00 0x03" or 18 in this example; Byte7 is a connector. When the value corresponding to Byte7 is 0xff, it means that all the target index values ​​corresponding to the target observation quantities in the target list to be established have been sent out.

[0115] Table 17

[0116] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0x04 0x00 0x10 0x00 0x11 0x00 0x12 0xff

[0117] After the application layer of the vehicle receives the target index value sent by the host computer, it determines the number of the received target index values, and compares the relationship between the number of received target index values ​​and the number of target observation quantities in step 402-2 to generate verification information. As shown in Table 18, an example of verification information is given. Byte0 in Table 18 is the instruction code data bit, 0xFF represents the data reply; Byte1 is the verification result, when the value of Byte1 is 0x01, it means that the number verification is passed, and the number of the target index values ​​is equal to the number of the target observation quantities; when the value of Byte1 is 0x02, it means that the number verification is not passed, then the host computer enters 0x04 again to resend the target index value corresponding to the target observation quantity in the target list.

[0118] Table 18

[0119] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xFF 0x01 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

[0120] Step 402-4: the application layer of the vehicle sends corresponding data according to the above target index value.

[0121] The application layer of the whole vehicle obtains the target data of the corresponding target observation quantity according to each target index value, that is, obtains the target data of the corresponding target observation quantity according to each target index value.

[0122] Before using the target data to generate row data, a reply list can be created first. The reply list can include a data reply identifier and a list number identifier, wherein the data reply identifier is used to indicate that the specific function of the list is to reply, and the list number identifier is used to indicate the specific number of the list. The reply list can then be sent to the host computer.

[0123] The maximum value of the row data included in each reply list is preset, that is, the preset row number threshold. As shown in Table 19, an example is given when the number of rows in the reply list is the preset row number threshold. The value corresponding to Byte0 in Table 19 is the maximum row number of the first reply list, 0xef.

[0124] After creating a reply list and sending it to the host computer, the application layer can generate each row of data and send the row of data to the host computer in sequence. The application layer can also monitor the number of row data sent. If the monitoring finds that the number of row data sent is greater than the preset row number threshold corresponding to the above number identification, then a reply list with a list number identification of 2 can be created at this time. As shown in Table 20, an example of the second reply list is given. Byte0 of the first row of Table 20 is the instruction code data bit, 0xFF represents the data reply; Byte1 is the reply list number, in this example 0x02 represents the second reply list, and Byte2-7 is a placeholder and meaningless. The fourth and sixth rows are the row data of the second reply list. Then continue to generate the row data under the reply list with the list number identification of 2 according to the remaining target data. In this way, after the host computer receives the reply list with the list number identification of 2, the row data received thereafter can be defaulted to the row data under the reply list No. 2.

[0125] Table 19

[0126] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xef 0x00 0x01 0x00 0x02 0x00 0x03 0x1f

[0127] Table 20

[0128] Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 0xFF 0x02 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 1 3-1 2-2 2-1 1-4 1-3 1-2 1-1 Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 2 5-1 4-3 4-2 4-1 3-4 3-3 3-2

[0129] Optionally, the host computer parses the reply list and corresponding multiple rows of data received from the vehicle application layer according to the target index value, the target observation quantity corresponding to each target index value, and the data type corresponding to each target index value. Since each row of data contains multiple data, by identifying the data type corresponding to each data in the row of data, when a row of data includes target data corresponding to multiple target observation quantities, it is possible to directly and successfully identify which data belongs to the previous target observation quantity and which data belongs to the next target observation quantity (the target data of the same target observation quantity have the same data type). As shown in Table 21, an example of a parsed list obtained after parsing multiple rows of data is given. Through the data type corresponding to the target observation quantity, the character strings connected at the beginning and the end in each row of data can be separated according to the corresponding data type, thereby obtaining the data corresponding to each target observation quantity.

[0130] Optionally, the target index value may be any preset index value listed in the observation list.

[0131] Table 21

[0132]

[0133] Optionally, the value of the target data corresponding to the parsed target index value is displayed on the screen in the form of a curve or a numerical value.

[0134] By applying the technical solution of this embodiment, by customizing the observation handshake protocol, and after the observation handshake protocol is started, the host computer can directly exchange data with the application layer of the whole vehicle. Compared with the use of traditional communication protocols, this application does not need to connect to the VCU every time the target data is acquired, and then connect the host computer and the application layer through the VCU, thereby improving the efficiency and flexibility of data transmission, reducing the data loss caused by connecting to the VCU, and causing some data to not be observed. In addition, by obtaining the corresponding data through the target index value, it can be difficult to crack the observation value corresponding to the index value when the data is intercepted by an unknown third party, thereby improving the security of the data.

[0135] Further, as Figure 1 The specific implementation of the method, the embodiment of the present application provides a data transmission device based on the CAN bus, such as Figure 2 As shown, the device comprises:

[0136] A startup module, used for starting an observation handshake protocol, wherein the observation handshake protocol is a communication protocol based on the CAN bus that allows data exchange between the application layer and the host computer;

[0137] A communication connection module, used to receive and reply to the data observation request sent by the host computer to establish a communication connection with the host computer;

[0138] A data connection module, used to receive and reply to the request for creating a target list sent by the host computer, so as to establish a data connection with the host computer;

[0139] A data sending module is used to receive at least one target index value sent by the host computer, search for target data corresponding to each target index value, create row data according to each target data, and send the row data to the host computer in sequence so that the host computer builds the target list based on the received row data, and each target index value is used to indicate a target observation value in the target list.

[0140] It should be noted that for other corresponding descriptions of the functional units involved in the CAN bus-based data transmission device provided in the embodiment of the present application, reference can be made to Figure 1 The corresponding description in the method will not be repeated here.

[0141] The present application also provides a computer device, which may be a personal computer, a server, a network device, etc. Figure 3As shown, the computer device includes a bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store location information. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in each method embodiment are implemented.

[0142] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0143] In one embodiment, a computer-readable storage medium is provided. The computer-readable storage medium may be non-volatile or volatile, and stores a computer program thereon. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0144] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0145] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0146] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0147] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0148] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A data transmission method based on CAN bus, characterized in that: Applied to the application layer, including: Starting an observation handshake protocol, wherein the observation handshake protocol is a communication protocol based on the CAN bus that allows data exchange between the application layer and the host computer; Receive and reply to the data observation request sent by the host computer to establish a communication connection with the host computer; Receive and reply to the request for creating a target list sent by the host computer to establish a data connection with the host computer; Receive at least one target index value sent by the host computer, search for target data corresponding to each target index value, create row data according to each target data, and send the row data to the host computer in sequence so that the host computer builds the target list based on the received row data, and each target index value is used to indicate a target observation value in the target list.

2. The method according to claim 1, characterized in that Before starting the observation handshake protocol, the method further includes: Reading an observation list, wherein the observation list includes a plurality of preset observation values ​​and a preset index value corresponding to each of the preset observation values; Generating a corresponding program that can be flashed into an electronic control unit according to the observation list, the program including a code and a control code of the observation list; Accordingly, searching for target data corresponding to each target index value includes: The program is run by the electronic control unit to determine the target observation value corresponding to each target index value, and to search for target data corresponding to each target observation value.

3. The method according to claim 1, characterized in that: The receiving and replying to the target list creation request sent by the host computer to establish a data connection with the host computer includes: Receive a target list creation request sent by the host computer, determine the number of target observations and the list byte length based on the target list creation request, and determine the internal remaining stack space; Comparing the number of the target observations with the total amount of the preset observations to obtain a first comparison result, and comparing the internal remaining stack space with the list byte length to obtain a second comparison result; Based on the first comparison result and the second comparison result, a reply message corresponding to the request to create a target list is generated, and the reply message is sent to the host computer, so that when the host computer parses the first comparison result in the reply message to indicate that the number of target observations is not greater than the total amount of the preset observations, and the internal remaining stack space is not less than the list byte length, a data connection is established with the host computer.

4. The method according to any one of claims 1 to 3, characterized in that The data observation request also includes a data sending method; The step of creating row data according to each target data comprises: Determine the number of remaining placeholders included in each row of data, and write each target data into the remaining placeholders of each row in sequence according to the data sending method, so as to obtain multiple row data corresponding to each target data, wherein the first bit in each row of data is used to indicate the row number, and the remaining placeholders are used to write the target data; when the target data corresponding to any target index value is insufficient to complete the remaining placeholders of each row of data, the target data corresponding to the next target index value is continuously written into the uncompleted remaining placeholders, and the last character in the target data corresponding to any target index value is adjacent to the first character in the target data corresponding to the next target index value.

5. The method according to claim 4, characterized in that Before determining the number of remaining placeholders included in each row of data, the method further includes: Creating a reply list, the reply list including a data reply identifier and a list number identifier, and sending the reply list to the host computer; Accordingly, the method further comprises: When the number of row data corresponding to the reply list is greater than the preset row number threshold corresponding to the numbering identifier, a new reply list is created, the new reply list is sent to the host computer, and row data of the new reply list is created according to the remaining target data.

6. The method according to claim 5, characterized in that After sending the row data to the host computer in sequence, the method further includes: Parsing the reissue information sent by the host computer to obtain the list number and target row number of the reply list; According to the list number and the target row number, obtaining a target byte; The target byte is sent to the host computer.

7. The method according to any one of claims 1 to 3, characterized in that After receiving at least one target index value sent by the host computer, the method further includes: Determining the number of the target index values, and comparing the relationship between the number of the target index values ​​and the number of the target observations; When the number of the target index values ​​is equal to the number of the target observations, the target data corresponding to each of the target index values ​​is searched.

8. A data transmission device based on CAN bus, characterized in that: include: A startup module, used for starting an observation handshake protocol, wherein the observation handshake protocol is a communication protocol based on the CAN bus that allows data exchange between the application layer and the host computer; A communication connection module, used to receive and reply to the data observation request sent by the host computer to establish a communication connection with the host computer; A data connection module, used to receive and reply to the request for creating a target list sent by the host computer, so as to establish a data connection with the host computer; A data sending module is used to receive at least one target index value sent by the host computer, search for target data corresponding to each target index value, create row data according to each target data, and send the row data to the host computer in sequence so that the host computer builds the target list based on the received row data, and each target index value is used to indicate a target observation value in the target list.

9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.