Data transmission method and device based on K line and related equipment

In remote diagnosis of automobiles, the byte reception time is obtained using the K-line, the target byte interval is calculated, and the message data is assembled, the transmission timeout problem caused by network fluctuations is solved, and the reliability and stability of data transmission is improved.

CN120050288APending Publication Date: 2025-05-27LAUNCH TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510196912.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

In the automotive remote diagnosis scenario, due to network fluctuations, it is difficult to ensure that the network delay meets the strict requirements of the KWP2000 protocol, resulting in too large byte intervals, causing transmission timeout problems.

Method used

The reception time of the first byte and the second byte is obtained through the K-line, the target byte interval is calculated, and the message data is assembled according to the data status, and transmitted to the server to avoid transmission timeout caused by network fluctuations.

Benefits of technology

It effectively avoids excessive byte intervals caused by network fluctuations, prevents transmission timeout, and improves the reliability and stability of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120050288A_ABST
    Figure CN120050288A_ABST
Patent Text Reader

Abstract

The invention provides a data transmission method and device based on a K line and related equipment, and the method comprises the steps: obtaining first data at a first byte receiving moment through the K line, the first data comprising first byte data and a first data state; acquiring second data at a second byte receiving moment through the K line; the second data comprises second byte data and a second data state; the second byte receiving moment is later than the first byte receiving moment; determining a target byte interval according to the first byte receiving moment and the second byte receiving moment; determining a target byte data state according to the first data state, the second data state and the target byte interval; and assembling the first byte data, the second byte data, the target byte interval and the target byte data state to obtain first message data, and transmitting the first message data to a server of the electronic equipment. The problem of overtime transmission caused by overlarge byte interval of each piece of data due to network fluctuation can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of telecommunication technology, and in particular to a K-line based data transmission method, apparatus and related equipment. Background Art

[0002] At present, in the field of automobile fault diagnosis, major automobile companies have formulated relevant standards and protocols for data exchange between diagnostic equipment and automobile control units. Among them, the diagnostic service of Keyword protocol 2000 (KWP2000) does not rely on a specific network medium, and its application layer can be ported to any physical layer and data link layer protocol. The protocol implements a complete set of on-board diagnostic services and has been widely used in the automotive field. However, the KWP2000 protocol has strict requirements on timing, especially the byte interval of each frame of data is very high, and an interval exceeding 20 milliseconds will be considered a timeout.

[0003] In the scenario of remote car diagnosis, it is difficult to ensure that the network latency always meets the requirements due to network fluctuations, especially when users use wireless networks such as Wi-Fi or 4G, the network is even more unreliable. Network fluctuations can easily cause the byte interval to exceed, resulting in diagnosis failure. Therefore, how to avoid the transmission timeout problem caused by the large byte interval of each data due to network fluctuations needs to be solved urgently. Summary of the invention

[0004] The embodiments of the present application provide a K-line-based data transmission method, apparatus, and related equipment, which can avoid the transmission timeout problem caused by excessive byte intervals between each data due to network fluctuations.

[0005] In a first aspect, an embodiment of the present application provides a K-line-based data transmission method, which is applied to an electronic device, wherein the electronic device includes: a server and a client, wherein the server and the client perform two-way communication through a cloud platform, and the client communicates with a target vehicle through the K-line, and the method includes:

[0006] Acquire first data at the time of receiving the first byte through the K line, wherein the first data includes: first byte data and first data state;

[0007] Acquire second data at the time of receiving the second byte through the K line; the second data includes: second byte data and second data state; the time of receiving the second byte is later than the time of receiving the first byte;

[0008] Determine a target byte interval according to the first byte receiving time and the second byte receiving time;

[0009] Determine the target byte data status according to the first data status, the second data status, and the target byte interval;

[0010] Assemble the first byte data, the second byte data, the target byte interval, and the target byte data status to obtain first message data, and transmit the first message data to the server of the electronic device through the cloud platform.

[0011] In a second aspect, an embodiment of the present application provides a K-line based data transmission method, which is applied to an electronic device. The electronic device includes: a server and a client, and the server includes a data buffer; the server and the client communicate bidirectionally through the cloud platform. The method includes:

[0012] Receive first message data from the server; the first message data includes: n byte data, a first byte interval, and a first byte data status; n is an integer greater than 1;

[0013] Obtain cached data from the data buffer to obtain first cached data;

[0014] Send the first cached data to the cloud platform through the server according to the first byte interval, and clear the data buffer;

[0015] When the first byte data status is the start status or the continuous status, generate second cached data according to the n byte data, and save the second cached data to the data buffer.

[0016] In a third aspect, an embodiment of the present application provides a K-line based data transmission device, which is applied to an electronic device. The electronic device includes: a server and a client, and the server and the client communicate bidirectionally through the cloud platform. The client communicates with a target vehicle through a K-line. The device includes:

[0017] An acquisition module, configured to acquire first data at the first byte reception moment through the K-line, where the first data includes: first byte data, a first data status;

[0018] The acquisition module is further configured to acquire second data at the second byte reception moment through the K-line; the second data includes: second byte data, a second data status; the second byte reception moment is later than the first byte reception moment;

[0019] A determination module, configured to determine a target byte interval according to the first byte reception moment and the second byte reception moment;

[0020] The determining module is further configured to determine a target byte data state according to the first data state, the second data state, and the target byte interval;

[0021] The control module is configured to assemble the first byte data, the second byte data, the target byte interval, and the target byte data state to obtain a first message data, and transmit the first message data to the server end of the electronic device through the cloud platform.

[0022] In a fourth aspect, an embodiment of the present application provides a K-line based data transmission device, which is applied to an electronic device. The electronic device includes: a server end and a client end, and the server end includes a data buffer; the server end and the client end perform two-way communication through a cloud platform. The device includes:

[0023] A receiving unit, configured to receive first message data from the server end; the first message data includes: n byte data, a first byte interval, and a first byte data state; n is an integer greater than 1;

[0024] An obtaining unit, configured to obtain cached data from the data buffer to obtain first cached data;

[0025] A sending unit, configured to send the first cached data to the cloud platform through the server end at the first byte interval, and empty the data buffer;

[0026] A control unit, configured to generate second cached data according to the n byte data when the first byte data state is a start state or a continuous state, and save the second cached data to the data buffer.

[0027] In a fifth aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory, a communication interface, and one or more programs. The one or more programs are stored in the memory and are configured to be executed by the processor. The programs include instructions for executing the steps in the first aspect of the embodiments of the present application.

[0028] In a sixth aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory, a communication interface, and one or more programs. The one or more programs are stored in the memory and are configured to be executed by the processor. The programs include instructions for executing the steps in the second aspect of the embodiments of the present application.

[0029] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program for electronic data exchange, and the computer program causes a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application.

[0030] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program for electronic data exchange, and the computer program causes a computer to execute some or all of the steps described in the second aspect of the embodiments of the present application.

[0031] In a ninth aspect, an embodiment of the present application provides a computer program product. The computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in any of the methods in the first aspect of the embodiments of the present application. The computer program product may be a software installation package.

[0032] In a tenth aspect, an embodiment of the present application provides a computer program product. The computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in any of the methods in the second aspect of the embodiments of the present application. The computer program product may be a software installation package.

[0033] By implementing the embodiments of the present application, the following beneficial effects are achieved:

