CN116418369A - Two-wire communication method, electronic device and computer readable storage medium - Google Patents
Two-wire communication method, electronic device and computer readable storage medium Download PDFInfo
- Publication number
- CN116418369A CN116418369A CN202310375144.4A CN202310375144A CN116418369A CN 116418369 A CN116418369 A CN 116418369A CN 202310375144 A CN202310375144 A CN 202310375144A CN 116418369 A CN116418369 A CN 116418369A
- Authority
- CN
- China
- Prior art keywords
- data bus
- data
- node
- code
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04B—TRANSMISSION
- H04B3/00—Line transmission systems
- H04B3/50—Systems for transmission between fixed stations via two-conductor transmission lines
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/40—Bus structure
- G06F13/4063—Device-to-bus coupling
- G06F13/4068—Electrical coupling
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04B—TRANSMISSION
- H04B3/00—Line transmission systems
- H04B3/02—Details
- H04B3/04—Control of transmission; Equalising
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/40006—Architecture of a communication node
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Small-Scale Networks (AREA)
Abstract
本申请属于通讯技术领域,提供一种双线通讯方法、电子设备和计算机可读存储介质,双线通讯方法向总线以最多三种电平、即三进制的方式发送自身节点识别码后读取总线上的电平,响应于读取到所述数据总线上的电平与所述自身节点识别码对应的电平一致,发送目标数据,在多个节点同时发起通讯请求时,总线电压体现的是电平电压最高的节点识别码,因此,可以可靠地仲裁出发送节点,如此发送节点可以向目标节点发送数据,这种通讯方式是基于双线实现,比如共地线和电平信号线,解决了多线通讯不利于产品的小型化与通讯布置的问题。
This application belongs to the technical field of communication, and provides a two-wire communication method, electronic equipment and a computer-readable storage medium. Take the level on the bus, and send the target data in response to reading the level on the data bus that is consistent with the level corresponding to the self-node identification code. When multiple nodes initiate communication requests at the same time, the bus voltage reflects The identification code of the node with the highest level voltage, therefore, can reliably arbitrate the sending node, so that the sending node can send data to the target node. This communication method is based on two-wire implementation, such as common ground wire and level signal wire , which solves the problem that multi-line communication is not conducive to product miniaturization and communication layout.
Description
技术领域technical field
本申请属于通讯技术领域,尤其涉及一种双线通讯方法、电子设备和计算机可读存储介质。The present application belongs to the technical field of communication, and in particular relates to a two-line communication method, electronic equipment and a computer-readable storage medium.
背景技术Background technique
传统的有限通讯方式一般来说,通讯信号所采用的电压差越高时,通讯越稳定,可以传输的距离越远,但是传输速率将有所下降。同时,采用的线数越多,往往功能越全,软硬件要求越低,但是线数越多占用的板上空间大,不利于产品的小型化与通讯布置。Traditional limited communication methods Generally speaking, the higher the voltage difference used by the communication signal, the more stable the communication and the farther the transmission distance can be, but the transmission rate will decrease. At the same time, the more lines used, the more complete the functions, the lower the hardware and software requirements. However, the more lines occupy more space on the board, which is not conducive to the miniaturization of products and communication layout.
发明内容Contents of the invention
为了解决上述技术问题,本申请实施例提供了一种双线通讯方法、电子设备和计算机可读存储介质,可以解决传统的多线通讯不利于产品的小型化与通讯布置的问题。In order to solve the above technical problems, the embodiment of the present application provides a two-line communication method, electronic equipment and computer-readable storage medium, which can solve the problem that traditional multi-line communication is not conducive to product miniaturization and communication arrangement.
本申请实施例第一方面提供了一种双线通讯方法,应用于第一节点,所述第一节点与其他节点连接至同一个数据总线和同一个地线;所述双线通讯方法包括:The first aspect of the embodiment of the present application provides a two-wire communication method, which is applied to a first node, and the first node is connected to the same data bus and the same ground wire as other nodes; the two-wire communication method includes:
在所述数据总线空闲时,向所述数据总线以最多三种电平的方式发送自身节点识别码后,读取所述数据总线上的电平;When the data bus is idle, read the level on the data bus after sending its own node identification code to the data bus in a manner of at most three levels;
在读取到所述数据总线上的电平与所述自身节点识别码对应的电平一致时,向所述数据总线发送目标节点识别码;其中,目标节点在读取到所述数据总线上的所述目标节点识别码时向所述数据总线发送确认码;When the level read on the data bus is consistent with the level corresponding to the own node identification code, send the target node identification code to the data bus; wherein, the target node is read on the data bus Send a confirmation code to the data bus when the target node identification code;
响应于从所述数据总线上读取到的所述目标节点输出的确认码,向所述数据总线发送目标数据。In response to the confirmation code output by the target node read from the data bus, target data is sent to the data bus.
在一些实施例中,在所述向所述数据总线以最多三种电平的方式发送自身节点识别码后,读取所述数据总线上的电平之前,还包括:In some embodiments, after sending the self-node identification code to the data bus in a manner of at most three levels, before reading the level on the data bus, the method further includes:
向所述数据总线发送时钟同步码,以使连接于所述数据总线的其他节点根据所述时钟同步码进行时钟同步。sending a clock synchronization code to the data bus, so that other nodes connected to the data bus perform clock synchronization according to the clock synchronization code.
在一些实施例中,在所述向所述数据总线发送目标数据之前,还包括:In some embodiments, before sending the target data to the data bus, further comprising:
响应于从所述数据总线上读取到的确认码,向所述数据总线发送时钟校准码以使所述目标节点根据所述时钟校准码进行校准时钟。In response to the acknowledgment code read from the data bus, a clock calibration code is sent to the data bus to enable the target node to calibrate a clock according to the clock calibration code.
在一些实施例中,在所述向所述数据总线发送目标数据之后,还包括:In some embodiments, after sending the target data to the data bus, further comprising:
若在所述目标数据发送后超过预设时长未接收到所述确认码,重新向所述数据总线发送所述目标数据直至收到所述确认码或重新发送的次数达到预设次数;If the confirmation code is not received beyond the preset time after the target data is sent, resend the target data to the data bus until the confirmation code is received or the number of times of retransmission reaches the preset number of times;
所述数据总线其中,所述重新发送最大次数为预设次数。In the data bus, the maximum number of times of resending is a preset number of times.
在一些实施例中,在所述向所述数据总线发送目标数据之后,还包括:In some embodiments, after sending the target data to the data bus, further comprising:
若在所述目标数据发送后的所述预设时长内接收到所述确认码,且所述目标数据未包括回包请求的情况下,则发送结束码或继续向所述数据总线发送下一所述目标数据;或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 packet return request, then send the end code or continue to send the next message to the data bus said target data; or
若在所述目标数据发送后的所述预设时长内接收到所述确认码,且所述目标数据包括所述回包请求的情况下,则继续监听所述数据总线状态以接收回包数据,并在接收到所述回包数据时发送所述结束码或继续向所述数据总线发送下一所述目标数据;If the confirmation code is received within the preset time period after the target data is sent, and the target data includes the packet return request, continue to monitor the state of the data bus to receive the packet return data , and sending the end code or continuing to send the next target data to the data bus when the return packet data is received;
其中,所述回包请求用于指示所述目标节点响应于所述目标数据发送所述回包数据;所述结束码的电参数不同于所述确认码的电参数。Wherein, the return request is used to instruct the target node to send the return data in response to the target data; the electrical parameter of the end code is different from the electrical parameter of the confirmation code.
在一些实施例中,在所述向所述数据总线发送目标数据之后,还包括:In some embodiments, after sending the target data to the data bus, further comprising:
在接收到校验错误码时,重新向所述数据总线发送所述目标数据。When receiving the verification error code, resend the target data to the data bus.
在一些实施例中,所述方法还包括:In some embodiments, the method also includes:
在所述数据总线被占用时,确认占用所述数据总线的节点;When the data bus is occupied, confirm the node occupying the data bus;
在占用所述数据总线的节点的优先级低于自身节点时,向所述数据总线发送中断通讯讯号以使其他连接于所述数据总线的节点停止发送数据;When the priority of the node occupying the data bus is lower than its own node, sending an interrupt communication signal to the data bus so that 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;
响应于从所述数据总线上读取到的确认码,发送所述目标数据。The target data is transmitted in response to an acknowledgment code read from the data bus.
在一些实施例中,还包括:In some embodiments, also include:
响应于从所述数据总线读取到中断通讯信号,停止向所述数据总线发送目标数据并保存所述目标数据;in response to reading an interrupt communication signal from the data bus, stop sending the target data to the data bus and save the target data;
响应于接收到的结束码,重新发送所述目标数据。The target data is resent in response to receiving the end code.
本申请实施例第二方面提供了一种电子设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上所述方法的步骤。The second aspect of the embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and operable on the processor, and the computer program is implemented when the processor executes the computer program. Steps of the method as described above.
本申请实施例第三方面提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如上所述方法的步骤。A third aspect of the embodiments of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described above are implemented.
本申请实施例提供的双线通讯方法向总线以最多三种电平、即三进制的方式发送自身节点识别码后读取总线上的电平,响应于读取到数据总线上的电平与自身节点识别码对应的电平一致,发送目标数据,在多个节点同时发起通讯请求时,总线电压体现的是电平电压最高的节点识别码,因此,可以可靠地仲裁出发送节点,如此发送节点可以向目标节点发送数据,这种通讯方式是基于双线实现,比如共地线和电平信号线,解决了多线通讯不利于产品的小型化与通讯布置的问题。The two-wire communication method provided by the embodiment of the present application sends its own node identification code to the bus with a maximum of three levels, that is, the ternary system, and then reads the level on the bus, and responds to the level read on the data bus Consistent with the level corresponding to its own node identification code, when sending target data, when multiple nodes initiate communication requests at the same time, the bus voltage reflects the node identification code with the highest level voltage, so the sending node can be reliably arbitrated, so The sending node can send data to the target node. This communication method is based on two-wire implementation, such as common ground wire and level signal wire, which solves the problem that multi-wire communication is not conducive to product miniaturization and communication layout.
附图说明Description of drawings
图1是本申请各实施例的应用环境的一个示例性示意图;FIG. 1 is an exemplary schematic diagram of an application environment of various embodiments of the present application;
图2是为本申请一些实施例提供的双线通讯方法的流程图;Fig. 2 is a flowchart of a two-line communication method provided for some embodiments of the present application;
图3是本申请各实施例的双线通讯方法的仲裁配对阶段的数据总线电压波形图;3 is a waveform diagram of the data bus voltage in the arbitration pairing stage of the two-wire communication method of each embodiment of the present application;
图4是本申请一些实施例提供的双线通讯方法的流程图;Fig. 4 is a flowchart of a two-line communication method provided by some embodiments of the present application;
图5是本申请各实施例的双线通讯方法的发起阶段的数据总线电压波形图;5 is a waveform diagram of the data bus voltage at the initiation stage of the two-wire communication method of each embodiment of the present application;
图6是本申请各实施例的双线通讯方法的数据传输阶段的数据总线电压波形图;6 is a waveform diagram of the data bus voltage in the data transmission stage of the two-wire communication method of each embodiment of the present application;
图7是本申请各实施例的双线通讯方法的结束阶段的数据总线电压波形图;7 is a waveform diagram of the data bus voltage at the end stage of the two-wire communication method of each embodiment of the present application;
图8是为本申请一些实施例提供的双线通讯方法的流程图;Fig. 8 is a flowchart of a two-line communication method provided by some embodiments of the present application;
图9是本申请各实施例的双线通讯方法的中断阶段的数据总线电压波形图;9 is a waveform diagram of the data bus voltage during the interruption phase of the two-wire communication method of various embodiments of the present application;
图10是为本申请一些实施例提供的双线通讯方法的流程图;FIG. 10 is a flowchart of a two-wire communication method provided by some embodiments of the present application;
图11是本申请实施例提供的双线通讯装置的结构示意图;FIG. 11 is a schematic structural diagram of a two-wire communication device provided by an embodiment of the present application;
图12是本申请实施例提供的电子设备的结构示意图。FIG. 12 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请所要解决的技术问题、技术方案及有益效果更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the technical problems, technical solutions and beneficial effects to be solved by the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, and are not intended to limit the present application.
需要说明的是,当元件被称为“固定于”或“设置于”另一个元件,它可以直接在另一个元件上或者间接在该另一个元件上。当一个元件被称为是“连接于”另一个元件,它可以是直接连接到另一个元件或间接连接至该另一个元件上。It should be noted that when an element is referred to as being “fixed” or “disposed on” another element, it may be directly on the other element or be indirectly on the other element. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or indirectly connected to the other element.
需要理解的是,术语“长度”、“宽度”、“上”、“下”、“前”、“后”、“左”、“右”、“竖直”、“水平”、“顶”、“底”“内”、“外”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本申请和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本申请的限制。It is to be understood that the terms "length", "width", "top", "bottom", "front", "rear", "left", "right", "vertical", "horizontal", "top" , "bottom", "inner", "outer" and other indicated orientations or positional relationships are based on the orientations or positional relationships shown in the drawings, and are only for the convenience of describing the application and simplifying the description, rather than indicating or implying the referred device Or elements must have a certain orientation, be constructed and operate in a certain orientation, and thus should not be construed as limiting the application.
此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本申请的描述中,“多个”的含义是一个或一个以上,除非另有明确具体的限定。In addition, the terms "first" and "second" are used for descriptive purposes only, and cannot be interpreted as indicating or implying relative importance or implicitly specifying the quantity of indicated technical features. Thus, a feature defined as "first" and "second" may explicitly or implicitly include one or more of these features. In the description of the present application, "plurality" means one or more than one, unless otherwise specifically defined.
目前,储能系统一般由多个电池包组成,例如包括一个主电池包和多个从电池包,储能系统在工作时一般需要同时控制储能系统中的多个电池包同时启动或者同时关闭,以延长储能系统的使用寿命。At present, the energy storage system is generally composed of multiple battery packs, such as a master battery pack and multiple slave battery packs. When the energy storage system is working, it is generally necessary to control multiple battery packs in the energy storage system to start or shut down at the same time. , to prolong the service life of the energy storage system.
在相关技术中,储能系统的充放电由电池管理芯片控制,当电池管理芯片需要控制多个电池包同时启动工作时,一般需要进行多种采样,然后通过复杂的电路设计来实现,极大的限制了储能系统的使用。In the related technology, the charging and discharging of the energy storage system is controlled by the battery management chip. 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 realize it through complex circuit design. limit the use of energy storage systems.
请参阅图1,所示为本申请各实施例的应用环境的一个示例性示意图。如图1所示,本申请实施例提供的双线通讯方法可以应用于第一节点,第一节点与其他节点(即第二节点至第n节点)连接至同一个数据总线(即DATA_VOL)和同一个地线(即GND),其中地线用于为数据总线上的电压提供对地参考。可以理解的是,双线通讯方法也能够应用于其他节点,每个节点都可以基于双线通讯方法与其他节点通讯。另外,各个节点是指可以相互通讯的用电设备,可以是储能设备、充电设备、网络设备、照明设备、自移动设备、自移动设备的充电基站等,在一个可以相互通讯的系统中,各个节点可以是同类的设备,也可以是不同类的设备,例如,可以是充电设备与多个储能设备构成一个储能系统。Please refer to FIG. 1 , which is an exemplary schematic diagram of an application environment of various embodiments of the present application. As shown in Figure 1, the two-wire communication method provided by the embodiment of the present application can be applied to the first node, and the first node and other nodes (ie, the second node to the nth node) are connected to the same data bus (ie, DATA_VOL) and The same ground (that is, GND), where the ground is used to provide a ground reference for the voltage on the data bus. It can be 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. In addition, each node refers to the electrical equipment that can communicate with each other, which can be energy storage equipment, charging equipment, network equipment, lighting equipment, mobile equipment, charging base stations for mobile equipment, etc. In a system that can communicate with each other, Each node can be the same type of device, or a different type of device, for example, a charging device and multiple energy storage devices can form an energy storage system.
在一些实施例中,各个节点也可以是指同一个设备内不同的模块。例如,储能设备内的功率转换模块、电源模块、显示模块等等,每个模块作为一个节点,与其他节点可以基于双线通讯方法进行通讯。In some embodiments, each node may also refer to different modules in the same device. For example, the power conversion module, power module, display module, etc. in the energy storage device, each module serves as a node, and can communicate with other nodes based on the two-wire communication method.
示例性地,常态时数据总线电平为0V,每个节点可控制自身在每个时刻输出0V、3.3V或5V的电压以显现数据电平,数据总线上存在多个节点输出时,按照5V→3.3V→0V的优先级顺序显现数据电平。存在任意一个节点输出为5V时,数据总线显现5V,没有输出5V的节点时,存在任意输出3.3V的节点,则数据总线显现3.3V,反之若所有节点输出0V时,数据总线为0V。Exemplarily, the data bus level is 0V in the normal state, and each node can control itself to output a voltage of 0V, 3.3V or 5V at each moment to display the data level. When there are multiple node outputs on the data bus, the 5V The priority order of →3.3V→0V shows the data level. When there is any node outputting 5V, the data bus will show 5V. If there is no node outputting 5V, if there is any node outputting 3.3V, the data bus will show 3.3V. Conversely, if all nodes output 0V, the data bus will be 0V.
通讯的基础阶段包括发起、仲裁配对、数据传输、中断和终止等阶段。因此,在数据总线上传输数据时,最多可以以三进制(0V、3.3V、5V分别代表0、1、2)的方式发送数据,当然也可以在任意一个或多个阶段以二进制的(0V、3.3V,或0V、5V,或3.3V、5V,分别代表0、1)方式传输数据。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 (0V, 3.3V, 5V respectively represent 0, 1, 2) at most, of course, it can also be sent in binary ( 0V, 3.3V, or 0V, 5V, or 3.3V, 5V, respectively represent 0, 1) to transmit data.
请参阅图2,所示为本申请一实施例提供的双线通讯方法的流程图,本申请一实施例提供的双线通讯方法包括步骤S110-S130。Please refer to FIG. 2 , which is a flowchart of a two-line communication method provided by an embodiment of the present application. The two-line communication method provided by an embodiment of the present application includes steps S110-S130.
步骤S110,在所述数据总线空闲时,向所述数据总线以最多三种电平的方式发送自身节点识别码后,读取所述数据总线上的电平。Step S110, when the data bus is idle, after sending the self-node identification code to the data bus in a manner of at most three levels, and then reading the levels on the data bus.
其中,仲裁配对阶段所属的在步骤S110是基于数据总线空闲时执行的,其中数据总线空闲指的是连续预设个时钟周期数据总线为0V电平,或某个节点发送了结束码,此时表示数据总线在空闲状态。该连续预设个时钟周期可以是连续5个、10个或15个时钟周期,在此不做限定。Wherein, the step S110 of the arbitration pairing phase is executed based on the fact that the data bus is idle, wherein the idle data bus refers to the fact that the data bus is at 0V level for a preset number of clock cycles, or a certain node sends an end code, at this time Indicates that the data bus is in an idle state. The continuous preset number of clock cycles may be 5, 10 or 15 consecutive clock cycles, which is not limited here.
其中,三种电平包括电压依次递增的第一电平、第二电平和第三电平。示例性的,以双线通讯方法应用于第一节点为例,在仲裁配对阶段,比如第一节点的自身节点识别码为012,在第一节点连续三个时钟周期则向数据总线分别输出0V、3.3V、5V电平,以发送自身节点识别码;又比如,比如第一节点的自身节点识别码为011,则第一节点在连续三个时钟周期则向数据总线分别输出0V、3.3V、3.3V电平,以发送自身节点识别码。第一节点发送自身节点识别码后读取数据总线上的电平,比如通过一个端口发送,通过另一个端口实时检测。Wherein, the three levels include a first level, a second level and a third level whose voltages increase sequentially. Exemplarily, taking the two-wire communication method applied to the first node as an example, in the arbitration pairing stage, for example, the self-node identification code of the first node is 012, and the first node outputs 0V to the data bus for three consecutive clock cycles , 3.3V, 5V level to send its own node identification code; for example, if the self-node identification code of the first node is 011, then the first node will output 0V, 3.3V to the data bus respectively in three consecutive clock cycles , 3.3V level to send its own node identification code. The first node reads the level on the data bus after sending its own node identification code, for example, sending through one port and detecting in real time through another port.
因此,以三种电平的方式发送自身节点识别码。其中每个节点具有通过将通过5V、3.3V、0V分别代表三进制的2、1、0发送自身节点识别码的能力,而实际发送的电平是一种电平、两种电平还是三种电平是由自身识别码决定的。Therefore, the own node identification code is transmitted in three levels. Each node has the ability to send its own node identification code through 5V, 3.3V, and 0V representing ternary 2, 1, and 0, respectively, and the actual sent level is one level, two levels or The three levels are determined by its own identification code.
步骤S120,在读取到所述数据总线上的电平与所述自身节点识别码对应的电平一致时,向所述数据总线发送目标节点识别码。Step S120, when the read level on the data bus is consistent with the level corresponding to the own node identification code, send the target node identification code to the data bus.
可以理解的,目标节点在读取到数据总线上的目标节点识别码时向数据总线发送确认码,以通知第一节点其发送的目标节点识别码已被接收且确认,通信配对成功。请参阅图2和图3,示例性的,在同一连续的三个时钟周期时刻,第一节点作为第一发送节点发送自身节点识别码,即图3中所示ID(Identity document,身份识别)号120,第二节点作为第二发送节点发送自身节点识别码111(ID号111),而在第二个时钟周期两个节点均检测到数据总线的电压为5V,此时第二节点认为与自身节点识别码不一致而仲裁失败,则在第三个时钟周期停止输出第三位识别码1,改为输出0,表示第二节点仲裁不成功,下一时刻不具有在数据总线上传输数据的权限,因此,三个连续的时钟周近期内数据总线上显现的数据电平分别为3.3V、5V、0V,与第一节点的自身识别码120一致,表示第一节点仲裁成功。仲裁成功的第一节点在下一时刻具有在数据总线上传输数据的权限。仲裁成功的第一节点在仲裁成功后,发送待通讯的目标节点识别码010(ID号010)待目标节点响应确认以待配对。It can be understood that when the target node reads the target node identification code on the data bus, it sends a confirmation code to the data bus to notify the first node that the target node identification code it sent has been received and confirmed, and the communication pairing is successful. Please refer to FIG. 2 and FIG. 3. Exemplarily, at the same continuous three clock cycle moments, the first node sends its own node identification code as the first sending node, that is, the ID (Identity document, identification) shown in FIG. 3 No. 120, the second node sends its own node identification code 111 (ID number 111) as the second sending node, and both nodes detect that the voltage of the data bus is 5V in the second clock cycle, and at this moment the second node thinks that it is the same as If the self-node identification code is inconsistent and the arbitration fails, the output of the third identification code 1 will be stopped in the third clock cycle, and the output will be changed to 0, indicating that the arbitration of the second node is unsuccessful, and there is no possibility of transmitting data on the data bus at the next moment. Therefore, the data levels displayed on the data bus in three consecutive clock cycles are 3.3V, 5V, and 0V respectively, which are consistent with the self-identification code 120 of the first node, indicating that the arbitration of the first node is successful. The first node that succeeds in the arbitration has the right to transmit data on the data bus at the next moment. After the arbitration is successful, the first node that succeeds in the arbitration sends the identification code 010 (ID number 010) of the target node to be communicated and waits for the target node to respond and confirm for pairing.
步骤S130,响应于从所述数据总线上读取到的所述目标节点输出的确认码,向所述数据总线发送目标数据。Step S130, sending target data to the data bus in response to the confirmation code output by the target node read from the data bus.
请参阅图2和图3,示例性的,第一节点在仲裁成功后,在数据总线上发送待通讯的目标节点识别码,目标节点响应于收到的自身节点识别码,将在数据总线上发送一个确认码(ACK),比如是一个3.3V的电平信号。第一节点从数据总线上读取到该确认码,代表两个节点配对成功,如此可以进行后续的数据通讯,从而发送目标数据。可以理解的是,一个3.3V电平的确认码仅作示例,确认码的电平参数设置可以根据需求任意设置,比如两个3.3V电平,在此不做过多限定。Please refer to Fig. 2 and Fig. 3, exemplary, after the arbitration is successful, the first node sends the target node identification code to be communicated on the data bus, and the target node responds to the own node identification code received, and will Send an acknowledgment code (ACK), such as a 3.3V level signal. When the first node reads the confirmation code from the data bus, it means that the two nodes are paired successfully, so that subsequent data communication can be performed, thereby sending target data. It can be understood that a confirmation code with a 3.3V level is only used as an example, and the level parameter setting of the confirmation code can be set arbitrarily according to requirements, such as two 3.3V levels, which are not limited here.
上述的这种双线通讯方式,通讯线数少,且具有通过三进制传输数据的能力具有良好的抗干扰性,有利于通讯稳定,使得可传输距离更长,同时能保证高效的传输速率。The above-mentioned two-line communication method has a small number of communication lines, and has the ability to transmit data through the ternary system with good anti-interference performance, which is conducive to communication stability, making the transmission distance longer, and at the same time ensuring an efficient transmission rate. .
请继续参阅图2和3,在一些实施例中,为保证数据发送顺利,在仲裁配配对阶段结束、发送目标数据之前,使将要传输数据的两个节点进行时钟校准或同步。具体地,在步骤S130中的向所述数据总线发送目标数据之前,双线通讯方法还包括:响应于从所述数据总线上读取到的确认码,向所述数据总线发送时钟校准码以使所述目标节点根据所述时钟校准码进行校准时钟。Please continue to refer to FIGS. 2 and 3 . In some embodiments, in order to ensure smooth data transmission, the clocks of the two nodes to be transmitted are calibrated or synchronized before the arbitration pairing phase ends and the target data is transmitted. Specifically, before sending the target data to the data bus in step S130, the two-wire communication method further includes: in response to the confirmation code read from the data bus, sending a clock calibration code to the data bus to enabling the target node to calibrate a clock according to the clock calibration code.
示例性的,第一节点从数据总线上读取到目标节点发送的确认码后,则在数据总线上输出一个时钟校准码,例如是一个5V电平,目标节点在数据总线上读取到这个时钟校准码后,将重新校准一次时钟,使得自身的时钟与第一节点的时钟同步,并进入数据传输与校验阶段。如此,保证两个节点之间数据能够准确、顺利传输,不易发生传输延迟、数据丢失。可以理解的是,一个5V电平的时钟校准码仅作示例,时钟校准码的电平参数设置可以根据需求任意设置,比如两个5V电平,在此不做过多限定。Exemplarily, after the first node reads the confirmation 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, and the target node reads this on the data bus. After the clock calibration code, the clock will be recalibrated once, so that its own clock is synchronized with the clock of the first node, and enters the data transmission and verification stage. In this way, it is ensured that the data between the two nodes can be transmitted accurately and smoothly, and transmission delay and data loss are not easy to occur. It can be understood that a 5V level clock calibration code is only an example, and the level parameter setting of the clock calibration code can be set arbitrarily according to requirements, such as two 5V levels, which are not limited here.
请参阅图4,所示为本申请一实施例提供的双线通讯方法的流程图。结合图4和图5,在一些实施例中,为保证各个节点通讯顺利,在发起通讯阶段中,先对各个节点进行时钟同步。具体地,双线通讯方法在步骤S110之前,还包括步骤S105:向所述数据总线发送时钟同步码,以使连接于所述数据总线的其他节点根据所述时钟同步码进行时钟同步。Please refer to FIG. 4 , which is a flowchart of a two-line communication method provided by an embodiment of the present application. Referring to FIG. 4 and FIG. 5 , in some embodiments, in order to ensure the smooth communication of each node, clock synchronization is performed on each node in the phase of initiating communication. 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 perform clock synchronization according to the clock synchronization code.
示例性的,当数据总线处于空闲阶段时,需要发起通讯的节点(比如第一节点)将主动向数据总线发送时钟同步码,例如是一个5V→3.3V→5V交替的电平,如图5所示,拉高整根数据总线的电压,所有节点从数据总线上读取到的第一个5V上升沿为开始时钟同步码的始点,并根据这三次跳变沿,触发自身的时钟与发起通讯的节点时钟同步,从而保证此后的通讯过程数据传输顺利,不易发生传输延迟、数据丢失。随后,进入仲裁阶段。可以理解的是,时钟同步码也可以认为是通讯的起始码,对于时钟同步码的电平参数设置可以根据需求任意设置,在此不做限定。Exemplarily, when the data bus is in an idle phase, the node that needs to initiate communication (such as the first node) will actively send a clock synchronization code to the data bus, for example, an alternate level of 5V→3.3V→5V, as shown in Figure 5 As shown, the voltage of the entire data bus is pulled up, and the first 5V rising edge read by all nodes from the data bus is the starting point of the clock synchronization code, and according to these three jump edges, trigger their own clock and initiate The clocks of the communication nodes are synchronized, so as to ensure the smooth data transmission in the subsequent communication process, and the transmission delay and data loss are not easy to occur. Then, enter the arbitration stage. It can be understood that the clock synchronization code can also be regarded as the start code of communication, and the level parameter setting of the clock synchronization code can be set arbitrarily according to requirements, and there is no limitation here.
请继续参阅图6,在一些实施例中,双线通讯方法进入数据传输阶段时,将要发送数据的发送节点(比如第一节点)在数据总线上以0V和3.3V作为0和1信号,进行二进制数据发送,每次发送8个数据字节+校验码+请求回包码,其中,回包请求用于指示目标节点响应于目标数据发送回包数据,请求回包码是1代表需要目标节点回包,即目标数据包括回包请求,例如图6;0代表不需要目标节点回包,即目标数据不包括回包请求。发送完毕后,下一个时钟仅输出0V电平,并持续读取(即监听)数据总线上的电平,以待响应;例如,待目标节点回复确认码(ACK,例如3.3V),以及回包数据。在另一些实施例中,将要发送数据的节点可以在数据总线上以3.3V和5V,或0V和5V作为0和1信号,进行二进制数据发送;又或者,可以在数据总线上以0V、3.3V、5V作为0、1、2信号,进行三进制数据发送。Please continue to refer to FIG. 6. In some embodiments, when the two-wire communication method enters the data transmission stage, the sending node (such as the first node) to send data uses 0V and 3.3V as 0 and 1 signals on the data bus to perform Binary data transmission, 8 data bytes + check code + request return code are sent each time, where the return request is used to instruct the target node to send return packet data in response to the target data, and the request return code is 1 to represent the target The node returns the packet, that is, the target data includes the packet return request, as shown in Figure 6; 0 means that the target node does not need to return the packet, that is, the target data does not include the packet return request. After sending, the next clock only outputs 0V level, and continues to read (that is, monitor) the level on the data bus for a response; for example, wait for the target node to reply with an acknowledgment code (ACK, such as 3.3V) package data. In other embodiments, the node to send data can use 3.3V and 5V, or 0V and 5V as 0 and 1 signals on the data bus to send binary data; or, it can use 0V, 3.3 V and 5V are used as 0, 1 and 2 signals to send ternary data.
请参阅图6,在一些实施例中,在步骤S130中向总线发送目标数据之后,还包括:若在所述目标数据发送后超过预设时长未接收到所述确认码,重新向所述数据总线发送所述目标数据直至收到所述确认码或重新发送的次数达到预设次数,其中,所述重新发送最大次数为预设次数。Please refer to FIG. 6 , in some embodiments, after sending the target data to the bus in step S130, it also includes: if the confirmation code is not received after the target data is sent for a preset period of time, sending the data to the bus again The bus sends the target data until the confirmation code is received or the number of times of resending reaches a preset number of times, wherein the maximum number of times of resending is a preset number of times.
示例性的,如果目标节点收到了目标数据,则目标节点先向数据总线输出3.3V电平的确认码。此外,如果目标数据中包含的请求回包码为1,则目标节点还需要向数据总线发送回包数据,发送节点(比如第一节点)监听接收回包数据;如果目标数据中包含的请求回包码为0,则目标节点仅需要向数据总线输出3.3V电平的确认码。Exemplarily, if the target node receives the target data, the target node first outputs a 3.3V level confirmation code to the data bus. In addition, if the request return code contained in the target data is 1, the target node also needs to send return packet data to the data bus, and the sending node (such as the first node) monitors and receives the return packet data; if the request return code contained in the target data If the packet code is 0, the target node only needs to output a 3.3V confirmation code to the data bus.
发送节点在预设时长内从数据总线上读取到由目标节点发送的确认码,则认为目标数据发送成功,反之若超过预设时长未接收到确认码,即数据总线的电压超过预设时长都为0V电平,则发送节点重新向数据总线发送目标数据直至收到确认码,若再次超过预设时长未接收到确认码,则再次重新发送直至达到预设次数,例如2次或3次。可以理解的是,其中,重新发送的最大次数可以在对应寄存器中进行修改。If the sending node reads the confirmation code sent by the target node from the data bus within the preset time period, it considers that the target data is sent successfully. Otherwise, if the confirmation code is not received beyond the preset time period, that is, the voltage of the data bus exceeds the preset time period If they are all at 0V level, the sending node resends the target data to the data bus until the confirmation code is received. If the confirmation code is not received again after the preset time, it will resend again until the preset number of times is reached, such as 2 or 3 times . It can be understood that, wherein, the maximum number of times of resending can be modified in the corresponding register.
上述实施例中,发送节点发送目标数据后,需要目标节点回复确认码确认,使得数据传输的成功与否具有可知性;同时,设置了重发机制,能够提高数据传输的成功率。In the above embodiments, after the sending node sends the target data, the target node needs to reply with a confirmation code for confirmation, so that the success of the data transmission can be known; at the same time, a retransmission mechanism is set to improve the success rate of the data transmission.
请继续参阅图6,在一些实施例中,双线通讯方法在步骤S130中向总线发送目标数据之后,还包括:若在所述目标数据发送后的所述预设时长内接收到所述确认码,且所述目标数据未包括回包请求的情况下,则发送结束码或继续向所述数据总线发送下一所述目标数据。Please continue to refer to FIG. 6 , in some embodiments, after sending the target data to the bus in step S130, the two-wire communication method further includes: if the confirmation is received within the preset time period after the target data is sent code, and the target data does not include a packet return request, then send an end code or continue to send the next target data to the data bus.
示例性的,如果发送节点发送的目标数据中包含的请求回包码为0,则目标节点仅需要向数据总线输出3.3V电平的确认码。那么,发送节点在预设时长从数据总线上的由目标节点发送的确认码,则认为目标数据发送成功,继续下一步。如果数据已经传输结束,则发送结束码,等待下一次数据传输开始。其中,参见图7,结束码例如可以是5V→0V→3.3V→0V交替的电平,由此可见,结束码的电参数不同于确认码的电参数,以便于节点对每个数据参数的区分与响应。如果数据未传输结束,则发送节点继续向数据总线发送下一目标数据,一般地该下一目标数据可以与前一目标数据不同,其可以数据包,也可以是另一个目标节点的目标节点识别码,以寻求与另一个目标节点进行数据通讯。各个节点若从数据总线上读取到接收码,时代表通讯结束,认为数据总线处于空闲状态,所有其他节点可以重新发起通讯。Exemplarily, if the request return packet code contained in the target data sent by the sending node is 0, the target node only needs to output a 3.3V level confirmation code to the data bus. Then, if the sending node receives the acknowledgment code sent by the target node on the data bus within a preset period of time, it is considered that the target data is sent successfully, and the next step is continued. If the data transmission has ended, send the end code and wait for the next data transmission to start. Wherein, referring to FIG. 7, the end code can be, for example, an alternate level of 5V→0V→3.3V→0V. It can be seen that the electrical parameter of the end code is different from that of the confirmation code, so that the node can control each data parameter Differentiate and respond. If the data transmission is not over, the sending node continues to send the next target data to the data bus. Generally, the next target data can be different from the previous target data. It can be a data packet or the target node identification of another target node. code to seek data communication with another target node. If each node reads the receiving code from the data bus, it means that the communication is over, and the data bus is considered to be in an idle state, and all other nodes can re-initiate communication.
请参阅图6,在一些实施例中,双线通讯方法在步骤S130中向总线发送目标数据之后,若在所述目标数据发送后的所述预设时长内接收到所述确认码,且所述目标数据包括所述回包请求的情况下,则继续监听所述数据总线状态以接收回包数据,并在接收到所述回包数据时发送所述结束码或继续向所述数据总线发送下一所述目标数据;其中,所述回包请求用于指示所述目标节点响应于所述目标数据发送所述回包数据。Please refer to FIG. 6. In some embodiments, after the two-wire communication method sends the target data to the bus in step S130, if the confirmation code is received within the preset time period after the target data is sent, and the If the target data includes the return packet request, continue to monitor the data bus state to receive the return packet data, and send the end code when receiving the return packet data or continue to send to the data bus Next the target data; wherein, the packet return request is used to instruct the target node to send the packet return data in response to the target data.
示例性的,如果发送节点发送的目标数据中包含的请求回包码为1,则认为目标数据包括回包请求,目标节点在预设时长内需要向数据总线输出3.3V电平的确认码,之后还需要向数据总线发送回包数据,发送节点继续监听接收回包数据。发送节点从数据总线接收到回包数据之后,如果数据已经传输结束,则发送结束码,等待下一次数据传输开始;如果数据未传输结束,则发送节点继续向数据总线发送下一目标数据。一般地,该下一目标数据可以与前一目标数据不同,其可以是数据包,也可以是另一个目标节点的目标节点识别码,以寻求与另一个目标节点进行数据通讯。Exemplarily, if the request return code contained in the target data sent by the sending node is 1, it is considered that the target data includes a return request, and the target node needs to output a confirmation code of 3.3V level to the data bus within a preset duration, Afterwards, it is necessary to send the return packet data to the data bus, and the sending node continues to monitor and receive the return packet data. After the sending node receives the return packet data from the data bus, if the data transmission has ended, it will send an end code and wait for the next data transmission to start; if the data transmission is not completed, the sending node will continue to send the next target data to the data bus. Generally, the next target data can be different from the previous target data, and it can be a data packet, or a target node identification code of another target node, so as to seek data communication with another target node.
在一些实施例中,在步骤S130中向所述数据总线发送目标数据之后,双线通讯方法还包括:在接收到校验错误码时,重新向所述数据总线发送所述目标数据。In some embodiments, after sending the target data to the data bus in step S130, the two-wire communication method further includes: re-sending the target data to the data bus when a check error code is received.
示例性的,校验错误码的电平参数可以不同于时钟同步码、确认码、结束码等,比如是1个或两个5V电平,以便于发送节点识别。发送节点接收到校验错误码代表数据传输错误,因此,为保证数据传输成功,应重新向数据总线发送目标数据给目标节点,使得数据传输成功。Exemplarily, the level parameter of the check error code may be different from the clock synchronization code, confirmation code, end code, etc., for example, one or two 5V levels, so as to facilitate the identification of the sending node. When the sending node receives the check error code, it means that the data transmission is wrong. Therefore, in order to ensure the success of the data transmission, the target data should be sent to the data bus to the target node again, so that the data transmission is successful.
可选地,在接收到校验错误码时,重新向数据总线发送目标数据,直至在目标数据发送后预设时长内接收到确认码或重新发送的次数达到预设次数。即若再次超过预设时长未接收到确认码,则再次重新发送直至达到预设次数,例如2次或3次。可以理解的是,其中,重新发送的最大次数可以在对应寄存器中进行修改。Optionally, when the verification error code is received, the target data is resent to the data bus until the confirmation code is received within a preset time period after the target data is sent or the number of resends reaches a preset number of times. That is, if the confirmation code is not received again beyond the preset time period, it will be resent until the preset number of times is reached, such as 2 or 3 times. It can be understood that, wherein, the maximum number of times of resending can be modified in the corresponding register.
请参阅图8,所示为本申请一实施例提供的双线通讯方法的流程图。结合图8和图9,在一些情况下,需要进行实施紧急通讯,则需要将当前的通讯进行中断而进行紧急通讯,因此在一些实施例中,双线通讯方法还包括:Please refer to FIG. 8 , which is a flowchart of a two-line communication method provided by an embodiment of the present application. Combining Figure 8 and Figure 9, in some cases, it is necessary to implement emergency communication, and the current communication needs to be interrupted to perform emergency communication, so in some embodiments, the two-line communication method also includes:
步骤S210,在所述数据总线被占用时,确认占用所述数据总线的节点。Step S210, when the data bus is occupied, confirm the node occupying the data bus.
例如第一节点与第二节点正在相互通讯时,第n节点检测数据总线的电平信号,此时数据总线没有被检测到有数据空闲状态(即连续预设个时钟周期数据总线为0V电平或结束码),此时代表数据总线被占用,第n节点根据检测到的数据确认占用数据总线的节点第一节点和第二节点。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, the data bus is not detected to have a data idle state (that is, the data bus is at 0V level for consecutive preset clock cycles. or end code), which means that the data bus is occupied at this time, and the nth node confirms the first node and the second node occupying the data bus according to the detected data.
步骤S220,在占用所述数据总线的节点的优先级低于自身节点时,向所述数据总线发送中断通讯讯号以使其他连接于所述数据总线的节点停止发送数据。Step S220, when the priority of the node occupying the data bus is lower than that of its own node, sending an interrupt communication signal to the data bus to stop other nodes connected to the data bus from sending data.
节点的优先级是在实施步骤210之前设置的,比如可以在整个能够相互通讯的系统搭建时设置。第n节点将与占用数据总线的节点进行优先级比对,如果第n节点的优先级低于占用数据总线的节点则不向数据总线发送中断通讯讯号,反之则向数据总线发送中断通讯讯号。此时,连接于数据总线的所有其他节点(包括占用数据总线的节点)将接收到该中断通讯讯号,并根据该中断通讯讯号停止发送数据,从而使得总线暂时进入数据空闲状态。其中,中断通讯讯号可以是连续多个(例如4个,5个,10个,)时钟周期的5V电平,以区别于二进制数据传输时连续多个代表1的3.3V电平,使得所有其他节点能够顺利根据该中断通讯讯号停止发送数据。可以理解的是,中断通讯讯号的电平参数可以根据需求设置,在此不作限定。The priority of the nodes is set before step 210 is implemented, for example, it can be set when the entire system capable of communicating with each other is set up. The priority of the nth node will be compared with the node occupying the data bus. If the priority of the nth node is lower than that of the node occupying the data bus, no interrupt communication signal will be sent to the data bus. Otherwise, an interrupt communication signal will be sent to the data bus. At this time, all other nodes connected to the data bus (including nodes occupying the data bus) will receive the interrupt communication signal, and stop sending data according to the interrupt communication signal, so that the bus temporarily enters the data idle state. Among them, the interrupt communication signal can be a 5V level with multiple (for example, 4, 5, 10) clock cycles in a row, to distinguish it from a 3.3V level that represents 1 in a row during binary data transmission, so that all other The node can successfully stop sending data according to the interruption communication signal. It can be understood that the level parameter of the interruption communication signal can be set according to requirements, and is not limited here.
步骤S230,在发送中断通讯信号之后,向所述数据总线发送所述目标节点识别码。Step S230, after sending the interrupt communication signal, sending the target node identification code to the data bus.
第n节点发送中断通讯信号之后已占用数据总线进行数据传输的权限,从另一个角度将也可以认为是仲裁成功,从而向数据总线发送目标节点识别码寻求与目标节点(例如图9的第m节点)进行配对。After the nth node sends the interrupt communication signal, it has occupied the authority of the data bus to carry out data transmission. From another perspective, it can also be considered as a successful arbitration, so as to send the target node identification code to the data bus to seek and target node (for example, the mth node in FIG. 9 node) for pairing.
步骤S240,响应于从所述数据总线上读取到的确认码,发送所述目标数据。Step S240, sending the target data in response to the confirmation code read from the data bus.
例性的,第n节点发送中断通讯信号后,在数据总线上发送待通讯的目标节点识别码,目标节点(例如图9的第m节点)响应收到的自身识别码将在数据总线上发送一个确认码,第n节点从数据总线上读取到该确认码,代表两个节点配对成功,如此可以进行后续的数据通讯,从而发送目标数据,并在数据通讯结束之后向数据总线发送结束码。可以理解的是。步骤S240与步骤S130类同,其他适用于步骤S130的后续步骤或详细步骤,同样也适用于步骤S240,在此不再赘述。Exemplarily, after the nth node sends the interrupt communication signal, it sends the identification code of the target node to be communicated on the data bus, and the target node (such as the mth node in Figure 9) responds to the received self identification code and sends it on the data bus A confirmation code, the nth node reads the confirmation code from the data bus, which means that the two nodes are paired successfully, so that subsequent data communication can be carried out, so as to send the target data, and send the end code to the data bus after the data communication ends . Understandably so. Step S240 is similar to step S130, and other subsequent steps or detailed steps applicable to step S130 are also applicable to step S240, which will not be repeated here.
可选地,在一个节点触发了中断通讯后,其他节点在本次传输完成前将不再能触发中断通讯,从而保证本次中断通讯的节点能够实现完整的数据传输。Optionally, after a node triggers the interruption of communication, other nodes will no longer be able to trigger the interruption of communication before the current transmission is completed, so as to ensure that the node of this interruption of communication can realize complete data transmission.
在上述实施例中,占用数据总线的节点(比如第一节点和第二节点)被中断数据传输后,在造成该中断的节点数据传输结束后,占用数据总线的节点还可以继续数据传输,从而保证上一数据传输的完整性。请参阅图,10所示为本申请一实施例提供的双线通讯方法的流程图。结合图9和图10,在一些实施例中,双线通讯方法还包括:In the above embodiment, after the data transmission of the nodes (such as the first node and the second node) occupying the data bus is interrupted, after the data transmission of the node causing the interruption ends, the nodes occupying the data bus can continue the data transmission, thereby Guarantees the integrity of the previous data transfer. Please refer to FIG. 10 , which is a flowchart of a two-line communication method provided by an embodiment of the present application. With reference to Figure 9 and Figure 10, in some embodiments, the two-wire communication method further includes:
步骤S310,响应于从所述数据总线读取到中断通讯信号,停止向所述数据总线发送目标数据并保存所述目标数据。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.
示例性的,从数据总线读取到中断通讯信号之前,比如第一节点作为发送节点,第二节点作为目标节点,第一节点从数据总线读取到中断通讯信号则停止向数据总线发送当前目标数据,并将完整当前目标数据保存。Exemplarily, before the interrupt communication signal is read from the data bus, for example, the first node acts as the sending node and the second node acts as the target node, and the first node stops sending the current target to the data bus when the first node reads the interrupt communication signal from the data bus data, and save the complete current target data.
步骤S320,响应于接收到的结束码,重新发送所述目标数据。Step S320, resending the target data in response to the received end code.
中断通讯的紧急信息发送完毕后,第一节点在接收到接收码后,再重发上次被打断的当前目标数据,第二节点在接收到接收码后监听数据总线,待接收上次被打断的当前目标数据。After sending the emergency information that interrupts the communication, the first node resends the current target data that was interrupted last time after receiving the receiving code, and the second node monitors the data bus after receiving the receiving code, and waits to receive the last received data Interrupted current target data.
在一些实施例中,双线通讯方法还包括广播功能,发送节点在仲裁成功或者发出中断通讯信号后,发送目标节点识别码为广播码,比如目标节点识别码全部为0,则能够向其他所有节点发送目标数据,其他所有节点将接收目标数据。In some embodiments, the two-line communication method also includes a broadcast function. After the sending node succeeds in the arbitration or sends out a communication interruption signal, the sending node identification code is a broadcast code. For example, if the target node identification codes are all 0, then all Nodes send target data and all other nodes will receive target data.
可选地,广播的目标数据的请求回包码仅能为0,不请求回包,以避免数据传输出错。Optionally, the request reply packet code of the broadcast target data can only be 0, and no reply packet is requested, so as to avoid errors in data transmission.
可选地,与上述其中一个实施例类似,在接收到校验错误码时,重新向数据总线发送目标数据。直至在目标数据发送后预设时长内接收到确认码或重新发送的次数达到预设次数。即若再次超过预设时长未接收到确认码,则再次重新发送直至达到预设次数,例如2次或3次。可以理解的是,其中,重新发送的最大次数可以在对应寄存器中进行修改。Optionally, similar to one of the foregoing embodiments, when the verification error code is received, the target data is resent to the data bus. Until the confirmation code is received within the preset time period after the target data is sent or the number of times of resending reaches the preset number of times. That is, if the confirmation code is not received again beyond the preset time period, it will be resent until the preset number of times is reached, such as 2 or 3 times. It can be understood that, wherein, the maximum number of times of resending can be modified in the corresponding register.
对应于上文实施例所述的双线通讯方法,图11示出了本申请实施例提供的双线通讯装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。Corresponding to the two-wire communication method described in the above embodiments, FIG. 11 shows a structural block diagram of the two-wire communication device provided by the embodiment of the present application. For the convenience of description, only the parts related to the embodiment of the present application are shown.
请参照图11,该双线通讯装置,应用于第一节点,第一节点与其他节点连接至同一个数据总线和同一个地线;双线通讯装置包括第一收发模块801、第二收发模块802和第三收发模块803。Please refer to Figure 11, the two-wire communication device is applied to the first node, and the first node and other nodes are connected to the same data bus and the same ground wire; the two-wire communication device includes a
第一收发模块801,在所述数据总线空闲时,向所述数据总线以最多三种电平的方式发送自身节点识别码后,读取所述数据总线上的电平。The
第二收发模块802,在读取到所述数据总线上的电平与所述自身节点识别码对应的电平一致时,发送目标节点识别码。The
第三收发模块803,响应于从所述数据总线上读取到的所述目标节点输出的确认码,向所述数据总线发送目标数据。The
在一种可能的实现方式中,第一收发模块801还用于向所述数据总线发送时钟同步码,以使连接于所述数据总线的其他节点根据所述时钟同步码进行时钟同步。In a possible implementation manner, the
在一种可能的实现方式中,第三收发模块803还用于响应于从所述数据总线上读取到的确认码,向所述数据总线发送时钟校准码以使所述目标节点根据所述时钟校准码进行校准时钟。In a possible implementation manner, the
在一种可能的实现方式中,第三收发模块803还用于若在所述目标数据发送后超过预设时长未接收到所述确认码,重新向所述数据总线发送所述目标数据直至收到所述确认码或重新发送的次数达到预设次数;其中,所述重新发送最大次数为预设次数。In a possible implementation manner, the
在一种可能的实现方式中,第三收发模块803还用于若在所述目标数据发送后的所述预设时长内接收到所述确认码,且所述目标数据未包括回包请求的情况下,则发送结束码或继续向所述数据总线发送下一所述目标数据;或In a possible implementation, the
若在所述目标数据发送后的所述预设时长内接收到所述确认码,且所述目标数据包括所述回包请求的情况下,则继续监听所述数据总线状态以接收回包数据,并在接收到所述回包数据时发送所述结束码或继续向所述数据总线发送下一所述目标数据;If the confirmation code is received within the preset time period after the target data is sent, and the target data includes the packet return request, continue to monitor the state of the data bus to receive the packet return data , and sending the end code or continuing to send the next target data to the data bus when the return packet data is received;
其中,所述回包请求用于指示所述目标节点响应于所述目标数据发送所述回包数据;所述结束码的电参数不同于所述确认码的电参数。Wherein, the return request is used to instruct the target node to send the return data in response to the target data; the electrical parameter of the end code is different from the electrical parameter of the confirmation code.
在一种可能的实现方式中,第三收发模块803还用于在接收到校验错误码时,重新向所述数据总线发送所述目标数据。In a possible implementation manner, the
在一种可能的实现方式中,双线通讯装置还包括检测模块和中断模块。In a possible implementation manner, the two-wire communication device further includes a detection module and an interruption module.
检测模块,在所述数据总线被占用时,确认占用所述数据总线的节点;A detection module, when the data bus is occupied, confirm the node occupying the data bus;
中断模块,在占用所述数据总线的节点的优先级低于自身节点时,向所述数据总线发送中断通讯讯号以使其他连接于所述数据总线的节点停止发送数据;The interrupt module, when the priority of the node occupying the data bus is lower than its own node, sends an interrupt communication signal to the data bus so that other nodes connected to the data bus stop sending data;
所述第二收发模块802还用于在发送中断通讯信号之后,向所述数据总线发送所述目标节点识别码;The
所述第三收发模块803还用于响应于从所述数据总线上读取到的确认码,发送所述目标数据。The
在一种可能的实现方式中,双线通讯装置还包括保存模块,保存模块用于响应于从所述数据总线读取到中断通讯信号,停止向所述数据总线发送目标数据并保存所述目标数据;In a possible implementation manner, the two-wire communication device further includes a saving module, configured to stop sending target data to the data bus and save the target data in response to reading an interruption signal from the data bus. data;
所述第三收发模块803还用于响应于接收到的结束码,重新发送所述目标数据。The
图12为本申请一实施例提供的电子设备90的结构示意图。如图12所示,该实施例的电子设备90包括:至少一个处理器901(图12中仅示出一个)、存储器903以及存储在所述存储器903中并可在所述至少一个处理器901上运行的计算机程序902,所述处理器901执行所述计算机程序902时实现上述实施例中的步骤。FIG. 12 is a schematic structural diagram of an
所述电子设备90可包括,但不仅限于,处理器901、存储器903。本领域技术人员可以理解,图12仅仅是电子设备90的举例,并不构成对电子设备90的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如还可以包括输入输出设备、网络接入设备等。The
所称处理器901可以是中央处理单元(Central Processing Unit,CPU),该处理器901还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-called
所述存储器903在一些实施例中可以是所述电子设备90的内部存储单元,例如电子设备90的硬盘或内存。所述存储器903在另一些实施例中也可以是所述电子设备90的外部存储设备,例如所述电子设备90上配备的插接式硬盘,智能存储卡(Smart Media Car,SMC)、安全数字卡(Secure Digital,SD)、闪存卡(Flash Card)等。进一步地,所述存储器903还可以既包括所述电子设备90的内部存储单元,又包括外部存储设备。所述存储器903用于存储操作系统、应用程序、引导装载程序(Boot Loader)、数据以及其他程序等,例如所述计算机程序的程序代码等。所述存储器903还可以用于暂时地存储已经输出或者将要输出的数据。The
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程时,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一个计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读存储介质至少可以包括:能够将计算机程序代码携带到充电装置/电子设备的任何实体或装置、记录介质、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质,例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读存储介质不可以是电载波信号和电信信号。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, when the present application implements all or part of the processes in the methods of the above-mentioned embodiments, it can be completed by instructing related hardware through computer programs, and the computer programs can be stored in a computer-readable storage medium. When the program is executed by the processor, the steps in the above-mentioned various method embodiments can be realized. Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form. The computer-readable storage medium may at least include: any entity or device capable of carrying computer program codes to the charging device/electronic device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access Memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution media, such as U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, computer readable storage media may not be electrical carrier signals and telecommunication signals based on legislation and patent practice.
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述各个方法实施例中的步骤。The embodiment of the present application also provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the foregoing method embodiments are implemented.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the descriptions of each embodiment have their own emphases, and for parts that are not detailed or recorded in a certain embodiment, refer to the relevant descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those skilled in the art can appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present application.
在本申请所提供的实施例中,应该理解到,所揭露的装置/网络设备和方法,可以通过其它的方式实现。以上所描述的装置/网络设备实施例仅仅是示意性的,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元、组件可以结合或者可以集成到另一个系统中,一些特征可以忽略不执行。另一点,所显示或讨论的相互之间的间接耦合、直接耦合或通讯连接可以是通过一些接口、装置或单元的间接耦合、直接耦合或通讯连接,可以是电性、机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed device/network device and method may be implemented in other ways. The above-described device/network device embodiments are only illustrative, and the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units and components can be combined Or it can be integrated into another system, some features can be ignored and not implemented. In another point, the shown or discussed indirect coupling, direct coupling or communication connection may be through some interface, device or unit indirect coupling, direct coupling or communication connection, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
以上所述实施例仅用以说明本申请的技术方案,而非对其进行限制。尽管参照前述实施例对本申请进行了详细地说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改或者对其中部分技术特征进行等同替换,而这些修改或者替换,并不会使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solution of the present application, but not to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: they can still modify the technical solutions described in the aforementioned embodiments or equivalently replace some of the technical features, and these modifications Or replacement, which will not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310375144.4A CN116418369A (en) | 2023-03-30 | 2023-03-30 | Two-wire communication method, electronic device and computer readable storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310375144.4A CN116418369A (en) | 2023-03-30 | 2023-03-30 | Two-wire communication method, electronic device and computer readable storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN116418369A true CN116418369A (en) | 2023-07-11 |
Family
ID=87052712
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202310375144.4A Pending CN116418369A (en) | 2023-03-30 | 2023-03-30 | Two-wire communication method, electronic device and computer readable storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116418369A (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6430641B1 (en) * | 1999-05-04 | 2002-08-06 | International Business Machines Corporation | Methods, arbiters, and computer program products that can improve the performance of a pipelined dual bus data processing system |
| CN102484533A (en) * | 2009-10-29 | 2012-05-30 | 惠普发展公司,有限责任合伙企业 | Optical data bus and method |
| CN103118251A (en) * | 2012-05-08 | 2013-05-22 | 友达光电股份有限公司 | Method and system for multilevel data transmission |
| CN114900390A (en) * | 2022-03-28 | 2022-08-12 | 深圳市元征科技股份有限公司 | Data transmission method and device, electronic equipment and storage medium |
-
2023
- 2023-03-30 CN CN202310375144.4A patent/CN116418369A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6430641B1 (en) * | 1999-05-04 | 2002-08-06 | International Business Machines Corporation | Methods, arbiters, and computer program products that can improve the performance of a pipelined dual bus data processing system |
| CN102484533A (en) * | 2009-10-29 | 2012-05-30 | 惠普发展公司,有限责任合伙企业 | Optical data bus and method |
| CN103118251A (en) * | 2012-05-08 | 2013-05-22 | 友达光电股份有限公司 | Method and system for multilevel data transmission |
| CN114900390A (en) * | 2022-03-28 | 2022-08-12 | 深圳市元征科技股份有限公司 | Data transmission method and device, electronic equipment and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| TWI296083B (en) | Communication controller, host-side controller, communication system, usb system, communication equipment, communication method, packet-based communication method, packet-based communication program, and storage medium | |
| US9003089B2 (en) | Synchronous serial data-exchange system | |
| US10339093B2 (en) | USB interface using repeaters with guest protocol support | |
| TWI512449B (en) | Methods and apparatus for reducing power consumption within embedded systems | |
| KR102099789B1 (en) | Subscriber station for a bus system and method for transmitting messages between subscriber stations of a bus system | |
| US9569390B2 (en) | Protocol for communication | |
| WO2013124918A1 (en) | Initiator apparatus, target apparatus, communication system, timeout detection method, and timeout detection program | |
| CN115865830B (en) | Method and device for reducing RDMA network overhead based on connection management | |
| CN116627869B (en) | Data transmission method and device applied to electronic equipment | |
| CN109240975A (en) | Two take two system synchronous method and device | |
| US20240281403A1 (en) | I3c pending read with retransmission | |
| TWI483117B (en) | Device for executing a command, host controller and system for executing a command | |
| US20210173808A1 (en) | Early parity error detection on an i3c bus | |
| CN116418369A (en) | Two-wire communication method, electronic device and computer readable storage medium | |
| US20240214909A1 (en) | Method for data transmission, gateway and bluetooth tag | |
| CN103793344A (en) | Method and system for processing data collision | |
| CN116627879A (en) | SPI communication system and method applied to multiprocessor and vehicle-mounted terminal | |
| CN116909977A (en) | Multi-machine communication method and system | |
| CN116419318A (en) | Communication method and device of processor, electronic equipment and storage medium | |
| WO2024131009A1 (en) | Inter-chip communication method and storage medium | |
| KR20250133436A (en) | SPI-based data transmission method, chip, controller, and storage medium | |
| CN116846705A (en) | Communication method, system, master node, slave node, and computer storage medium | |
| US20240357491A1 (en) | Systems, methods, and devices for low-power operation of wireless devices | |
| WO2010070530A1 (en) | Electronic apparatus comprising a common bus | |
| US20210286743A1 (en) | Memory system and information processing system |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |