Dual-wire communication method, electronic device, and computer-readable storage medium
By using a two-wire communication method, ternary level signal transmission is achieved through a data bus and a ground wire, which solves the problem that traditional multi-wire communication methods are not conducive to miniaturization and improves communication stability and transmission efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-30
- Publication Date
- 2026-03-17
AI Technical Summary
Traditional multi-line communication methods are not conducive to product miniaturization and communication deployment, and it is difficult to balance transmission rate and stability.
It adopts a two-wire communication method, and realizes ternary level signal transmission through data bus and ground line, including node identification, clock synchronization and data transmission stages, and has anti-interference and high transmission rate.
This design enabled the product to be miniaturized, improved communication stability and transmission distance, while ensuring a high data transmission rate.
Smart Images

Figure CN116418369B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of communication technology, and in particular relates to a two-wire communication method, electronic device, and computer-readable storage medium. Background Technology
[0002] In traditional wired communication methods, generally speaking, the higher the voltage difference used for the communication signal, the more stable the communication and the longer the transmission distance, but the transmission rate will decrease. At the same time, the more lines used, the more complete the functions and the lower the hardware and software requirements, but more lines occupy more board space, which is not conducive to product miniaturization and communication layout. Summary of the Invention
[0003] To address the aforementioned technical problems, embodiments of this application provide a two-line communication method, an electronic device, and a computer-readable storage medium, which can solve the problem that traditional multi-line communication is not conducive to product miniaturization and communication layout.
[0004] A first aspect of this application provides a two-wire communication method applied to a first node, wherein the first node is connected to the same data bus and the same ground wire as other nodes; the two-wire communication method includes:
[0005] When the data bus is idle, after sending its own node identification code to the data bus in up to three different level modes, the level on the data bus is read.
[0006] When the level read on the data bus matches the level corresponding to its own node identification code, the target node identification code is sent to the data bus; wherein, when the target node reads the target node identification code on the data bus, it sends an acknowledgment code to the data bus;
[0007] In response to the acknowledgment code output by the target node read from the data bus, target data is sent to the data bus.
[0008] In some embodiments, before reading the levels on the data bus after sending its own node identification code to the data bus in up to three different levels, the method further includes:
[0009] A clock synchronization code is sent to the data bus so that other nodes connected to the data bus can synchronize their clocks according to the clock synchronization code.
[0010] In some embodiments, prior to sending the target data to the data bus, the method further includes:
[0011] In response to an acknowledgment code read from the data bus, a clock calibration code is sent to the data bus so that the target node calibrates its clock according to the clock calibration code.
[0012] In some embodiments, after sending the target data to the data bus, the method further includes:
[0013] If the confirmation code is not received after a preset time period following the transmission of the target data, the target data is retransmitted to the data bus until the confirmation code is received or the number of retransmissions reaches a preset number.
[0014] In the data bus, the maximum number of retransmissions is a preset number.
[0015] In some embodiments, after sending the target data to the data bus, the method further includes:
[0016] If the acknowledgment code is received within the preset time period after the target data is sent, and the target data does not include a return packet request, then an end code is sent or the next set of target data is sent to the data bus; or
[0017] If the acknowledgment code is received within the preset time after the target data is sent, and the target data includes the return packet request, then the data bus status will continue to be monitored to receive the return packet data, and the end code will be sent or the next target data will continue to be sent to the data bus when the return packet data is received;
[0018] The return packet request is used to instruct the target node to send the return packet data in response to the target data; the electrical parameters of the end code are different from the electrical parameters of the acknowledgment code.
[0019] In some embodiments, after sending the target data to the data bus, the method further includes:
[0020] Upon receiving a verification error code, the target data is retransmitted to the data bus.
[0021] In some embodiments, the method further includes:
[0022] When the data bus is occupied, identify the node occupying the data bus;
[0023] When the priority of a node occupying the data bus is lower than that of its own node, an interrupt communication signal is sent to the data bus to cause other nodes connected to the data bus to stop sending data;
[0024] After sending the interrupt communication signal, the target node identification code is sent to the data bus;
[0025] In response to the acknowledgment code read from the data bus, the target data is sent.
[0026] In some embodiments, it also includes:
[0027] In response to reading an interrupt communication signal from the data bus, stop sending target data to the data bus and save the target data;
[0028] In response to the received end code, the target data is retransmitted.
[0029] A second aspect of this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described above.
[0030] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method described above.
[0031] The two-wire communication method provided in this application sends its own node identification code to the bus in up to three levels, i.e., ternary mode, and then reads the level on the bus. In response to the reading that the level on the data bus is consistent with the level corresponding to its own node identification code, the target data is sent. When multiple nodes initiate communication requests at the same time, the bus voltage reflects the node identification code with the highest level voltage. Therefore, the sending node can be reliably arbitrated, and the sending node can send data to the target node. This communication method is based on two-wire implementation, such as a common ground line and a level signal line, which solves the problem that multi-wire communication is not conducive to product miniaturization and communication layout. Attached Figure Description
[0032] Figure 1 This is an exemplary schematic diagram of the application environment of various embodiments of this application;
[0033] Figure 2 This is a flowchart illustrating a two-line communication method provided for some embodiments of this application;
[0034] Figure 3 This is a data bus voltage waveform diagram of the arbitration pairing stage of the two-wire communication method in various embodiments of this application;
[0035] Figure 4 This is a flowchart of a two-line communication method provided in some embodiments of this application;
[0036] Figure 5 This is a data bus voltage waveform diagram of the initiation phase of the two-wire communication method in various embodiments of this application;
[0037] Figure 6This is a data bus voltage waveform diagram of the data transmission stage of the two-wire communication method in various embodiments of this application;
[0038] Figure 7 This is a data bus voltage waveform diagram of the final stage of the two-wire communication method in various embodiments of this application;
[0039] Figure 8 This is a flowchart illustrating a two-line communication method provided for some embodiments of this application;
[0040] Figure 9 This is a data bus voltage waveform diagram of the interruption phase of the two-wire communication method in various embodiments of this application;
[0041] Figure 10 This is a flowchart illustrating a two-line communication method provided for some embodiments of this application;
[0042] Figure 11 This is a schematic diagram of the structure of the two-line communication device provided in the embodiments of this application;
[0043] Figure 12 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0044] To make the technical problems, technical solutions, and beneficial effects to be solved by this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the scope of this application.
[0045] It should be noted that when a component is referred to as being "fixed to" or "set on" another component, it can be directly on or indirectly on that other component. When a component is referred to as being "connected to" another component, it can be directly connected to or indirectly connected to that other component.
[0046] It should be understood that the terms "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.
[0047] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means one or more, unless otherwise explicitly specified.
[0048] Currently, energy storage systems generally consist of multiple battery packs, such as a main battery pack and multiple slave battery packs. When an energy storage system is working, it is generally necessary to control the simultaneous start-up or shutdown of multiple battery packs in the energy storage system to extend the service life of the energy storage system.
[0049] In related technologies, the charging and discharging of energy storage systems are controlled by battery management chips. When the battery management chip needs to control multiple battery packs to start working at the same time, it generally needs to perform multiple samplings and then implement them through complex circuit design, which greatly limits the use of energy storage systems.
[0050] Please see Figure 1 The diagram shown is an exemplary schematic of the application environment for various embodiments of this application. Figure 1 As shown, the two-wire communication method provided in this application embodiment can be applied to a first node. The first node and other nodes (i.e., the second to the nth node) are connected to the same data bus (i.e., DATA_VOL) and the same ground wire (i.e., GND), where the ground wire is used to provide a ground reference for the voltage on the data bus. It is understood that the two-wire communication method can also be applied to other nodes, and each node can communicate with other nodes based on the two-wire communication method. Furthermore, each node refers to an electrical device that can communicate with each other, such as an energy storage device, charging device, network device, lighting device, self-moving device, or a charging base station for a self-moving device. In a system that can communicate with each other, each node can be a device of the same type or different types. For example, a charging device and multiple energy storage devices can constitute an energy storage system.
[0051] In some embodiments, each node may refer to different modules within the same device. For example, power conversion modules, power supply modules, display modules, etc., within an energy storage device, each module acts as a node and can communicate with other nodes using a two-wire communication method.
[0052] For example, under normal conditions, the data bus level is 0V. Each node can control itself to output 0V, 3.3V, or 5V at any given time to display the data level. When multiple nodes output on the data bus, the data levels are displayed in the priority order of 5V→3.3V→0V. If any node outputs 5V, the data bus displays 5V. If no node outputs 5V, but any node outputs 3.3V, the data bus displays 3.3V. Conversely, if all nodes output 0V, the data bus is 0V.
[0053] The basic stages of communication include initiation, arbitration pairing, data transmission, interruption, and termination. Therefore, when transmitting data on the data bus, data can be sent in ternary mode (0V, 3.3V, and 5V represent 0, 1, and 2 respectively), or in binary mode (0V, 3.3V, or 0V, 5V, or 3.3V, 5V, representing 0 and 1 respectively) in any one or more stages.
[0054] Please see Figure 2 The diagram shows a flowchart of a two-line communication method provided in an embodiment of this application. The two-line communication method provided in an embodiment of this application includes steps S110-S130.
[0055] Step S110: When the data bus is idle, after sending its own node identification code to the data bus in up to three different level modes, the level on the data bus is read.
[0056] The arbitration pairing phase, specifically step S110, is executed when the data bus is idle. "Data bus idle" means that the data bus is at 0V for a consecutive preset number of clock cycles, or that a node has sent an end code. This consecutive preset number of clock cycles can be 5, 10, or 15 clock cycles, and is not limited here.
[0057] The three voltage levels include a first level, a second level, and a third level, with voltages increasing sequentially. For example, taking the two-wire communication method applied to the first node, during the arbitration and pairing phase, if the first node's self-identification code is 012, it will output 0V, 3.3V, and 5V levels to the data bus for three consecutive clock cycles to send its self-identification code. Alternatively, if the first node's self-identification code is 011, it will output 0V, 3.3V, and 3.3V levels to the data bus for three consecutive clock cycles to send its self-identification code. After sending its self-identification code, the first node reads the voltage levels on the data bus, for example, by sending through one port and detecting them in real time through another port.
[0058] Therefore, each node transmits its own identification code using three different voltage levels. Each node has the capability to transmit its own identification code by using 5V, 3.3V, and 0V to represent ternary 2, 1, and 0, respectively. The actual voltage level transmitted—whether it is one, two, or three—is determined by its own identification code.
[0059] Step S120: When the level on the data bus is found to be consistent with the level corresponding to the self-node identification code, the target node identification code is sent to the data bus.
[0060] Understandably, when the target node reads the target node identification code on the data bus, it sends an acknowledgment code to the data bus to notify the first node that its target node identification code has been received and acknowledged, indicating successful communication pairing. Please refer to [link / reference]. Figure 2 and Figure 3 For example, at any given moment within the same three consecutive clock cycles, the first node, as the first sending node, sends its own node identification code, i.e. Figure 3 The ID (Identity Document) number shown is 120. The second node, acting as the second transmitting node, sends its own node identification code 111 (ID number 111). In the second clock cycle, both nodes detect a data bus voltage of 5V. At this point, the second node considers this inconsistent with its own node identification code and arbitration fails. Therefore, in the third clock cycle, it stops outputting the third bit of its identification code (1) and instead outputs 0, indicating that the second node's arbitration failed and it does not have the authority to transmit data on the data bus in the next moment. Thus, the data levels displayed on the data bus in the next three consecutive clock cycles are 3.3V, 5V, and 0V, respectively, consistent with the first node's own identification code 120, indicating that the first node's arbitration was successful. The first node, having successfully arbitrated, has the authority to transmit data on the data bus in the next moment. After successful arbitration, the first node sends the target node's identification code 010 (ID number 010) to await a response from the target node for pairing.
[0061] Step S130: In response to the acknowledgment code output by the target node read from the data bus, send target data to the data bus.
[0062] Please see Figure 2 and Figure 3For example, after successful arbitration, the first node sends the target node identification code on the data bus. In response to the received identification code, the target node sends an acknowledgment code (ACK) on the data bus, such as a 3.3V level signal. The first node reads this ACK from the data bus, indicating successful pairing between the two nodes, thus enabling subsequent data communication and the transmission of target data. It is understood that a 3.3V level ACK is merely an example; the ACK level parameter can be arbitrarily set according to requirements, such as two 3.3V levels, without further limitations.
[0063] The aforementioned two-line communication method has fewer communication lines and the ability to transmit data in ternary mode, which provides good anti-interference capabilities, promotes stable communication, allows for longer transmission distances, and ensures high-efficiency transmission rates.
[0064] Please continue reading. Figure 2 and 3 In some embodiments, to ensure smooth data transmission, before the arbitration matching phase ends and the target data is sent, the two nodes that are about to transmit data perform clock calibration or synchronization. Specifically, before sending the target data to the data bus in step S130, the two-wire communication method further includes: in response to an acknowledgment code read from the data bus, sending a clock calibration code to the data bus so that the target node calibrates its clock according to the clock calibration code.
[0065] For example, after the first node reads the acknowledgment code sent by the target node from the data bus, it outputs a clock calibration code on the data bus, such as a 5V level. After the target node reads this clock calibration code on the data bus, it recalibrates its clock to synchronize with the first node's clock and enters the data transmission and verification phase. This ensures accurate and smooth data transmission between the two nodes, minimizing transmission delays and data loss. It is understood that a 5V clock calibration code is merely an example; the level parameter of the clock calibration code can be arbitrarily set according to requirements, such as two 5V levels, without further limitations.
[0066] Please see Figure 4 The diagram shows a flowchart of a two-line communication method provided in an embodiment of this application. (In conjunction with...) Figure 4 and Figure 5 In some embodiments, to ensure smooth communication between nodes, clock synchronization is performed on each node during the communication initiation phase. Specifically, before step S110, the two-wire communication method further includes step S105: sending a clock synchronization code to the data bus so that other nodes connected to the data bus can synchronize their clocks according to the clock synchronization code.
[0067] For example, when the data bus is idle, the node that needs to initiate communication (such as the first node) will actively send a clock synchronization code to the data bus, such as an alternating 5V→3.3V→5V level. Figure 5 As shown, the voltage of the entire data bus is pulled high. The first 5V rising edge read by all nodes from the data bus serves as the starting point for the clock synchronization code. Based on these three rising edges, each node triggers its own clock to synchronize with the clock of the node initiating communication, thus ensuring smooth data transmission and minimizing transmission delays and data loss during subsequent communication. Following this, the arbitration phase begins. It can be understood that the clock synchronization code can also be considered the start code for communication. The level parameters of the clock synchronization code can be arbitrarily set according to requirements and are not limited here.
[0068] Please continue reading. Figure 6 In some embodiments, when the two-wire communication method enters the data transmission phase, the sending node (e.g., the first node) transmits binary data on the data bus using 0V and 3.3V as 0 and 1 signals, respectively. Each transmission consists of 8 data bytes + a checksum + a request for a response. The response request instructs the target node to send a response in response to the target data. A response request code of 1 indicates that the target node needs to respond, meaning the target data includes the response request. For example... Figure 6 0 indicates that no response is needed from the target node, meaning the target data does not include a response request. After transmission is complete, the next clock cycle outputs only a 0V level and continuously reads (i.e., listens) the level on the data bus for a response; for example, waiting for the target node to reply with an acknowledgment code (ACK, e.g., 3.3V) and response data. In other embodiments, the node sending data can transmit binary data using 3.3V and 5V, or 0V and 5V as 0 and 1 signals on the data bus; or, it can transmit ternary data using 0V, 3.3V, and 5V as 0, 1, and 2 signals on the data bus.
[0069] Please see Figure 6 In some embodiments, after sending the target data to the bus in step S130, the method further includes: if the acknowledgment code is not received after a preset time period following the transmission of the target data, retransmitting the target data to the data bus until the acknowledgment code is received or the number of retransmissions reaches a preset number, wherein the maximum number of retransmissions is the preset number.
[0070] For example, if the target node receives the target data, it first outputs a 3.3V acknowledgment code to the data bus. Furthermore, if the target data contains a request response code of 1, the target node also needs to send response data to the data bus, and the sending node (e.g., the first node) listens for and receives the response data; if the target data contains a request response code of 0, the target node only needs to output a 3.3V acknowledgment code to the data bus.
[0071] If the sending node reads an acknowledgment code from the data bus within a preset time period, it considers the target data transmission successful. Conversely, if no acknowledgment code is received within the preset time period (i.e., the data bus voltage remains at 0V for the preset time period), the sending node retransmits the target data to the data bus until an acknowledgment code is received. If no acknowledgment code is received again within the preset time period, the node retransmits again until a preset number of retransmissions is reached, such as 2 or 3 times. It is understood that the maximum number of retransmissions can be modified in the corresponding register.
[0072] In the above embodiments, after the sending node sends the target data, the target node needs to reply with an acknowledgment code to confirm, making the success or failure of data transmission knowable; at the same time, a retransmission mechanism is set up to improve the success rate of data transmission.
[0073] Please continue reading. Figure 6 In some embodiments, after sending the target data to the bus in step S130, the two-wire communication method further includes: if the acknowledgment code is received within the preset time after the target data is sent, and the target data does not include a return packet request, then an end code is sent or the next target data is sent to the data bus.
[0074] For example, if the request response code in the target data sent by the sending node is 0, the target node only needs to output a 3.3V acknowledgment code to the data bus. Then, the sending node considers the target data transmission successful upon receiving the acknowledgment code from the target node on the data bus after a preset time, and continues to the next step. If data transmission has ended, an end code is sent, waiting for the next data transmission to begin. See [link to relevant documentation]. Figure 7The end-of-transmission code can be an alternating voltage level of 5V→0V→3.3V→0V. This demonstrates that the electrical parameters of the end-of-transmission code differ from those of the acknowledgment code, facilitating node differentiation and response to each data parameter. If data transmission is not complete, the sending node continues to send the next target data to the data bus. This next target data can generally differ from the previous target data; it can be a data packet or a target node identification code from another target node, seeking data communication with that node. If any node reads a receive code from the data bus, it signifies the end of communication, assuming the data bus is idle, and all other nodes can re-initiate communication.
[0075] Please see Figure 6 In some embodiments, after sending target data to the bus in step S130, if the acknowledgment code is received within the preset time after the target data is sent, and the target data includes the return packet request, the two-wire communication method continues to monitor the data bus status to receive return packet data, and sends the end code or continues to send the next target data to the data bus when the return packet data is received; wherein, the return packet request is used to instruct the target node to send the return packet data in response to the target data.
[0076] For example, if the target data sent by the sending node contains a request reply code of 1, it is considered that the target data includes a reply request. The target node needs to output a 3.3V acknowledgment code to the data bus within a preset time period, and then needs to send reply data to the data bus. The sending node continues to listen for and receive reply data. After receiving reply data from the data bus, if the data transmission has ended, the sending node sends an end code and waits for the next data transmission to begin; if the data transmission has not ended, the sending node continues to send the next target data to the data bus. Generally, this next target data can be different from the previous target data; it can be a data packet or a target node identification code of another target node, in order to seek data communication with another target node.
[0077] In some embodiments, after sending the target data to the data bus in step S130, the two-wire communication method further includes: resending the target data to the data bus when a verification error code is received.
[0078] For example, the level parameters of the check error code can differ from those of the clock synchronization code, acknowledgment code, and end code; for instance, it can be one or two 5V levels to facilitate identification by the transmitting node. When the transmitting node receives a check error code, it indicates a data transmission error. Therefore, to ensure successful data transmission, the target data should be retransmitted to the target node via the data bus to ensure successful data transmission.
[0079] Optionally, upon receiving a verification error code, the target data is retransmitted to the data bus until an acknowledgment code is received within a preset time period after the target data was sent, or the number of retransmissions reaches a preset number. That is, if no acknowledgment code is received again after the preset time period, the data is retransmitted again until the preset number is reached, such as 2 or 3 times. It is understood that the maximum number of retransmissions can be modified in the corresponding register.
[0080] Please see Figure 8 The diagram shows a flowchart of a two-line communication method provided in an embodiment of this application. (In conjunction with...) Figure 8 and Figure 9 In some cases, emergency communication is required, necessitating the interruption of current communication for emergency communication. Therefore, in some embodiments, the two-wire communication method further includes:
[0081] Step S210: When the data bus is occupied, identify the node occupying the data bus.
[0082] For example, when the first node and the second node are communicating with each other, the nth node detects the level signal of the data bus. At this time, no data idle state is detected on the data bus (i.e., the data bus is at 0V level or end code for a consecutive preset number of clock cycles). This means that the data bus is occupied. The nth node confirms the first node and the second node that occupy the data bus based on the detected data.
[0083] Step S220: When the priority of the node occupying the data bus is lower than that of its own node, an interrupt communication signal is sent to the data bus to cause other nodes connected to the data bus to stop sending data.
[0084] The node priorities are set before step 210, for example, during the setup of the entire interconnected system. The nth node will compare its priority with the node occupying the data bus. If the nth node's priority is lower than the node occupying the data bus, it will not send an interrupt communication signal to the data bus; otherwise, it will send an interrupt communication signal. At this time, all other nodes connected to the data bus (including the node occupying the data bus) will receive the interrupt communication signal and stop sending data accordingly, thus temporarily putting the bus into a data idle state. The interrupt communication signal can be a continuous series of 5V levels (e.g., 4, 5, 10 clock cycles), to distinguish it from the continuous series of 3.3V levels representing 1s in binary data transmission, allowing all other nodes to successfully stop sending data based on the interrupt communication signal. It is understood that the level parameters of the interrupt communication signal can be set according to requirements and are not limited here.
[0085] Step S230: After sending the interrupt communication signal, send the target node identification code to the data bus.
[0086] After the nth node sends an interrupt communication signal, it has already occupied the data bus for data transmission. From another perspective, this can also be considered as successful arbitration. Therefore, it sends the target node identification code to the data bus to seek communication with the target node (e.g., ...). Figure 9 Pair the m-th node.
[0087] Step S240: In response to the acknowledgment code read from the data bus, the target data is sent.
[0088] For example, after the nth node sends an interrupt communication signal, it sends the target node identification code to be communicated with on the data bus. The target node (e.g.) Figure 9 The m-th node, upon receiving its own identification code, will send an acknowledgment code on the data bus. The n-th node reads this acknowledgment code from the data bus, indicating that the two nodes have successfully paired, allowing subsequent data communication to proceed and the target data to be sent. After the data communication ends, an end code is sent to the data bus. It is understood that step S240 is similar to step S130, and other subsequent or detailed steps applicable to step S130 also apply to step S240, and will not be elaborated further here.
[0089] Optionally, once a node triggers a communication interruption, other nodes will no longer be able to trigger a communication interruption until the current transmission is completed, thus ensuring that the node that interrupted the communication can achieve complete data transmission.
[0090] In the above embodiments, after the data transmission of a node occupying the data bus (such as the first node and the second node) is interrupted, the node occupying the data bus can continue data transmission after the data transmission of the node causing the interruption ends, thereby ensuring the integrity of the previous data transmission. Please refer to Figure 10, which is a flowchart of a two-line communication method provided in an embodiment of this application. Combined with... Figure 9 and Figure 10 In some embodiments, the two-wire communication method further includes:
[0091] Step S310: In response to reading an interrupt communication signal from the data bus, stop sending target data to the data bus and save the target data.
[0092] For example, before reading the interrupt communication signal from the data bus, such as the first node acting as the sending node and the second node acting as the target node, the first node stops sending the current target data to the data bus and saves the complete current target data when it reads the interrupt communication signal from the data bus.
[0093] Step S320: In response to the received end code, retransmit the target data.
[0094] After the emergency message of communication interruption is sent, the first node, upon receiving the receive code, retransmits the previously interrupted current target data. The second node, upon receiving the receive code, listens to the data bus, waiting to receive the previously interrupted current target data.
[0095] In some embodiments, the two-line communication method further includes a broadcast function. After successful arbitration or the sending node sends an interruption signal, it sends the target node identification code as a broadcast code. For example, if all the target node identification codes are 0, the target data can be sent to all other nodes, and all other nodes will receive the target data.
[0096] Optionally, the request response code for the broadcast target data can only be 0, and no response is requested to avoid data transmission errors.
[0097] Optionally, similar to one of the embodiments described above, upon receiving a verification error code, the target data is retransmitted to the data bus. This continues until an acknowledgment code is received within a preset time after the target data is sent, or the number of retransmissions reaches a preset number. That is, if no acknowledgment code is received again after the preset time, the data is retransmitted again until the preset number is reached, such as 2 or 3 times. It is understood that the maximum number of retransmissions can be modified in the corresponding register.
[0098] Corresponding to the two-line communication method described in the above embodiments, Figure 11 A structural block diagram of a two-line communication device provided in an embodiment of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.
[0099] Please refer to Figure 11 The two-wire communication device is applied to the first node, which is connected to the same data bus and the same ground line as other nodes. The two-wire communication device includes a first transceiver module 801, a second transceiver module 802 and a third transceiver module 803.
[0100] When the data bus is idle, the first transceiver module 801 sends its own node identification code to the data bus in up to three different level modes, and then reads the level on the data bus.
[0101] The second transceiver module 802 sends the target node identification code when it reads that the level on the data bus is consistent with the level corresponding to its own node identification code.
[0102] The third transceiver module 803, in response to the acknowledgment code output by the target node read from the data bus, sends target data to the data bus.
[0103] In one possible implementation, the first transceiver module 801 is further configured to send a clock synchronization code to the data bus so that other nodes connected to the data bus can synchronize their clocks according to the clock synchronization code.
[0104] In one possible implementation, the third transceiver module 803 is further configured to send a clock calibration code to the data bus in response to an acknowledgment code read from the data bus, so that the target node calibrates its clock according to the clock calibration code.
[0105] In one possible implementation, the third transceiver module 803 is further configured to resend the target data to the data bus until the acknowledgment code is received or the number of resends reaches a preset number if the acknowledgment code is not received after a preset time period following the transmission of the target data; wherein the maximum number of resends is the preset number.
[0106] In one possible implementation, the third transceiver module 803 is further configured to, if the acknowledgment code is received within the preset time period after the target data is sent, and the target data does not include a return packet request, then send an end code or continue sending the next target data to the data bus; or
[0107] If the acknowledgment code is received within the preset time after the target data is sent, and the target data includes the return packet request, then the data bus status will continue to be monitored to receive the return packet data, and the end code will be sent or the next target data will continue to be sent to the data bus when the return packet data is received;
[0108] The return packet request is used to instruct the target node to send the return packet data in response to the target data; the electrical parameters of the end code are different from the electrical parameters of the acknowledgment code.
[0109] In one possible implementation, the third transceiver module 803 is further configured to resend the target data to the data bus when a verification error code is received.
[0110] In one possible implementation, the two-wire communication device also includes a detection module and an interrupt module.
[0111] The detection module identifies the node occupying the data bus when the data bus is occupied.
[0112] The interrupt module sends an interrupt communication signal to the data bus when the priority of the node occupying the data bus is lower than that of its own node, so that other nodes connected to the data bus stop sending data.
[0113] The second transceiver module 802 is further configured to send the target node identification code to the data bus after sending an interrupt communication signal;
[0114] The third transceiver module 803 is also used to send the target data in response to an acknowledgment code read from the data bus.
[0115] In one possible implementation, the two-wire communication device further includes a storage module, which is used to stop sending target data to the data bus and save the target data in response to reading an interrupt communication signal from the data bus;
[0116] The third transceiver module 803 is also used to retransmit the target data in response to the received end code.
[0117] Figure 12 This is a schematic diagram of the structure of an electronic device 90 provided in an embodiment of this application. Figure 12 As shown, the electronic device 90 of this embodiment includes: at least one processor 901 ( Figure 12 Only one is shown in the diagram), memory 903, and computer program 902 stored in memory 903 and executable on at least one processor 901, wherein processor 901 executes computer program 902 to implement the steps in the above embodiments.
[0118] The electronic device 90 may include, but is not limited to, a processor 901 and a memory 903. Those skilled in the art will understand that... Figure 12 This is merely an example of electronic device 90 and does not constitute a limitation on electronic device 90. It may include more or fewer components than shown, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0119] The processor 901 may be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0120] In some embodiments, the memory 903 may be an internal storage unit of the electronic device 90, such as a hard disk or memory of the electronic device 90. In other embodiments, the memory 903 may be an external storage device of the electronic device 90, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device 900. Furthermore, the memory 903 may include both internal and external storage units of the electronic device 90. The memory 903 is used to store the operating system, applications, boot loader, data, and other programs, such as the program code of the computer program. The memory 903 can also be used to temporarily store data that has been output or will be output.
[0121] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, when implementing all or part of the processes in the methods of the above embodiments of this application, it can be accomplished by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include at least: any entity or device capable of carrying computer program code to a charging device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, such as a USB flash drive, a portable hard drive, a magnetic disk, or an optical disk. In some jurisdictions, according to legislation and patent practice, a computer-readable storage medium cannot be an electrical carrier signal or a telecommunication signal.
[0122] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0123] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0124] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0125] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. The apparatus / network device embodiments described above are merely illustrative, and the division of modules or units is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, and some features may be ignored. Furthermore, the indirect coupling, direct coupling, or communication connection shown or discussed may be through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0126] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0127] The embodiments described above are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions will not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A two-wire communication method, characterized by, The application is applied to a first node, which is connected to a same data bus and a same ground wire with other nodes; the double-line communication method comprises: When the data bus is idle, sending a node identification code of the first node to the data bus in a manner of at most three levels, and reading a level on the data bus; When the level on the data bus is consistent with a level corresponding to the node identification code of the first node, sending a target node identification code to the data bus; wherein, a target node sends a confirmation code to the data bus when the target node identification code is read on the data bus; In response to the confirmation code output by the target node and read on the data bus, sending target data to the data bus; The double-line communication method further comprises: When the data bus is occupied, confirming a node occupying the data bus; When a priority of the node occupying the data bus is lower than a priority of the first node, sending an interrupt communication signal to the data bus to make other nodes connected to the data bus stop sending data; After sending the interrupt communication signal, sending the target node identification code to the data bus; In response to the confirmation code read on the data bus, sending the target data.
2. The method of claim 1, wherein, Before the reading of the level on the data bus after the sending of the node identification code of the first node to the data bus in the manner of at most three levels, the method further comprises: Sending a clock synchronization code to the data bus to make other nodes connected to the data bus perform clock synchronization according to the clock synchronization code.
3. The method according to claim 1 or 2, characterized in that, Before the sending of the target data to the data bus, the method further comprises: In response to the confirmation code read on the data bus, sending a clock calibration code to the data bus to make the target node perform calibration clock according to the clock calibration code.
4. The method of claim 1, wherein, After the sending of the target data to the data bus, the method further comprises: If the confirmation code is not received after the target data is sent for more than a preset time length, the target data is re-sent to the data bus until the confirmation code is received or the number of re-sending reaches a preset number of times; The maximum number of re-sending is the preset number of times.
5. The method of claim 1, wherein, After the sending of the target data to the data bus, the method further comprises: If the confirmation code is received within the preset time length after the target data is sent, and the target data does not include a back-packet request, an end code is sent or the next target data is continuously sent to the data bus; or If the confirmation code is received within the preset time length after the target data is sent, and the target data includes the back-packet request, the data bus state is continuously monitored to receive back-packet data, and the end code is sent or the next target data is continuously sent to the data bus when the back-packet data is received; The back-packet request is used to indicate that the target node sends the back-packet data in response to the target data; and an electrical parameter of the end code is different from an electrical parameter of the confirmation code.
6. The method of claim 1, wherein, After the sending of the target data to the data bus, the method further comprises: When a check error code is received, the target data is re-sent to the data bus.
7. The method according to any one of claims 1 to 6, characterized in that, The method further comprises: in response to reading an interrupt communication signal from the data bus, stopping sending target data to the data bus and saving the target data; in response to the received end code, resending the target data.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The computer program is executed by the processor to implement the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 8. The computer program is executed by the processor to implement the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Optical data bus and method
CN102484533A
Multi-level data transmission method and system
CN103118251A