[0034] The K-line based data transmission method described in this application is applied to an electronic device. The electronic device includes a server and a client. The server and the client communicate bidirectionally through a cloud platform. The client communicates with a target vehicle through a K-line. The client of the electronic device obtains first data at the first byte reception time through the K-line. The first data includes: first byte data and first data status; obtains second data at the second byte reception time through the K-line; the second data includes: second byte data and second data status; the second byte reception time is later than the first byte reception time; determines a target byte interval according to the first byte reception time and the second byte reception time; determines a target byte data status according to the first data status, the second data status and the target byte interval; assembles the first byte data, the second byte data, the target byte interval and the target byte data status to obtain first message data, and transmits the first message data to the server of the electronic device through the cloud platform. The server of the electronic device receives the first message data through the cloud platform; the first message data includes: n byte data, a first byte interval and a first byte data status; n is an integer greater than 1; obtains cached data from a data buffer to get first cached data; sends the first cached data to the cloud platform through the server of the electronic device according to the first byte interval, and clears the data buffer; when the first byte data status is a start status or a continuous status, generates second cached data according to the n byte data, and saves the second cached data to the data buffer. In this way, by calculating the byte interval and notifying the server to send each byte data in the frame according to the original byte interval, it is prevented that the byte interval is too small after packaging, and the server sends after receiving a complete frame of data, thus avoiding the transmission timeout problem caused by the too large byte interval of each data due to network fluctuations. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions of the embodiments of this application, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to these drawings.

[0036] Figure 1 is an architecture diagram of a K-line based data transmission system provided by an embodiment of this application;

[0037] Figure 2 is a schematic structural diagram of an electronic device provided by an embodiment of this application;

[0038] Figure 3 is a schematic flowchart of a K-line based data transmission method provided by an embodiment of this application;

[0039] Figure 4It is a schematic flowchart of another K-line-based data transmission method provided by an embodiment of the present application;

[0040] Figure 5 It is a block diagram of the functional modules of a K-line-based data transmission device provided by an embodiment of the present application;

[0041] Figure 6 It is a block diagram of the functional units of a K-line-based data transmission device provided by an embodiment of the present application. Detailed implementation manners

[0042] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0043] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices.

[0044] It should be understood that the term "and / or" in this article is only an association relationship describing associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article indicates that the associated objects before and after are in an "or" relationship. The "multiple" that appears in the embodiments of the present application refers to two or more.

[0045] The "at least one (item)" or its similar expression in the embodiments of the present application refers to any combination of these items, including any combination of single items (items) or plural items (items), referring to one or more, and multiple refers to two or more. For example, at least one (item) of a, b, or c can represent the following seven situations: a, b, c, a and b, a and c, b and c, a, b, and c. Each of a, b, and c can be an element or a set containing one or more elements.

[0046] In the embodiments of the present application, the "connection" mentioned herein refers to various connection methods such as direct connection or indirect connection, etc., to achieve communication between devices. The embodiments of the present application do not make any limitations on this.

[0047] Referring to "embodiment" in this text means that the specific features, structures or characteristics described in combination with the embodiment can be included in at least one embodiment of the present application. The appearance of this phrase at various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0048] First, the relevant terms involved in the present application are explained as follows:

[0049] K line: The K line is a common communication line in the vehicle control system. It is mainly used as a physical connection medium for communication between the vehicle electronic control unit (Electronic Control Unit, ECU) and the diagnostic device. The K line uses a serial communication method, and data is transmitted bit by bit on the K line in sequence. During the communication process, the K line can achieve two-way data transmission. The diagnostic device can send a request command to the ECU, and the ECU can also return response data to the diagnostic device. Usually, the K line is the seventh pin on the on-board diagnostic system (On-Board Diagnostics, OBD) port.

[0050] KWP2000 protocol: The KWP2000 protocol based on the K line is a widely used on-vehicle diagnostic protocol standard in the automotive field. It is a protocol applied to the physical layer, data link layer and application layer. At the physical layer, the electrical characteristics of K line communication are defined. At the data link layer, the data frame format is defined. At the application layer, the format and meaning of commands and responses are defined. During the communication process, the diagnostic device returns a diagnostic response to the ECU by obtaining information such as the address and message of the ECU.

[0051] The KWP2000 protocol based on the K line has very strict requirements for timing, especially for the byte interval of each frame of data. An interval exceeding 20 milliseconds will be considered a timeout. In the scenario of vehicle remote diagnosis, due to network fluctuations, it is very difficult to ensure that the network delay always meets the requirements. Especially when users use wireless networks such as Wi-Fi or 4G, the network is even more unreliable. Due to network fluctuations, it is easy to cause the byte interval to exceed, resulting in diagnostic failure. When there are network fluctuations, it will cause the byte interval of each piece of data to be too large, resulting in a transmission timeout problem.

[0052] To solve the above problems, an embodiment of the present application provides a K-line-based data transmission method, apparatus, and related equipment, which are applied to an electronic device. The electronic device includes a server and a client. The server and the client communicate bidirectionally through a cloud platform. The client communicates with a target vehicle through a K-line. The method includes: obtaining first data at the first byte reception time through the K-line, where the first data includes: first byte data and first data status; obtaining second data at the second byte reception time through the K-line; the second data includes: second byte data and second data status; the second byte reception time is later than the first byte reception time; determining a target byte interval according to the first byte reception time and the second byte reception time; determining a target byte data status according to the first data status, the second data status, and the target byte interval; assembling the first byte data, the second byte data, the target byte interval, and the target byte data status to obtain first message data, and transmitting the first message data to the server of the electronic device through the cloud platform. By calculating the byte interval and notifying the server to send each byte of data in the frame according to the original byte interval, it is prevented that the byte interval after packaging is too small, and the server sends after receiving a complete frame of data, thereby avoiding the transmission timeout problem caused by the too large byte interval of each data due to network fluctuations.

[0053] The following combines Figure 1 to illustrate the architecture of a K-line-based data transmission system in an embodiment of the present application. Figure 1 FIG. 1 is an architecture diagram of a K-line-based data transmission system provided by an embodiment of the present application. The K-line-based data transmission system includes a cloud platform 110, a vehicle 120, a diagnostic device 130, a K-line 140, a client 141, and a server 142.

[0054] Among them, the cloud platform 110 is used to collect, store, and forward the assembled diagnostic data from the client 141. The diagnostic data is the diagnostic data obtained by the vehicle 120 through the K-line 140. The data may include: vehicle running state information, fault diagnostic codes, etc., or may include: vehicle attribute information, such as vehicle model, factory date, maintenance data, etc., which are not limited herein. At the same time, the cloud platform 110 can also perform data interaction with other external systems to provide data support for the optimization of vehicle manufacturing and vehicle service-related products.

[0055] Among them, during the operation of the vehicle 120, if a fault occurs, the sensors inside the vehicle will detect abnormal data. When the diagnostic device 130 sends a diagnostic request to the vehicle 120, the client 141 packs the detected abnormal data and relevant information about the fault through the K-line 140 and sends them to the diagnostic device 130 through the cloud platform 110. At the same time, the ECU of the vehicle 120 itself will record and save relevant operation data, providing a basis for subsequent fault troubleshooting and analysis.

