Device communication method, device, terminal device and storage medium
By storing data in the cache when the sending condition is not met during the vehicle diagnosis process and sending it at one time when the condition is met, the data timeout and interruption caused by network delay in the traditional method is solved, and more stable and efficient data transmission is achieved.
Patent Information
- Application Number
- CN202211212134.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2042-09-30
AI Technical Summary
In the process of automotive diagnosis, traditional device communication methods are prone to data timeout and interruption due to the high requirements for network delay, especially in the case of poor network conditions.
When the data transmission condition is not met, the data is stored in the cache, and when the data transmission condition is met, the cached data is sent to the second terminal through the network to realize real-time transmission.
This method can reduce data interruption, reduce the impact of network delay on communication, and improve the stability and efficiency of data transmission.
Smart Images

Figure CN115633075B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a device communication method, apparatus, terminal device and storage medium. Background Art
[0002] With the development of the automobile industry, the degree of electronic control of automobiles is getting higher and higher. Some users use the original diagnostic equipment for automobile diagnosis, but there are very few users who can own the original diagnostic equipment, so some users will use general automobile diagnostic equipment. The service end (B end) and maintenance end (C end) solutions provided by the traditional method adopt the form of data forwarding. There are certain timeout settings in the process of data interaction. This method has a relatively high requirement for network delay. In the case of poor network, the car or diagnostic instrument is prone to data timeout, which leads to interruption problems. Summary of the invention
[0003] Based on this, it is necessary to provide a device communication method, apparatus, computer equipment and storage medium that can reduce data interruption in response to the above technical problems.
[0004] A device communication method, wherein a first terminal is connected to a first device, and a second terminal is connected to a second device, wherein the first terminal and the second terminal are connected via a network, and the method is applied to the first terminal, and the method comprises:
[0005] receiving data sent by the first device;
[0006] When the data transmission condition is not met, storing the data in a cache;
[0007] When the data sending condition is met, the data in the buffer is sent to the second terminal through the network, so that the second terminal sends the data to the second device in real time.
[0008] A device communication apparatus, the device communication apparatus is applied to a first terminal, the first terminal is connected to a first device, a second terminal is connected to a second device, the first terminal and the second terminal are connected via a network, the apparatus comprises:
[0009] A receiving module, used for receiving data sent by the first device;
[0010] A storage module, used for storing the data in a cache when a data transmission condition is not met;
[0011] The sending module is used to send the data in the cache to the second terminal through the network when the data sending condition is met, so that the second terminal sends the data to the second device in real time.
[0012] A terminal device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of each method embodiment when executing the computer program.
[0013] A computer-readable storage medium stores a computer program, which implements the steps of various method embodiments when executed by a processor.
[0014] The above-mentioned device communication method, apparatus, terminal device and storage medium have high delay requirements between the device and the terminal and are prone to disconnection. Therefore, by storing the data in the cache when the data sending conditions are not met, more data can be accumulated; when the data sending conditions are met, the data in the cache is sent to the second terminal through the network, that is, more data is sent to the second terminal at one time, and the second terminal needs to spend a longer time to send data to the second device; if the next data transmission has a network delay, then at this time, since the second terminal last sent data to the second device for a long time, and the delay timing of the second device is calculated from the start of no data reception, the data waiting time of the second device is reduced, thereby reducing the impact of network delays and reducing data interruptions caused by timeouts. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 A schematic diagram of an application environment of a device communication method in an embodiment;
[0016] Figure 2 A schematic diagram of a flow chart of a device communication method in one embodiment;
[0017] Figure 3 A schematic diagram of a process of using a first communication protocol to perform device communication in an embodiment;
[0018] Figure 4 A schematic diagram of a process of using a second communication protocol to perform device communication in one embodiment;
[0019] Figure 5 It is a schematic diagram of a process of using a second communication protocol to perform device communication in another embodiment;
[0020] Figure 6 is a structural block diagram of a device communication apparatus in one embodiment;
[0021] Figure 7 FIG. 4 is a diagram showing the internal structure of a terminal device in an embodiment. DETAILED DESCRIPTION
[0022] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0024] It should be noted that all directional indications in the embodiments of the present application (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly. The connection can be a direct connection or an indirect connection.
[0025] In addition, in this application, descriptions such as "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0026] The terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first terminal may be referred to as a second terminal, and similarly, a second terminal may be referred to as a first terminal. Both the first terminal and the second terminal are terminals, but they are not the same terminal.
[0027] It can be understood that the “connection” in the following embodiments should be understood as “electrical connection”, “communication connection”, etc. if the connected circuits, modules, units, etc. have electrical signals or data transmission between each other.
[0028] In one embodiment, Figure 1 The above is a schematic diagram of an application environment of a device communication method in an embodiment. Figure 1The system includes a first device 110, a first terminal 120, a second terminal 130 and a second device 140. The first device 110 is connected to the first terminal 120 via a local connection. The second terminal 130 and the second device 140 are connected via a local connection. Local connection refers to a wired connection, a Bluetooth connection, an NFC (Near Field Communication) connection, a local area network connection, etc. The first terminal 120 and the second terminal 130 are connected via a network. The network connection can be a wired network and a wireless network, and specifically can be a remote connection, a network connection through a cloud server, a wide area network, etc. with a longer delay. The data transmission delay between the first terminal 120 and the second terminal 130 is relatively high. One of the first device 110 and the second device 140 can be a detection device, and the other can be a device to be detected. The detection device is such as an automobile diagnostic device, and the device to be detected is such as a car. The first terminal 120 and the second terminal 130 combine common functions in the test scenario and can adapt to different detection devices or devices to be detected. Specifically in the automobile diagnosis scenario, the first device 110 may be an automobile diagnosis device, the first terminal 120 may be an automobile service terminal, the second terminal 130 may be a second maintenance terminal, and the second device 140 may be an automobile. Alternatively, the first device 110 may be an automobile, the first terminal 120 may be an automobile maintenance terminal, the second terminal 130 may be an automobile service terminal, and the second device 140 may be an automobile diagnosis device. The above scenario requires communication between the first device 110 and the second device 140. The delay allowed between the first device 110 and the first terminal 120 is relatively short. The traditional method directly adopts the form of data forwarding. When the delay between the first terminal 120 and the second terminal 130 is relatively high, the first terminal 120 and the second terminal 130 do not receive data for a long time and cannot play back data to the corresponding device, resulting in the local connection between the first device 110 and the first terminal 120, or the local connection between the second terminal 130 and the second device 140 being disconnected, resulting in the problem of data interruption due to timeout.
[0029] like Figure 2 FIG. 1 is a flow chart of a device communication method in an embodiment. A device communication method includes the following steps:
[0030] Step 202: Receive data sent by the first device.
[0031] Specifically, when the first device is a car diagnostic device, the data is car diagnostic data. The car diagnostic data can be a diagnostic request sent to a car module of the car. The car module is such as a steering system, an engine, a dashboard, etc. The user uses the first device to select the car module to be diagnosed for car diagnosis and sends data to the second device. In the process of sending data from the first device to the second device, the first terminal and the second terminal are required. The first terminal receives the data sent by the first device through the local connection.
[0032] Step 204: When the data transmission condition is not met, the data is stored in the cache.
[0033] Each communication protocol may have a corresponding data transmission condition. For example, the data transmission condition corresponding to the first communication protocol is that the count of the timer reaches a preset count, and the data transmission condition corresponding to the second communication protocol is that the data is a data packet to be responded.
[0034] Specifically, the first terminal may determine the corresponding data transmission condition based on the adopted communication protocol. When the data transmission condition corresponding to the communication protocol is not met, the data is stored in the cache. Then, when the data transmission condition is not met, the data sent by the first device is always stored in the cache.
[0035] Optionally, the first terminal obtains the selected vehicle model from the vehicle model selection interface, and determines the communication protocol corresponding to the vehicle model.
[0036] Step 206: When the data transmission condition is met, the data in the buffer is transmitted to the second terminal via the network, so that the second terminal transmits the data to the second device in real time.
[0037] Specifically, when the data transmission conditions corresponding to the communication protocol are met, the first terminal sends the data stored in the cache through the network so that the second terminal receives the data and sends the data to the second device in real time through the local connection. That is, the second terminal receives the data sent by the first terminal while forwarding the data to the second device.
[0038] In this embodiment, the delay requirement between the device and the terminal is high and the connection is easily disconnected. Therefore, by storing the data in the cache when the data transmission conditions are not met, more data can be accumulated; when the data transmission conditions are met, the data in the cache is sent to the second terminal through the network, that is, more data is sent to the second terminal at one time. At this time, the second terminal needs to spend more time to send data to the second device; if the next data transmission has a network delay, then at this time, since the second terminal last sent data to the second device for a long time, and the delay timing of the second device is calculated from the start of no data reception, the data waiting time of the second device is reduced, thereby reducing the impact of network delays and reducing data interruptions caused by timeouts. In addition, in network transmission, frequent transmissions will occupy network resources. The solution in this embodiment can reduce the number of network transmissions, transmit a large amount of data at one time as much as possible, and reduce a large amount of network resources occupied by multiple transmissions.
[0039] In one embodiment, when the data transmission condition is not met, storing the data in the cache includes: starting a timer; when the count of the timer does not reach a preset count, storing the data in the cache. When the data transmission condition is met, sending the data in the cache to the second terminal via the network includes: when the count of the timer reaches a preset count, sending the data in the cache to the second terminal via the network.
[0040] Specifically, the preset count refers to a value, time, etc. pre-stored in the first terminal. The preset count can be configured as needed. The first terminal can start counting when receiving the data sent by the first device for the first time, or can start counting from the time of initialization.
[0041] In this embodiment, when the timer count does not reach the preset count, the data is stored in the cache. When the preset count is reached, the data in the cache is sent to the second terminal via the network, so that the second terminal sends the data to the second device, which can reduce the delay between the device and the terminal and reduce data interruption.
[0042] In one embodiment, the first terminal, the first device, the second terminal and the second device communicate based on a first communication protocol; the data includes continuous frame data.
[0043] Among them, the first communication protocol can be but is not limited to the ISO15765-2 protocol, and can be extended to other similar protocols. The ISO15765-2 protocol is a diagnostic protocol based on the CAN (Controller Area Network) bus. According to the introduction of Unified Diagnostic Services (UDS protocol) in the ISO15765-2 protocol, data frames are divided into single frames, first frames, continuous frames and flow control frames. Continuous frame data contains a large amount of data. For CAN (Controller Area Network) diagnosis, it can be determined which of the four types of frames it belongs to by identifying the first byte of the data field of each CAN frame. The network layer distinguishes these four types of data units through N_PCL (Protocol Control Information). For single-frame data, due to the small amount of data, it can be forwarded directly to the second terminal.
[0044] Specifically, the first terminal receives data sent by the first device through a local connection; when the data is continuous frame data and the timer has not reached a preset count, the continuous frame data is stored in a cache; when the data is continuous frame data and the timer reaches a preset count, the continuous frame data is sent to the second terminal through the network, so that the second terminal sends the continuous frame data to the second device.
[0045] In this embodiment, adapted to the first communication protocol, when the data is continuous frame data and the timer reaches a preset count, the continuous frame data is sent through the network, so that the second terminal sends continuous frame data to the second device, which can reduce the delay between the device and the terminal and reduce data timeout interruptions.
[0046] In one embodiment, the first terminal, the first device, the second terminal and the second device communicate based on a first communication protocol; the method also includes: when receiving the first frame data sent by the first device to the second device, sending the first flow control frame data in response to the first frame data to the first device.
[0047] Among them, in the Unified Diagnostic Services (UDS) part of the ISO 15765-2 protocol, the flow control frame data needs to be responded to for the first frame data. The first flow control frame data includes information such as the baud rate of the second device. The first terminal can pre-store the information of the second device to generate the first flow control frame data.
[0048] Specifically, in a normal process, the first frame data is sent from the first device to the second device. When receiving the first frame data sent by the first device to the second device, the first terminal sends the first flow control frame data in response to the first frame data to the first device through the local connection.
[0049] Optionally, the data may be pre-configured to a background server or saved to a terminal via offline data, and when a vehicle model is selected, the configured flow control frame data may be selected according to the vehicle model.
[0050] In this embodiment, the first device sends the first frame data to the second device and waits to receive the flow control frame data in response from the second device. During this process, due to network delays, the connection between the first device and the first terminal is disconnected. In this case, the first terminal first sends the first flow control frame data in response to the first frame data to the first device to maintain a connection with the first device, thereby reducing data interruptions.
[0051] In one embodiment, the method also includes: sending the first frame data to the second terminal through the network, so that the second terminal sends the first frame data to the second device, and the second device sends the second flow control frame data in response to the first frame data to the second terminal; receiving the second flow control frame data and ignoring it.
[0052] Specifically, the first frame data sent by the first device should be sent to the second device. The first terminal sends the first frame data to the second terminal, the second terminal receives the first frame data, and sends the first frame data to the second device, and the second device sends the second flow control frame data in response to the first frame data to the second terminal. Since the first terminal has previously returned the flow control frame data to the first device, the second flow control frame data can be ignored.
[0053] In this embodiment, the first frame data is sent to the second terminal so that the second terminal sends the first frame data to the second device, and a connection with the second device can be established. The second device responds with second flow control frame data to indicate that the connection has been established. Then, in the process of the first terminal receiving the flow control frame data of the first device, the connection between the first device, the first terminal, the second terminal and the second device has been established, and the second flow control frame data returned by the second device is useless and can be ignored, which can reduce data transmission time and data interruption.
[0054] In one embodiment, when a data sending condition is met, data in a cache is sent to a second terminal via a network, including: when the data is a data packet to be responded to, the data in the cache and the data packet to be responded to are sent to the second terminal via the network; the data packet to be responded to is sent to the second terminal or to a second device; a first response packet in response to the data packet to be responded to is obtained, and the first response packet is sent to the first device.
[0055] Among them, the data packet to be responded to refers to the data packet that requires the response of the other end. The device performs the next operation after receiving the response packet. The data packet to be responded to can be sent to the second terminal or to the second device. The first response packet can be pre-configured in the background server or saved in the first terminal through offline data. After selecting the vehicle model, the configured response packet can be selected according to the vehicle model. The first response packet is related to the vehicle model. Specifically, the selected vehicle model can be obtained through the interface.
[0056] Specifically, when the data is a data packet to be responded, the first terminal can send the data in the cache and the data packet to be responded to to the second terminal through the network. Or the first terminal can add the data packet to be responded to to the cache and then send the data in the cache to the second terminal. The first terminal obtains the first response packet from the server or obtains the first response packet locally, and sends the first response packet to the first device.
[0057] The first terminal sends the data packet to be responded to to the second terminal, so that the second terminal sends the data packet to be responded to to the second device, and the second device sends a second response packet in response to the data packet to be responded to to the second terminal; the first terminal receives and ignores the second response packet.
[0058] In this embodiment, since sending to the second terminal or the second device needs to pass through the first terminal, the first terminal can return the first response packet to the first device in advance instead of the second device, so that the first device starts transmitting data in advance without disconnecting from the first terminal due to too long waiting time for response.
[0059] In one embodiment, the first terminal, the first device, the second terminal, and the second device communicate based on the second communication protocol. When the data is a data packet to be responded, the data in the cache and the data packet to be responded are sent to the second terminal through the network, including: when the data includes a connection establishment parameter in the second communication protocol, and the connection establishment parameter includes a byte to be responded, determining that the data is a data packet to be responded; storing the data packet to be responded in the cache, and sending the data in the cache to the second terminal through the network.
[0060] The second communication protocol may be, but is not limited to, SAE-J2819 (i.e., TP2.0 Vehicle Diagnostic Protocol), and may be extended to other protocols. The connection establishment parameter may refer to the TPCI1 parameter. The response byte refers to the high 4 bits of TPCI1 being 0b0001 or 0b0000.
[0061] Specifically, when the data sent by the first device includes the connection establishment parameters in the second communication protocol, and the connection establishment parameters include the response-pending byte, the first terminal determines that the data is a response-pending data packet. The first terminal stores the response-pending data packet in a cache and sends the data in the cache to the second terminal through the network.
[0062] In this embodiment, for the second communication protocol, since a response data packet is sent at regular intervals, the data in the cache can be sent to the second terminal after the response data packet arrives, so that the second terminal can send data to the second device in real time, reducing the impact of delay on the connection between the second device and the second terminal.
[0063] In one embodiment, a device communication method is provided, wherein a first terminal and a first device are connected locally, a second terminal and a second device are connected locally, the first terminal and the second terminal are connected via a network, and the first terminal, the first device, the second terminal and the second device communicate based on a first communication protocol. The method is applied to the first terminal and includes:
[0064] Step (a1), receiving data sent by the first device through the local connection.
[0065] Step (a2): when the data is the first frame data sent by the first device to the second device, first flow control frame data in response to the first frame data is sent to the first device through the local connection.
[0066] Step (a3), sending the first frame data to the second terminal through the network, so that the second terminal sends the first frame data to the second device, and the second device sends the second flow control frame data in response to the first frame data to the second terminal.
[0067] Step (a4), receiving the second flow control frame data and ignoring it.
[0068] Step (a5), when the data is continuous frame data and the timer has not reached a preset count, the continuous frame data is stored in a cache.
[0069] Step (a6), when the data is continuous frame data and the timer reaches a preset count, the continuous frame data is sent to the second terminal through the network, so that the second terminal sends the continuous frame data to the second device.
[0070] like Figure 3 FIG. 1 is a flow chart of using a first communication protocol to perform device communication in an embodiment. Figure 3 The flowchart can be applied to an automobile service terminal as well as an automobile maintenance terminal. Figure 3 The opposite end in the above means that when the current end is a car service terminal, the opposite end is a car maintenance terminal; when the current end is a car maintenance terminal, the opposite end is a car service terminal. Take the first device as a car diagnostic device, the first terminal as a car service terminal, the second terminal as a car maintenance terminal, the second device as a car, and the first communication protocol as ISO 15765-2 protocol as an example. The first terminal and the first device are connected via a CAN bus, the second terminal and the second device are connected via a CAN bus, and the first terminal and the second terminal are connected via a server.
[0071] The car service terminal initializes the car model database. After the car service terminal is initialized, it obtains the car model selected by the user and obtains the current vehicle information from the vehicle information set based on the car model. The vehicle information set can be pre-stored locally or in the cloud. The car service terminal initializes the CAN bus according to the vehicle information.
[0072] The automobile service terminal starts the timer and periodically checks whether the data length in the continuous frame data buffer is greater than 0, that is, whether there is data. If so, the data is sent to the other end through the network. Otherwise, no processing is performed.
[0073] The car service terminal monitors the CAN bus data end, that is, monitors whether the car diagnostic instrument has sent data. When there is data on the CAN bus, the application layer starts to parse the CAN bus data. The car service terminal determines whether the high four bits of the first byte of the data are 0b0001. When the high four bits of the first byte are 0b0001, the car service terminal determines that the current data is the first frame data according to the protocol. Check whether the CANID is in the database of the vehicle model, that is, compare the current CANID with the vehicle information to see if there is a matching CANID. If there is, send a frame of flow control frame data (that is, the first flow control frame data) to the CAN bus, and forward this frame data to the other end through the network.
[0074] When the high four bits of the first byte are 0b0011, the current data is judged as flow control frame data according to the protocol, and in this embodiment, it can be the second flow control frame data. Check whether the CANID is in the vehicle model database, that is, compare the current CANID with the vehicle information to see if there is a matching CANID. If there is, ignore this data. If not, forward this frame data to the other end through the network.
[0075] When the high four bits of the first byte are 0b0010, the current data is judged as continuous frame data according to the protocol. Check whether the CANID is in the vehicle model database, that is, compare the current CANID with the vehicle information to see if there is a matching CANID. If so, put the data into the continuous frame buffer.
[0076] In the above cases, when the CANID is not in the database of the vehicle model, it means that this vehicle model cannot be processed. Therefore, the automobile service terminal acts as a transfer station and sends the data directly to the other end. It can be understood that the step of querying whether the CANID is in the database of the vehicle model can be performed before determining whether the first byte is a preset byte. If it is, the step of determining the first byte is performed; if not, the data is directly sent to the other end through the network.
[0077] In this embodiment, according to the characteristics of each frame in the first communication protocol, a flow control frame needs to be replied to the first frame according to the protocol. The flow control frame that needs to be replied at this time can be sent instead of the other party to reduce the time timeout caused by two network transmissions; for continuous frames, the terminal can first receive the continuous frames and then transmit them to the other party through the network, ensuring that the maximum amount of data is transmitted as much as possible in one effective transmission; the data played back by the terminal to the device can be stably played back according to the received data, and the playback interval of continuous frames will not change too much due to network instability.
[0078] In one embodiment, a device communication method is provided, wherein a first terminal and a first device are connected locally, a second terminal and a second device are connected locally, and the first terminal and the second terminal are connected via a network. The method is applied to the first terminal, and the first terminal, the first device, the second terminal and the second device communicate based on a second communication protocol, including:
[0079] Step (b1), receiving data sent by the first device through the local connection.
[0080] Step (b2), when the data is not a data packet to be responded to, the data is stored in a cache.
[0081] When the data includes a connection establishment parameter in the second communication protocol, and the connection establishment parameter includes a response-pending byte, the data is determined to be a response-pending data packet.
[0082] Step (b3), storing the data packet to be responded to in the cache, and sending the data in the cache to the second terminal via the network; the data packet to be responded to is sent to the second terminal or to the second device.
[0083] Step (b4), obtaining a first response packet in response to the data packet to be responded to, and sending the first response packet to the first device.
[0084] Step (b5), sending the data packet to be responded to to the second terminal, so that the second terminal sends the data packet to be responded to to the second device, and the second device sends a second response packet in response to the data packet to be responded to to the second terminal.
[0085] Step (b6), receive the second response packet and ignore it.
[0086] like Figure 4 FIG. 1 is a flow chart of using the second communication protocol for device communication in one embodiment. Figure 4 The flowchart is applied to the automobile service terminal (indicated by end B in the figure). End C in the figure is the automobile diagnostic terminal. The second communication protocol is the SAE-J2819 protocol as an example for explanation. The first terminal and the first device are connected via a CAN bus, the second terminal and the second device are connected via a CAN bus, and the first terminal and the second terminal are connected via a server.
[0087] The car service terminal receives the data sent by the car diagnostic instrument and parses it to obtain the CANID and opcode (operation code). Determine whether the CANID is 0x200 and the opcode is 0xc0, that is, determine whether the data is the data for requesting the car module to establish a connection. If so, parse to obtain TP-ADDR (car module address). Receive the network CAN data packet sent by the C end and parse it. Determine whether the CANID is 0x200+TP-ADDR. If so, parse to obtain TX-ID-P (CANID sent by the car) and RX-ID-P (CANID sent by the car diagnostic instrument), and then send the network CAN data packet sent by the C end to the car diagnostic instrument; if not, directly send the network CAN data packet sent by the C end to the car diagnostic instrument.
[0088] When the data sent by the car diagnostic instrument does not meet the conditions of CANID being 0x200 and opcode being 0xc0, determine whether CANID is RX-ID-P. If not, it means that the data is not the model in the database, so it is not processed. If so, determine whether the data packet length is 1; if so, determine whether the high byte of the data is 0xB. 0xB indicates a response packet and ignores the current data. If the current CANLEN is not 1, determine whether TPCI1 == 0xA0. If so, parse the CAN data to obtain T1, T3 and the number of blocks. T1 refers to the timeout duration, that is, how long no connection will cause a timeout. T3 refers to the minimum data interval time, that is, the minimum interval between received data. Block data refers to the number of continuous data allowed to be sent. After obtaining the above data, send the data of the car diagnostic instrument to the C end.
[0089] When the upper four bits of TPCI1 are 0b0001 or 0b0000, it means that a response is required to the data packet, so the car service terminal responds to TPCI1&0x0F+1, forming the first response packet, and sends the first response packet to the car diagnostic instrument. The car service terminal determines whether there is data in the cache. When there is data in the cache, the data sent by the car diagnostic instrument is inserted into the cache data, and the cache data is sent to the C end. If there is no data in the cache, the data sent by the car diagnostic instrument is sent to the C end. When the upper four bits of TPCI1 are 0b0010, it means that this data packet does not require a response, so the data is stored in the cache.
[0090] In one embodiment, Figure 5 FIG. 1 is a flow chart of another embodiment of using the second communication protocol to perform device communication. Figure 5 The flowchart is applied to the automobile diagnostic terminal (represented by the C terminal in the figure). The B terminal in the figure is the automobile service terminal. The second communication protocol is the SAE-J2819 protocol as an example for explanation. The first terminal and the first device are connected through the CAN bus, the second terminal and the second device are connected through the CAN bus, and the first terminal and the second terminal are connected through the server.
[0091] The car diagnostic terminal receives the network CAN data packet sent by the B end and parses it to determine whether the CANID is 0x200. If so, TP-ADDR is obtained through the analysis. If not, the network CAN data packet is sent to the car through the CAN bus. The car diagnostic terminal receives the CAN data packet sent by the car and parses it to obtain the CANID. The car diagnostic terminal determines whether the CANID is 0x200+TP-ADDR, that is, whether it is data requesting a connection. When the CANID is 0x200+TP-ADDR, TX-ID-P (CANID sent by the car) and RX-ID-P (CANID sent by the car diagnostic instrument) are obtained through the analysis, and then the CAN data sent by the car is sent to the B end. When the CANID is not 0x200+TP-ADDR, determine whether the CANID is TX-ID-P. The subsequent process is the same as Figure 4 Similar, I will not go into details here.
[0092] In this embodiment, in combination with the characteristics of the second communication protocol, such as when a response is required during data transmission, when a response data packet is received, the data in the cache is sent, which can reduce communication interruptions caused by delays.
[0093] This application has been experimentally tested and can still achieve remote programming and other operations even when the network delay is relatively large.
[0094] It should be understood that although the above Figures 2 to 5 In the flowchart, each step is shown in sequence as indicated by the arrows, and each step in steps (a1) to (a6) and steps (b1) to (b6) is shown in sequence as indicated by the numbers, but these steps are not necessarily performed in the order indicated by the arrows or numbers. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be performed in other orders. Moreover, Figures 2 to 5 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0095] In one embodiment, Figure 6 FIG. 1 is a block diagram of a device communication apparatus in an embodiment. Figure 6 A device communication device is provided. The device can be a software module or a hardware module, or a combination of the two to become a part of a computer device. The device specifically includes: a receiving module 602, a storage module 604 and a sending module 606, wherein:
[0096] The receiving module 602 is used to receive data sent by the first device;
[0097] The storage module 604 is used to store the data in a cache when the data transmission condition is not met;
[0098] The sending module 606 is used to send the data in the buffer to the second terminal through the network when the data sending condition is met, so that the second terminal sends the data to the second device in real time.
[0099] In this embodiment, since the delay requirement between the device and the terminal is high and the connection is easily disconnected, more data can be accumulated by storing the data in the cache when the data transmission conditions are not met; when the data transmission conditions are met, the data in the cache is sent to the second terminal through the network, that is, more data is sent to the second terminal at one time, and the second terminal needs to spend more time to send data to the second device; if the next data transmission has a network delay, then at this time, since the second terminal last sent data to the second device for a long time, and the delay timing of the second device is calculated from the start of no data reception, the data waiting time of the second device is reduced, thereby reducing the impact of network delays and reducing data interruptions. In addition, in network transmission, frequent transmission will occupy network resources. The solution in this embodiment can reduce the number of network transmissions, transmit a large amount of data at one time as much as possible, and reduce a large amount of network resources occupied by multiple transmissions.
[0100] In one embodiment, the device also includes a timer. After the timer is started, the storage module 604 is used to store data in the cache when the timer count does not reach the preset count; the sending module 606 is used to send the data in the cache to the second terminal through the network when the timer count reaches the preset count.
[0101] In this embodiment, when the timer count does not reach the preset count, the data is stored in the cache. When the preset count is reached, the data in the cache is sent to the second terminal via the network, so that the second terminal sends the data to the second device, which can reduce the delay between the device and the terminal and reduce data interruption.
[0102] In one embodiment, the first terminal, the first device, the second terminal and the second device communicate based on a first communication protocol; the data includes continuous frame data.
[0103] In this embodiment, adapted to the first communication protocol, when the data is continuous frame data and the timer reaches a preset count, the continuous frame data is sent through the network, so that the second terminal sends continuous frame data to the second device, which can reduce the delay between the device and the terminal and reduce data interruptions caused by timeouts.
[0104] In one embodiment, the sending module 606 is further configured to send first flow control frame data in response to the first frame data to the first device when receiving the first frame data sent by the first device to the second device.
[0105] In this embodiment, the first device sends the first frame data to the second device and waits to receive the flow control frame data in response from the second device. During this process, due to network delays, the connection between the first device and the first terminal is disconnected. In this case, the first terminal first sends the first flow control frame data in response to the first frame data to the first device to maintain a connection with the first device, thereby reducing data interruptions.
[0106] In one embodiment, the sending module 606 is also used to send the first frame data to the second terminal through the network, so that the second terminal sends the first frame data to the second device, and the second device sends the second flow control frame data in response to the first frame data to the second terminal; the receiving module 602 is used to receive the second flow control frame data and ignore it.
[0107] In this embodiment, the first frame data is sent to the second terminal so that the second terminal sends the first frame data to the second device, and a connection with the second device can be established. The second device responds with second flow control frame data to indicate that the connection has been established. Then, in the process of the first terminal receiving the flow control frame data of the first device, the connection between the first device, the first terminal, the second terminal and the second device has been established, and the second flow control frame data returned by the second device is useless and can be ignored, which can reduce data transmission time and data interruption.
[0108] In one embodiment, the sending module 606 is used to send the data in the cache and the data packet to be responded to to the second terminal through the network when the data is a data packet to be responded to; the data packet to be responded to is sent to the second terminal or to the second device; obtain a first response packet in response to the data packet to be responded to, and send the first response packet to the first device.
[0109] In this embodiment, since sending to the second terminal or the second device needs to pass through the first terminal, the first terminal can return the first response packet to the first device in advance instead of the second device, so that the first device starts transmitting data in advance without disconnecting from the first terminal due to too long waiting time for response.
[0110] In one embodiment, the sending module 606 is used to determine that the data is a data packet to be responded to when the data includes a connection establishment parameter in the second communication protocol and the connection establishment parameter includes a byte to be responded to; store the data packet to be responded to in a cache, and send the data in the cache to the second terminal via the network.
[0111] In this embodiment, for the second communication protocol, since a response data packet is sent at regular intervals, the data in the cache can be sent to the second terminal after the response data packet arrives, so that the second terminal can send data to the second device in real time, reducing the impact of delay on the connection between the second device and the second terminal.
[0112] For the specific definition of the device communication device, please refer to the definition of the device communication method above, which will not be repeated here. Each module in the above-mentioned device communication device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the terminal device in the form of hardware, or can be stored in the memory of the terminal device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0113] In one embodiment, a terminal device is provided, whose internal structure diagram can be as follows: Figure 7 As shown. The terminal device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the terminal device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a device communication method is implemented. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the terminal device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the terminal device housing, or an external keyboard, touchpad or mouse, etc.
[0114] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the terminal device to which the scheme of the present application is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0115] In one embodiment, a terminal device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned method embodiments when executing the computer program.
[0116] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method embodiments are implemented.
[0117] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.
[0118] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes in the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0119] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A device communication method, characterized in that: A first terminal is connected to a first device, a second terminal is connected to a second device, the first terminal and the second terminal are connected via a network, the method is applied to the first terminal, and the method includes: Obtain the selected vehicle model from the vehicle model selection interface and determine the communication protocol corresponding to the vehicle model; receiving data sent by the first device; In the case where the communication protocol is a first communication protocol, when the count of the timer does not reach a preset count and when the data is continuous frame data, the data is stored in a cache; the first communication protocol includes a CAN protocol; When the timer count reaches the preset count, sending the data in the buffer to the second terminal via the network; In a case where the communication protocol is the second communication protocol, when the data is a data packet that does not require a response, storing the data in the cache; When the data includes a connection establishment parameter in the second communication protocol, and the connection establishment parameter includes a response-pending byte, determining that the data is a response-pending data packet; the second communication protocol includes a vehicle diagnostic protocol; The data packet to be responded to is stored in the cache, and the data in the cache is sent to the second terminal through the network; the data packet to be responded to is sent to the second terminal or to the second device.
2. The method according to claim 1, characterized in that: The method further comprises: In the case where the communication protocol is the first communication protocol, when the first frame data sent by the first device to the second device is received, first flow control frame data responding to the first frame data is sent to the first device.
3. The method according to claim 2, characterized in that The method further comprises: Sending the first frame data to the second terminal through the network, so that the second terminal sends the first frame data to the second device, and the second device sends the second flow control frame data in response to the first frame data to the second terminal; The second flow control frame data is received and ignored.
4. The method according to claim 1, characterized in that After storing the data packet to be responded to in the cache and sending the data in the cache to the second terminal through the network, the method further includes: Obtain a first response packet in response to the data packet to be responded to, and send the first response packet to the first device.
5. The method according to any one of claims 1 to 4, characterized in that: The first device is an automobile diagnostic device, the first terminal is an automobile service terminal, the second terminal is an automobile maintenance terminal, and the second device is an automobile; Alternatively, the first device is a car, the first terminal is a car maintenance terminal, the second terminal is a car service terminal, and the second device is a car diagnostic device.
6. A device communication apparatus, characterized in that: The device communication apparatus is applied to a first terminal, the first terminal is connected to a first device, the second terminal is connected to a second device, the first terminal and the second terminal are connected via a network, and the apparatus is used to implement the steps of the method described in any one of claims 1 to 5.
7. A terminal device, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Data communication method and device, electronic equipment and storage medium
CN114338270A
Data transmission method and device, electronic equipment and storage medium
CN114513385A
Data transmission method and device, equipment and storage medium
CN114553373A
Remote upgrading method, device and system and equipment end connector
CN114827206A