[0056] Among them, the diagnostic device 130 is a data interaction and analysis tool in the K-line-based data transmission system. It establishes a stable connection with the K-line 140 through the client 141, the server 142, and the cloud platform 110 for remote diagnosis. First, the diagnostic device 130 sends diagnostic request information to the server 142 through the K-line 140. The server 142 packs and encapsulates the diagnostic request information and transmits it to the cloud platform 110. After receiving the encapsulated request instruction packet sent by the server 142, the cloud platform 110 forwards it to the client 141. The client 141 parses the encapsulated request instruction packet forwarded by the cloud platform 110 and sends the parsed request instruction to the vehicle 120 through the K-line 140. Then, the vehicle 120 responds to the diagnostic request of the diagnostic device 130, and sends the abnormal data detected by the sensors of the vehicle 120, the operation data recorded by the ECU, or other data (such as the attribute information of the vehicle) to the client 141 through the K-line 140. The client 141 packs and encapsulates the fault data and uploads it to the cloud platform 110. The cloud platform 110 forwards the data to the server 142. Finally, the server parses the encapsulated data packet forwarded by the cloud platform 110 and sends it to the diagnostic device 130 through the K-line 140. Among them, the K-line 140 mainly serves as a communication interface for transmitting diagnostic data and other relevant information between the vehicle 120 and the diagnostic device 130. The K-line 140 itself is only responsible for data transmission and does not have the ability to process data.

[0057] Among them, the client 141 interacts with the vehicle 120 through the K-line 140, and the server 142 interacts with the diagnostic device 130. They perform remote diagnosis through the cloud platform 110. When the diagnostic device 130 sends a diagnostic request to the server 142, the cloud platform 110 forwards the diagnostic request data to the client 141. The client 141 sends a request to upload the diagnostic request to the vehicle 120 through the K-line 140 for the requested diagnostic data. At this time, the client 141 will be the object of data transmission, and the operation data and fault information detected by the internal sensors of the vehicle 120 will be encoded into a data packet according to the standard format of the KWP2000 protocol and sent to the cloud platform 110. After receiving the data packet sent by the client 141, the cloud platform 110 forwards the data packet to the server 142. After receiving the data packet forwarded by the cloud platform 110, the server 142 parses the data packet based on the same processing protocol standard for diagnostic data as the client 141, and sends the parsed result to the diagnostic device 130 through the K-line 140, so that the diagnostic device 130 can obtain the diagnostic data of the vehicle 120. Through the collaborative work of the client 141 and the server 142, stable and efficient data interaction and analysis between the vehicle 120 and the diagnostic device 130 can be achieved.

[0058] In a possible embodiment, the diagnostic device 130 initiates a diagnostic request and sends the request to the server 142 via the K140 line. After receiving the diagnostic request, the server 142 forwards it to the client 141 via the cloud platform 110. After receiving the diagnostic request forwarded by the cloud platform 110, the client 141 sends the diagnostic request instruction information to the electronic control unit (ECU) of the vehicle 120 via the K line 140, so that the vehicle 120 makes a diagnostic response. The vehicle 120 responds to the diagnostic request, and the client 141 receives the response data of the vehicle 120 via the K line 140. These data include: abnormal information, fault codes, operating status information, etc. The client 141 encodes and packs the data according to the protocol in KWP2000, such as the ISO / WD14230-1 or ISO / WD14230-2 protocol, which is not limited here. After the encoding and packing are completed, the client 141 uploads the packed data to the cloud platform 110. After receiving the packed response data, the cloud platform 110 forwards the data to the server 142. After receiving the packed response data, the server 142, on the one hand, continues to request the cloud platform 110 to send more diagnostic data, such as the historical fault records and maintenance data of the vehicle 120, etc., which is not limited here; on the other hand, the server 142 caches the packed data sent by the client 141. After receiving the diagnostic request from the server 142, the cloud platform 110 requests the vehicle 120 to upload more diagnostic data via the client 141. The cloud platform 110 forwards the newly received data from the client 141 to the server 142 and parses the data, and then the diagnostic device 130 obtains the diagnostic data parsed by the server 142. The maintenance personnel can obtain this report by authorizing to log in to the cloud platform 110 or directly through the diagnostic device 130, and clearly understand the specific location, possible causes and recommended repair solutions of the vehicle fault. It should be noted that the above interaction between the client 141 and the server 142 is only a process of one interaction. In the whole remote diagnosis process, the client 141 and the server 142 are constantly interacting.

[0059] It can be seen that through the above system architecture, the server of the K line, the cloud platform and the client can work together, which can avoid timeout caused by network delay, thus resulting in the failure of remote diagnosis.

[0060] The following will be combined with Figure 2 to describe the electronic device in the embodiments of the present application. Figure 2 As shown in the structural schematic diagram of an electronic device provided by the embodiments of the present application, as Figure 2 shown, the electronic device 200 includes one or more processors 210, a memory 220, a communication interface 230, and one or more programs 221. The processor 210 is communicatively connected to the memory 220 and the communication interface 230 through an internal communication bus.

[0061] Among them, the processor is mainly used for:

[0062] Obtain first data at the first byte reception moment through the K line, where the first data includes: first byte data and first data status;

[0063] Obtain second data at the second byte reception moment through the K line; the second data includes: second byte data and second data status; the second byte reception moment is later than the first byte reception moment;

[0064] Determine the target byte interval according to the first byte reception moment and the second byte reception moment;

[0065] Determine the target byte data status according to the first data status, the second data status and the target byte interval;

[0066] Assemble the first byte data, the second byte data, the target byte interval and the target byte data status to obtain first message data, and transmit the first message data to the server of the electronic device through the cloud platform.

[0067] Among them, the processor is mainly further used for:

[0068] Receive first message data from the server; the first message data includes: n byte data, first byte interval and first byte data status; n is an integer greater than 1;

[0069] Obtain cached data from the data buffer to get first cached data;

[0070] Send the first cached data to the cloud platform through the server according to the first byte interval, and empty the data buffer;

[0071] When the first byte data status is the start status or the continuous status, generate second cached data according to the n byte data, and save the second cached data to the data buffer.

[0072] Among them, the one or more programs are stored in the above-mentioned memory 220 and are configured to be executed by the above-mentioned processor. The one or more programs include instructions for executing any step in the above method embodiment.

[0073] Among them, the processor 210 can be, for example, a Central Processing Unit (CPU), a general-purpose processor, a Digital Signal Processor (DSP), an Application-Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logical blocks, units, and circuits described in connection with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and so on. The communication unit can be a communication interface, a transceiver, a transceiver circuit, etc., and the storage unit can be a memory.

[0074] Among them, the memory 220 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchlink dynamic random access memory (SLDRAM), and direct rambus random access memory (DR RAM).

[0075] It can be understood that the electronic device may include more or fewer structural elements than those shown in the above structural block diagram. For example, it may include a power module, physical buttons, a Wi-Fi module, a speaker, a Bluetooth module, sensors, a display module, etc., which are not limited herein. It can be understood that the electronic device may be equipped with, such as Figure 1 the system architecture described above.

[0076] After understanding the software and hardware architecture of the present application, the following will describe a K-line-based data transmission method in an embodiment of the present application in conjunction with Figure 3 A flowchart of a K-line-based data transmission method provided in an embodiment of the present application is shown in Figure 3 FIG. 9. This method is applied to an electronic device, and the electronic device includes: a server and a client. The server and the client communicate bidirectionally through a cloud platform, and the client communicates with a target vehicle through a K-line. The method specifically includes the following steps:

[0077] Step S310: Obtain first data at the first byte reception time through the K-line. The first data includes: first byte data and a first data status.

[0078] Among them, the first byte reception time is the reception time of the current byte, and the first data is the basic unit of information transmitted through the K-line. Under the K-line communication protocol, the format and content of the first data follow the rules of the KWP2000 protocol. Among them, the first byte data may contain instruction information, status identifiers, valid byte content, etc., which are not limited herein. For example, in the automotive diagnostic data transmission based on the KWP2000 protocol, the first byte data includes the type of diagnostic request, such as reading fault codes, clearing fault codes, etc. The first data status represents the identifier of data transmission, which mainly includes but is not limited to the start status, continuous status, and end status. The start status indicates the start of data transmission, indicating that data reception starts from the current moment; at this time, the first byte data may contain data frame header information, where the data header information may include the start flag and the number of bytes of the data frame; the continuous status indicates that data transmission is ongoing, indicating that the first data can be continuously received; the end status indicates that the data reception has been completed. Among them, the end status may contain information such as a checksum or an end identifier to ensure the integrity and accuracy of data transmission.

[0079] Specifically, when obtaining the first data at the first byte reception time through the K-line, the client first detects the signal of the K-line. When the start signal that conforms to the protocol regulations of the K-line is detected, the data reception process is started. As the signal continues to be input, the client receives the data bit by bit and assembles it into bytes. During the reception process, the client judges and parses each byte according to the standard rules of the KWP2000 protocol to determine whether it is the first byte data. For example, in some protocols, a specific byte sequence is defined as the start identifier of the first byte data. When the client recognizes this identifier, the subsequent received bytes are processed as the first byte data. At the same time, the client also needs to synchronously judge the first data status. For example, if multiple bytes are continuously received within a short period of time and the arrangement of these bytes conforms to the data format requirements in the continuous state, then the client determines the first data status as the continuous state. On the contrary, if the received byte sequence matches the start state identifier specified in the protocol, the first data status is determined as the start state.

[0080] Step S320, obtaining the second data at the second byte reception time through the K-line; the second data includes: second byte data, second data status; the second byte reception time is later than the first byte reception time.

[0081] Among them, the second reception time is the time of the next received byte of the current reception time. When the client has received the first data and the first data status is the start state or the continuous state, the client will receive the second data. The second data is similar to the first data in the above step S310 and is the basic unit of information transmitted through the K-line.

[0082] Among them, the complete information of the data can be further analyzed according to the correlation relationship between the first byte data and the second byte data. For example, in the ISO9141-3 communication protocol in the KWP2000 protocol, the first byte data may include those used to identify the data type and specific parameters, and they jointly form the instruction information or data information.

[0083] Specifically, when obtaining the second data at the second byte reception time, the client device needs to continuously monitor the K-line signal. After the reception of the first byte is completed, according to the byte transmission interval and timing requirements specified by the K-line protocol, the reception start point of the second byte is determined. When judging the second byte data, the client parses it according to the protocol rules. For example, in the scenario of vehicle remote diagnosis based on K-line, when there is a fault in the vehicle's central brake light, the maintenance personnel establish a connection with the vehicle's ECU through the diagnostic device and start a diagnostic session. If the first byte data indicates an instruction that may include lighting system fault information, the second byte data may contain detailed status codes related to the central brake light. For the determination of the second data status, the client mainly realizes it by comparing the current byte reception situation with the previous byte reception status and the status conversion rules specified by the protocol. For example, if the first data status is a continuous status, and the second byte data is received within the expected time interval, and the format of this byte data meets the requirements in the continuous status, then the second data status is probably also determined to be a continuous status. On the contrary, if there is an abnormal delay at the second byte reception time, or the format of the received byte data does not conform to the continuous status format specified by the protocol, the client may mark the second data status as an abnormal status and trigger corresponding error handling mechanisms, such as requesting retransmission of data, performing data verification, etc., to ensure the integrity and accuracy of the data.

[0084] Step S330, determine the target byte interval according to the first byte reception time and the second byte reception time.

[0085] Among them, the determination of the target byte interval is crucial for analyzing the data transmission characteristics of the K-line and ensuring the correct processing of data. Since the KWP2000 protocol has strict timing requirements, especially for the byte interval of each frame of data, it is considered timed out if it exceeds 20 milliseconds. In remote diagnosis, due to network fluctuations, it is easy to cause the byte interval to exceed, resulting in diagnostic failure. Therefore, determining the target byte interval can judge whether there is an abnormality in the transmission process.

[0086] Specifically, when determining the target byte interval, first record the first byte reception time and the second byte reception time, and then calculate the target byte interval. The calculation of the target byte interval can be based on the following formula:

[0087] Target byte interval = Second byte reception time - First byte reception time:

[0088] Among them, the unit of the target byte interval can be milliseconds, microseconds, and is not limited here.

[0089] Generally, the first byte reception time and the second byte reception time depend on the internal clock mechanism of the client. After obtaining the exact values of the two times, the original time difference of the target byte interval can be obtained through a simple subtraction operation. Among them, further processing may be required according to the K-line communication protocol and the specific requirements of the system. For example, some protocols may stipulate that the time difference needs to be converted into a specific time unit, such as converting microseconds to milliseconds, for subsequent data processing and analysis. In addition, considering factors such as clock drift and signal interference that may exist during the actual transmission process, the calculated target byte interval may need to be calibrated and verified. This can be achieved by comparing it with a preset normal interval range. If the target byte interval exceeds the normal range, it may mean that there are abnormalities during the transmission process, such as signal attenuation and transmission delay caused by noise interference. At the same time, methods such as taking the average of multiple measurements can also be used to improve the accuracy and reliability of the target byte interval.

[0090] Step S340, determine the target byte data state according to the first data state, the second data state, and the target byte interval.

[0091] Among them, the first data state and the second data state respectively reflect the data transmission stage characteristics when the first byte and the second byte are received, while the target byte interval reflects the time characteristics of the transmission of the two bytes. They jointly provide a basis for determining the target byte data state. If the first data state is the start state, it indicates that a new data transmission process has just started. At this time, if the second data state is the continuous state and the target byte interval is within the threshold, it means that the data transmission is stable and reliable, and it can be initially determined that the target byte data state is the continuous state of stable transmission. However, if the target byte interval exceeds the normal range, even if the second data state is the continuous state, it may imply that there is an abnormal delay in the data transmission, and then the current round of data transmission is ended. At this time, the target byte data state can be marked as the abnormal state. If the first data state is the continuous state, the second data state is also the continuous state, and the target byte interval is stable, it means that the data is being transmitted in an orderly manner, and the target byte data state is likely to remain in the continuous state. But when the first data state is the continuous state and the second data state shows the end state, because this may indicate that the data transmission ends in advance, the target byte data state may need to be adjusted to a special end or abnormal state, so that the system can accurately process the possible incomplete data and provide reliable support for subsequent locomotive fault diagnosis.

[0092] In a possible embodiment, the determining the target byte data state according to the first data state, the second data state, and the target byte interval may include the following steps:

[0093] 41. Determine the first received byte count according to the target byte interval and the first data state;

[0094] 42. When the first received byte count is greater than or equal to a preset first threshold, determine the target byte data based on the first data state, the second data state, the first byte data, and the second byte data;

[0095] 43. Determine the target frame length according to the target byte data;

[0096] 44. When the target frame length is equal to the first received byte count, determine that the target byte data state is the end state; otherwise, when the target frame length is not equal to the first received byte count, determine that the target byte data state is the continuous state.

[0097] Among them, when the target byte interval is below a threshold of less than 20 milliseconds, combined with the first data state, if it is the start state or the continuous state, the server receives the second byte data. The first threshold is set to 3. If the first received byte count is 1, the first data state is set to the start state, indicating that the next round of byte data can be continued to be received; if the first received byte count is 2 or 3, the first data state is set to the continuous state, which also indicates that the next round of byte data can be continued to be received; if the first received byte count is greater than 3, it is necessary to determine the frame length of the target byte data and determine whether the state of the target byte data is the end state according to the frame length.

[0098] Specifically, when determining the target frame length according to the target byte data, the target byte data is parsed according to specific protocol rules, such as the ISO14230-3 protocol in the KWP2000 protocol. By identifying specific identifiers in the target byte data, such as the frame start flag, the frame end flag, and the data padding byte, etc., the target frame length is calculated. This calculation process can use the state machine algorithm to perform state transitions according to different byte states, so as to accurately locate the frame boundary. When judging whether the target frame length is equal to the first received byte count, this is a key verification of data integrity. If the two are equal, it means that the received data is complete and meets the expectations. At this time, it is determined that the target byte data state is the end state, and the server has completed a complete reception of the K-line data and performs subsequent transmission work, such as closing the data connection, saving the data, etc.; if they are not equal, it means that the data may be lost or incorrect. At this time, it is determined that the target byte data state is the continuous state, and the system will continue to monitor the data transmission and wait for the subsequent data to be supplemented for recalculation and verification to ensure that complete and accurate data can be obtained finally. Through this series of steps, the client can comprehensively and accurately determine the target byte data state according to various factors, greatly improving the stability and reliability of the K-line-based data transmission system.

[0099] In a possible embodiment, the method may further include the following steps:

[0100] A1. When the first received byte count is less than the preset first threshold, determine whether the first received byte count meets the preset first condition;

[0101] A2. When the first received byte count meets the preset first condition, determine that the target byte data state is the start state; otherwise, when the first received byte count does not meet the preset first condition, determine that the target byte data state is the continuous state.

[0102] Wherein, the first threshold is 3, and the first condition is that the number of received bytes is equal to 1. When the number of received bytes is 1, the target byte data state is set to the start state; when the number of received bytes is 2 or 3, the target byte data state is set to the continuous state.

[0103] Specifically, first, the client compares the first received byte count with the preset first threshold. If the first received byte count is less than the preset first threshold, the client makes a logical judgment according to the preset first condition. If it meets the condition, the process of determining the target byte data state as the start state is followed; if it does not meet the condition, then the target byte data state is determined to be the continuous state. When the target byte data state is determined to be the start state, it may indicate that the number of received bytes is small, or it may indicate that no bytes have been received in this round. However, according to the judgment of the preset first condition, this is a new starting point for data transmission. At this time, the client performs subsequent operations according to the processing logic of the start state, such as initializing the data buffer, resetting the byte counter, etc., to prepare for the subsequent complete data reception and processing; while when the target byte data state is determined to be the continuous state, the client determines that it is a continuation of the previous data transmission process and will continue to use the previous processing logic, such as appending the newly received byte data to the existing data buffer and updating relevant parameters such as the byte counter according to the rules in the continuous state.

[0104] It can be seen that by judging whether the received byte count meets the first preset condition, the state judgment mechanism of the K-line based data transmission system is further improved. In the face of the special situation where the first received byte count is less than the preset first threshold, the state of the target byte data can be accurately distinguished through the judgment of the preset first condition, so as to adopt corresponding processing strategies. This not only enhances the adaptability of the system in a complex data transmission environment, but also improves the accuracy and reliability of data processing, ensuring that the entire K-line based data transmission system can operate stably and efficiently.

[0105] In a possible embodiment, the determining the first received byte count according to the target byte interval and the first data state may include the following steps:

[0106] 411. When the first data state is the start state or the continuous state, determine the first byte count according to the first byte data;

[0107] 412. When the target byte interval is greater than the preset first interval threshold, determine the preset first byte count as the first received byte count;

[0108] 413. When the target byte interval is less than or equal to the preset first interval threshold, determine the second received byte count according to the second byte data;

[0109] 414. Determine the first received byte count according to the second received byte count and the first byte count.

[0110] Among them, when the first data state is the start state, it means that a new round of data reception has just started. At this time, the first byte count is determined according to the first byte data. The continuous state indicates the coherence of data transmission, and the accuracy of counting also needs to rely on the first byte data. The first interval threshold is determined based on the characteristics of K-line transmission. Because the KWP2000 protocol based on K-line has very strict requirements for timing, especially for the byte interval of each frame of data. If it exceeds 20 milliseconds, it will be judged as timeout. During vehicle remote diagnosis, for some vehicles using K-line diagnosis, once the byte interval of each frame of data exceeds 20 milliseconds, it will cause the diagnosis to fail. In practical applications, generally, the first threshold is set below 80% of the K-line limit value to ensure the reliability of data transmission based on K-line. The first interval threshold can be 16 milliseconds, 15 milliseconds, 10 milliseconds, etc., and is not limited here.

[0111] Specifically, when the target byte interval is less than or equal to the preset first interval threshold, it indicates that the data transmission is relatively stable and reliable. At this time, when determining the second received byte count according to the second byte data, it is necessary to deeply analyze the characteristics of the second byte data and its position in the entire data frame. By parsing the second byte data, more information about the data length and structure can be obtained, so as to more accurately determine the second received byte count. For example, the second byte data may contain the encoding information of the data length. Through a specific decoding algorithm, the second received byte count can be accurately calculated. Then, when determining the first received byte count according to the second received byte count and the first byte count, it is not a simple numerical addition, but the logical relationship of the data and the protocol requirements need to be considered. For example, it may be necessary to perform weighted calculations on the two byte counts according to the data type and transmission order, or combine them according to specific rules. This calculation method can make full use of the information carried by the two byte data to ensure that the finally determined first received byte count is accurate and provide a reliable data basis for subsequent data processing and analysis.

[0112] It can be seen that according to the target byte interval and the first data state, the first received byte count can be determined systematically and comprehensively. This step not only considers various states and conditions during data transmission but also combines various possible situations in practical applications, ensuring accurate reception and processing of data in different scenarios, thereby improving the reliability and stability of the K-line based data transmission system.

[0113] In a possible embodiment, the determining the target frame length according to the target byte data may include the following steps:

[0114] 431. Analyze the target byte data according to a preset first rule to obtain first parsed data; the first parsed data includes frame padding bytes and the target byte count;

[0115] 432. Determine the number of the frame padding bytes to obtain a first padding count;

[0116] 433. Determine the frame length according to the target byte count and the first padding count to obtain the target frame length.

[0117] Among them, this preset first rule is usually based on the parsing logic defined by the KWP2000 protocol. In the K-line data transmission scenario, the target byte data is organized according to specific protocol specifications. When parsing, byte analysis of the target byte data needs to be carried out according to rules such as byte identifiers and position offsets defined by the protocol. For example, certain specific byte sequences may be defined as identifiers of frame padding bytes. By identifying these identifiers, the frame padding bytes in the target byte data are distinguished from the valid data bytes, and the target byte count is accurately counted.

[0118] Among them, after obtaining the first parsed data containing frame padding bytes, the frame padding bytes need to be counted. Since the distribution of frame padding bytes in the data may not be regular, they may appear continuously or be scattered at different positions. In the KWP2000 protocol, the role of frame padding bytes is to ensure the integrity and stability of data transmission. Their quantity and positions are strictly regulated. By traversing the part of the first parsed data identified as frame padding bytes, accurate counting of the number of frame padding bytes is achieved, thereby obtaining the first padding count.

[0119] Specifically, in K-line communication, a complete data frame not only contains valid data bytes (i.e., the bytes corresponding to the target number of bytes), but may also contain frame padding bytes added to meet the protocol requirements. When calculating the target frame length, the target number of bytes needs to be added to the first padding number. For example, if the target number of bytes is 50 and the first padding number is 5, then the target frame length is 55. In actual application scenarios, the preset first rule may be adjusted according to different K-line communication application requirements. When parsing the target byte data, a state machine algorithm can be used. The state machine performs state transitions and data extraction based on different byte values and the current state, so as to accurately identify the frame padding bytes and the target number of bytes.

[0120] Step S350: Assemble the first byte data, the second byte data, the target byte interval, and the target byte data state to obtain first message data, and transmit the first message data to the server of the electronic device through the cloud platform.

[0121] Among them, the data structure of the first message data is a data structure assembled according to the KWP2000 protocol standard from the first byte data, the second byte data, the target byte interval, and the target byte data state. Among them, the data structure of the message consists of three parts: a message header, a data field, and a checksum. Among them, the message header contains a format byte, a target address, a source address, and additional length information. The target address and the source address are optional. It can only contain the target address, only contain the source address, or contain both the target address and the source address, or neither the target address nor the source address. The data field contains the data information transmitted by the K-line. In this embodiment, the data field includes the first byte data, the second byte data, and the target byte data state.

[0122] In a possible embodiment, the assembling the first byte data, the second byte data, the target byte interval, and the target byte data state to obtain first message data may include the following steps:

[0123] 351. Generate target message information according to the first byte data, the second byte data, and the target byte interval;

[0124] 352. Assemble the first byte data, the second byte data, and the target byte interval to obtain first assembled data;

[0125] 353. Add the target message information and the target byte data state to the first assembled data to obtain first message data.

[0126] Among them, the first byte data and the second byte data serve as the main part of the transmitted data content, and their content and order have specific meanings. The target byte interval reflects the time characteristics of data transmission. Together, they provide key information for subsequent message parsing. When generating the target message information, the first byte data, the second byte data, and the target byte interval need to be reasonably arranged according to the format specified by the protocol. For example, the target byte interval is embedded into the data structure composed of the first byte data and the second byte data in a specific encoding manner, so as to form the target message information with clear meaning and can be accurately parsed by the client.

[0127] Among them, the assembly process is to integrate the first byte data, the second byte data, and the target byte interval in an orderly manner. The assembly here is not a simple splicing, but according to the message structure defined by the protocol, each part is placed in the corresponding position. For example, the ISO14230-2 protocol includes message structure, initialization process, communication connection management, timing parameters, and error handling, etc. The K-line message includes three parts: message header, data field, and checksum. Among them, the message header contains format byte, target address (optional), source address (optional), and additional length information (optional). The first byte data and the second byte data are in the position of the additional length, and the target byte interval is arranged in a specific field of the message.

[0128] Specifically, when adding the target message information and the target byte data status to the first assembled data, the integrity and correctness of the entire message need to be considered. The target byte data status is the key information describing the current data transmission status, such as start status, continuous status, or end status, etc. When adding it to the first assembled data, it is necessary to ensure that its position and format are correct to ensure that the client can accurately identify it. For example, in some application scenarios, the target byte data status may be encoded as a specific byte value and added to the end of the first assembled data as the status identifier of the entire message. When adding the target message information, it is necessary to consider its integration method with the first assembled data and cannot damage the existing data structure. In this way, the finally obtained first message data can completely carry all the information required for transmission. Whether it is data content, transmission time characteristics, or data status, it can be accurately parsed and processed by the client, thus ensuring the efficiency and reliability of K-line-based data transmission.

[0129] It can be seen that when the client receives the K-line data, it first calculates the byte interval. When the byte interval is less than 20 milliseconds, it first sets a counter for the number of received bytes, clears the number of received bytes, saves the received bytes at the same time, and counts the number of received bytes accordingly. If the number of received bytes is 1, the received data status is set to the start state; if the number of ending bytes is 2, the received data status is set to the continuous state. Then, the received data is parsed to obtain the length of the frame. If the length of the frame is equal to the number of received bytes, it is marked that the data of one frame has been received completely, and the data status is set to the end state. In addition, the number of received bytes is cleared. Through the described step process and the embodiment described above, a K-line-based data transmission method can avoid the transmission timeout problem caused by too large a byte interval for each data due to network fluctuations.

[0130] Please refer to Figure 4 , Figure 4 which is a schematic flow chart of another K-line-based data transmission method provided by the embodiment of the present application. As Figure 4 shown, it is applied to an electronic device. The electronic device includes: a server and a client. The server includes a data buffer; the server and the client communicate bidirectionally through a cloud platform, and specifically include the following steps:

[0131] Step S410, receive first packet data from the server; the first packet data includes: n byte data, a first byte interval, and a first byte data status; n is an integer greater than 1;

[0132] Step S420, obtain cached data from the data buffer to get first cached data;

[0133] Step S430, send the first cached data to the cloud platform through the server according to the first byte interval, and clear the data buffer;

[0134] Step S440, when the first byte data status is the start state or the continuous state, generate second cached data according to the n byte data, and save the second cached data to the data buffer.

[0135] Among them, in terms of generating the second cached data from the n-byte data, it specifically includes: parsing the n-byte data to detect whether there is an end flag in the n-byte data; determining the reception time of two adjacent byte data in the n-byte data to obtain n-1 first byte intervals; when there is an end flag in the n-byte data, counting the total number of bytes in the n-byte data; when the total number of bytes is equal to a preset second threshold and each byte interval in the n-1 first byte intervals is less than a preset first duration, storing the n-byte data and the n-1 byte data in the buffer to obtain the second cached data.

[0136] Among them, the first cached data is the data already existing in the data buffer, which can be a message. The second cached data is the n-byte data received by the server of the K line. The second threshold is set based on the KWP2000 protocol standard and will not be limited here. When the status of the first byte data is the start status or the continuous status, the operation of generating and storing the second cached data will be executed. During the process of generating the second cached data, first, the n-byte data is parsed to detect whether there is an end flag in it. At the same time, the reception time of two adjacent byte data in the n-byte data is determined. When an end flag is detected in the n-byte data, the total number of bytes will be further counted. If the total number of bytes is equal to the preset value and each byte interval in the n-1 first byte intervals is less than the preset first duration, this indicates that the data meets the requirements in terms of integrity and timeliness. At this time, the n-byte data and the n-1 byte data are stored in the buffer to obtain the second cached data.

[0137] Further, in the subsequent process, if the client receives new message data again and the data status is start or continuous, the above steps of generating the second cached data will be repeated to continuously update and supplement the content of the data buffer. When the data status is end, the system will send the cached data in the buffer according to the byte interval and clear the buffer to prepare for the next round of data reception and processing, ensuring the stability and efficiency of the entire K line data transmission and processing system.

[0138] The K-line based data transmission method described in this application receives data containing messages through the K-line. Based on the KWP2000 protocol standard, the received messages are parsed to obtain the data status of the received bytes. At the same time, it is checked whether there is cached data in the data buffer. If the data status of the received bytes is the start status or the continuous status, and there is cached data in the data buffer, the server will send the cached data at intervals of less than 20 milliseconds and clear the data buffer. Subsequently, the received bytes are stored in the cleared data buffer. When the data status of the received bytes is the end, the saved received bytes are sent at intervals of less than 20 milliseconds. After the server receives network data, it parses the messages and decides whether to cache the data according to the data status. When the received data status is complete, the cached data is sent to the K-line at byte intervals. In this way, duplicate parsing of data at both ends (the server and the client on the K-line) is avoided, effectively improving the processing efficiency and the reliability of data transmission. At the same time, the problem of transmission timeout caused by excessive byte intervals for each data due to network fluctuations is avoided.

[0139] The above mainly introduces the solution of the embodiment of this application from the perspective of the execution process on the method side. It can be understood that in order for an electronic device to implement the above functions, it includes the corresponding hardware structure and / or software module for executing each function. Those skilled in the art should easily realize that, combining the units and algorithm steps of each example described in the embodiments provided in this article, this application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0140] The embodiments of this application can divide the functional units of the electronic device according to the above method examples. For example, each functional unit can be divided corresponding to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. It should be noted that the division of units in the embodiments of this application is illustrative, only a logical function division, and there can be other division methods in actual implementation.

[0141] In the case of dividing each functional module corresponding to each function, Figure 5A functional module composition block diagram of a K-line based data transmission device provided by an embodiment of the present application. The device is applied to an electronic device, and the electronic device includes: a server and a client. The server and the client communicate bidirectionally through a cloud platform. The client communicates with a target vehicle through a K-line. The K-line based data transmission device 500 includes:

[0142] An acquisition module 510, configured to acquire first data at the first byte reception time through the K-line. The first data includes: first byte data and first data status;

[0143] The acquisition module 510 is further configured to acquire second data at the second byte reception time through the K-line. The second data includes: second byte data and second data status. The second byte reception time is later than the first byte reception time;

[0144] A determination module 520, configured to determine a target byte interval according to the first byte reception time and the second byte reception time;

[0145] A control module 530, configured to assemble the first byte data, the second byte data, the target byte interval, and the target byte data status to obtain first message data, and transmit the first message data to the server of the electronic device through the cloud platform.

[0146] Optionally, in terms of determining the target byte data status according to the first data status, the second data status, and the target byte interval, the determination module 520 is specifically configured to:

[0147] Determine a first received byte count according to the target byte interval and the first data status;

[0148] When the first received byte count is greater than or equal to a preset first threshold, determine target byte data based on the first data status, the second data status, the first byte data, and the second byte data;

[0149] Determine a target frame length according to the target byte data;

[0150] When the target frame length is equal to the first received byte count, determine that the target byte data status is an end status;

[0151] Otherwise, when the target frame length is not equal to the first received byte count, determine that the target byte data status is a continuous status.

[0152] Optionally, the determination module 520 is further specifically configured to:

[0153] When the first received byte count is less than the preset first threshold, determine whether the first received byte count meets a preset first condition;

[0154] When the first received byte count meets the preset first condition, determine that the target byte data state is the start state;

[0155] Otherwise, when the first received byte count does not meet the preset first condition, determine that the target byte data state is the continuous state.

[0156] Optionally, in terms of determining the first received byte count according to the target byte interval and the first data state, the determining module 520 is specifically configured to:

[0157] When the first data state is the start state or the continuous state, determine the first byte count according to the first byte data;

[0158] When the target byte interval is greater than a preset first interval threshold, determine the preset first byte count as the first received byte count;

[0159] When the target byte interval is less than or equal to the preset first interval threshold, determine the second received byte count according to the second byte data;

[0160] Determine the first received byte count according to the second received byte count and the first byte count.

[0161] Optionally, in terms of determining the target frame length according to the target byte data, the determining module 520 is specifically configured to:

[0162] Parse the target byte data according to a preset first rule to obtain first parsed data; the first parsed data includes frame padding bytes and the target byte count;

[0163] Determine the number of the frame padding bytes to obtain a first padding number;

[0164] Determine the frame length according to the target byte count and the first padding number to obtain the target frame length.

[0165] Optionally, in terms of assembling the first byte data, the second byte data, the target byte interval, and the target byte data state to obtain first message data, the control module 530 is specifically configured to:

[0166] Generate target message information according to the first byte data, the second byte data, and the target byte interval;

[0167] Assemble the first byte data, the second byte data, and the target byte interval to obtain first assembled data;

[0168] Add the target message information and the target byte data status to the first assembled data to obtain the first message data.

[0169] It can be seen that the K-line-based data transmission device described in this application is applied to the client of an electronic device. The first data at the first byte reception time is obtained through the K-line. The first data includes: the first byte data and the first data status. The second data at the second byte reception time is obtained through the K-line. The second data includes: the second byte data and the second data status. The second byte reception time is later than the first byte reception time. Determine the target byte interval according to the first byte reception time and the second byte reception time. Determine the target byte data status according to the first data status, the second data status, and the target byte interval. Assemble the first byte data, the second byte data, the target byte interval, and the target byte data status to obtain the first message data, and transmit the first message data to the server. By calculating the byte interval and notifying the server to send each byte data in the frame according to the original byte interval, it is prevented that the byte interval is too small after packaging, and the server sends after receiving a complete frame of data, thereby avoiding the transmission timeout problem caused by too large a byte interval for each data due to network fluctuations.

[0170] It should be noted that the specific implementation of each operation can adopt the corresponding description of the method embodiment shown above. The K-line-based data transmission device 500 can be used to execute the method embodiment of this application above, and details are not described herein again.

[0171] Please refer to Figure 6 , Figure 6 is a functional unit composition block diagram of a K-line-based data transmission device involved in an embodiment of this application. This device is applied to an electronic device. The electronic device includes: a server and a client. The server includes a data buffer. The server and the client communicate bidirectionally through a cloud platform. The K-line-based data transmission device 600 includes:

[0172] A receiving unit 610, configured to receive first message data from the server. The first message data includes: n byte data, a first byte interval, and a first byte data status. n is an integer greater than 1.

[0173] An obtaining unit 620, configured to obtain cached data from the data buffer to obtain first cached data.

[0174] A sending unit 630, configured to send the first cached data to the cloud platform through the server according to the first byte interval, and empty the data buffer.

[0175] A control unit 640, configured to generate second buffered data according to the n-byte data and save the second buffered data to the data buffer when the first-byte data state is a start state or a continuous state.

[0176] The K-line based data transmission device described in this application is applied to the server of an electronic device. The electronic device further includes a client. The server includes a data buffer. The server communicates with the client through a K-line, receives first message data from the client through the K-line; obtains buffered data from the data buffer to get first buffered data; sends the first buffered data to the client at the first-byte interval and clears the data buffer; generates second buffered data according to the n-byte data and saves the second buffered data to the data buffer when the first-byte data state is a start state or a continuous state. In this way, repeated data parsing at both ends (the server and the client on the K-line) is avoided, the processing efficiency and the reliability of data transmission are effectively improved, and at the same time, the problem of transmission timeout caused by too large a byte interval for each data due to network fluctuations is avoided.

[0177] It can be understood that the functions of the program modules of the K-line based data transmission device in the embodiments of this application can be specifically implemented according to the methods in the above method embodiments, and the specific implementation process can refer to the relevant descriptions in the above method embodiments, which will not be elaborated here.

[0178] The embodiments of this application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program for electronic data exchange, and the computer program enables a computer to execute some or all of the steps of any of the methods described in the above method embodiments. The above computer includes an electronic device.

[0179] The embodiments of this application also provide a computer program product. The computer program product includes a non-transitory computer-readable storage medium storing a computer program. The computer program is operable to enable a computer to execute some or all of the steps of any of the methods described in the above method embodiments. The computer program product can be a software installation package. The above computer includes an electronic device.

[0180] It should be noted that, for each of the above embodiments, for the sake of simple description, they are all described as a series of combinations of actions. Those skilled in the art should be aware that the present application is not limited by the described order of actions, because certain steps in the embodiments of the present application can be performed in other orders or simultaneously. Additionally, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions, steps, modules, or units involved are not necessarily essential to the embodiments of the present application.

[0181] In the above embodiments, the descriptions of the embodiments of the present application each have their own focuses. For parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0182] Those of ordinary skill in the art can understand all or part of the processes of the methods in the above embodiments. These processes can be completed by relevant hardware instructed by a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The aforementioned storage medium includes: ROM or random access memory RAM, magnetic disks, or optical discs, etc., which are various media that can store program codes.

[0183] The steps of the methods or algorithms described in the embodiments of the present application can be implemented in a hardware manner or by a processor executing software instructions. The software instructions can be composed of corresponding software modules. The software modules can be stored in RAM, flash memory, ROM, EPROM, electrically erasable programmable read-only memory (EEPROM), registers, hard disks, removable hard disks, CD-ROMs, or any other form of storage medium well-known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. Additionally, the ASIC can be located in a terminal device or a management device. Of course, the processor and the storage medium can also exist as discrete components in a terminal device or a management device.

[0184] Those skilled in the art should be able to realize that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a digital video disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)), etc.

[0185] Each device and product described in the above embodiments includes various modules / units, which can be software modules / units, hardware modules / units, or can be partly software modules / units and partly hardware modules / units. For example, for each device and product applied to or integrated into a chip, each module / unit it includes can be implemented in the form of hardware such as circuits, or at least some modules / units can be implemented in the form of software programs that run on the processor integrated inside the chip, and the remaining (if any) part of the modules / units can be implemented in the form of hardware such as circuits; for each device and product applied to or integrated into a chip module, each module / unit it includes can be implemented in the form of hardware such as circuits, and different modules / units can be located in the same component (such as a chip, a circuit module, etc.) or different components of the chip module, or at least some modules / units can be implemented in the form of software programs that run on the processor integrated inside the chip module, and the remaining (if any) part of the modules / units can be implemented in the form of hardware such as circuits; for each device and product applied to or integrated into a terminal device, each module / unit it includes can be implemented in the form of hardware such as circuits, and different modules / units can be located in the same component (such as a chip, a circuit module, etc.) or different components inside the terminal device, or at least some modules / units can be implemented in the form of software programs that run on the processor integrated inside the terminal device, and the remaining (if any) part of the modules / units can be implemented in the form of hardware such as circuits.

[0186] The specific embodiments described above further elaborate on the purpose, technical solutions, and beneficial effects of the embodiments of the present application. It should be understood that the above is only the specific embodiments of the embodiments of the present application and is not used to limit the protection scope of the embodiments of the present application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.

Claims

1. A K-line based data transmission method, characterized in that: Applied to an electronic device, the electronic device comprises: a server and a client, the server and the client perform two-way communication via a cloud platform, the client communicates with a target vehicle via a K-line, and the method comprises: Acquire first data at the time of receiving the first byte through the K line, wherein the first data includes: first byte data and first data state; Acquire second data at the time of receiving the second byte through the K line; the second data includes: second byte data and second data state; the time of receiving the second byte is later than the time of receiving the first byte; Determine a target byte interval according to the first byte receiving time and the second byte receiving time; determining a target byte data state according to the first data state, the second data state and the target byte interval; The first byte data, the second byte data, the target byte interval and the target byte data state are assembled to obtain first message data, and the first message data is transmitted to the server of the electronic device through the cloud platform.

2. The method according to claim 1, characterized in that The determining the target byte data state according to the first data state, the second data state and the target byte interval comprises: Determine a first received byte number according to the target byte interval and the first data state; When the first received byte number is greater than or equal to a preset first threshold, determining target byte data based on the first data state, the second data state, the first byte data, and the second byte data; Determine a target frame length according to the target byte data; When the target frame length is equal to the first received byte number, determining that the target byte data state is an end state; Otherwise, when the target frame length is not equal to the first received byte number, it is determined that the target byte data state is a continuous state.

3. The method according to claim 2, characterized in that The method further comprises: When the first number of received bytes is less than the preset first threshold, determining whether the first number of received bytes meets a preset first condition; When the first received byte number meets a preset first condition, determining that the target byte data state is a start state; Otherwise, when the first received byte number does not satisfy the preset first condition, it is determined that the target byte data state is a continuous state.

4. The method according to claim 1 or 2, characterized in that: The determining a first number of received bytes according to the target byte interval and the first data state comprises: When the first data state is a start state or a continuous state, determining a first byte number according to the first byte data; When the target byte interval is greater than a preset first interval threshold, determining the preset first byte number as the first received byte number; When the target byte interval is less than or equal to a preset first interval threshold, determining a second received byte number according to the second byte data; The first received byte number is determined according to the second received byte number and the first byte number.

5. The method according to claim 1 or 2, characterized in that: Determining the target frame length according to the target byte data comprises: Parsing the target byte data according to a preset first rule to obtain first parsed data; the first parsed data includes frame filling bytes and a target number of bytes; Determine the number of the frame filling bytes to obtain a first filling number; The frame length is determined according to the target number of bytes and the first filling number to obtain a target frame length.

6. The method according to claim 1, characterized in that The step of assembling the first byte data, the second byte data, the target byte interval, and the target byte data state to obtain first message data includes: Generate target message information according to the first byte data, the second byte data and the target byte interval; Assembling the first byte data, the second byte data and the target byte interval to obtain first assembled data; The target message information and the target byte data status are added to the first assembled data to obtain first message data.

7. A K-line based data transmission method, characterized in that: Applied to an electronic device, the electronic device comprises: a server and a client, the server comprises a data buffer; the server and the client perform two-way communication via a cloud platform, the method comprises: Receive first message data from the server; the first message data includes: n bytes of data, a first byte interval and a first byte data state; n is an integer greater than 1; Acquire cache data from the data buffer to obtain first cache data; Sending the first cached data to the cloud platform through the server according to the first byte interval, and clearing the data buffer; When the state of the first byte data is a start state or a continuous state, second cache data is generated according to the n bytes of data, and the second cache data is saved in the data buffer.

8. A K-line based data transmission device, characterized in that: Applied to electronic equipment, the electronic equipment includes: a server and a client, the server and the client perform two-way communication through a cloud platform, the client communicates with a target vehicle through a K line, and the device includes: An acquisition module, configured to acquire first data at a first byte receiving time through the K line, wherein the first data includes: first byte data and first data state; The acquisition module is further used to acquire second data at the time of receiving the second byte through the K line; the second data includes: second byte data and second data status; the time of receiving the second byte is later than the time of receiving the first byte; A determination module, configured to determine a target byte interval according to the first byte receiving time and the second byte receiving time; The determining module is further used to determine a target byte data state according to the first data state, the second data state and the target byte interval; A control module is used to assemble the first byte data, the second byte data, the target byte interval and the target byte data state to obtain first message data, and transmit the first message data to the server of the electronic device through the cloud platform.

9. A K-line based data transmission device, characterized in that: Applied to an electronic device, the electronic device comprises: a server and a client, the server comprises a data buffer; the server and the client perform two-way communication via a cloud platform, the device comprises: A receiving unit, configured to receive first message data from the server; the first message data includes: n bytes of data, a first byte interval and a first byte data state; n is an integer greater than 1; An acquiring unit, configured to acquire cache data from the data buffer to obtain first cache data; A sending unit, configured to send the first cached data to the cloud platform through the server according to the first byte interval, and clear the data buffer; A control unit is used to generate second cache data according to the n bytes of data when the state of the first byte data is a start state or a continuous state, and save the second cache data to the data buffer.

10. An electronic device, characterized in that: include: A processor, a memory, a communication interface, and one or more programs; The one or more programs are stored in the memory and configured to be executed by the processor, the programs comprising instructions for executing the steps in the method according to any one of claims 1 to 6.