Data processing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202611037459.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-13
- Publication Date
- 2026-08-28
AI Technical Summary
但实际应用中,串行数据线(Serial Data,SDA)或串行时钟线(Serial Clock,SCL)易被从机异常拉低,引发总线挂死问题,影响系统稳定运行
[0020] The data processing method disclosed herein determines the time threshold for each slave device in each communication phase within a first time window during communication between the master and multiple slave devices. In response to a first slave device whose duration in the first communication phase is greater than or equal to the time threshold, a recovery signal is sent to the multiple slave devices, causing the first slave device to stop pulling the serial data line low and pulling up the SDA level using the corresponding pull-up resistor, thus releasing the bus from occupancy. The recovery signal includes the address corresponding to the first slave device. This allows for early prediction of deadlock risks through slave device behavior profiling, intervention before the bus crashes, and prevention of fault escalation. Furthermore, the recovery signal and address filtering mechanism ensure precise recovery only for faulty slave devices without interfering with normal equipment.
Smart Images

Figure CN122653889A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of integrated circuit bus communication technology, and in particular to a data processing method, apparatus, electronic device and storage medium. Background Technology
[0002] Inter-Integrated Circuit (I2C) buses are widely used in embedded systems due to their simple structure and flexible configuration. However, in practical applications, the serial data line (SDA) or serial clock line (SCL) can be abnormally pulled low by the slave device, causing the bus to hang and affecting the stable operation of the system.
[0003] In related technologies, fault recovery solutions are mainly divided into two categories: software timeout recovery and hardware watchdog. Software timeout recovery relies on the operating status of the main controller software, and the recovery process will interrupt communication and interfere with normal slave devices. Although hardware watchdog does not rely on software, the recovery operation lacks specificity and is prone to disrupting normal transmission. At the same time, neither of the above two solutions has fault prediction capabilities, cannot achieve accurate recovery of faulty slave devices, and the recovery pulse can easily cause disorder in the normal slave device status. Summary of the Invention
[0004] This disclosure provides a data processing method, apparatus, electronic device, and storage medium to at least solve the above-mentioned technical problems existing in the prior art.
[0005] According to a first aspect of this disclosure, a data processing method is provided, the method comprising: During communication between the master and multiple slaves, determine the time threshold for each slave in each communication stage within the first time window; In response to the fact that the duration of the first slave device in the first communication phase is greater than or equal to the time threshold of the first slave device in the first communication phase, a recovery signal is sent to the plurality of slave devices, causing the first slave device to stop pulling the serial data line low, and the pull-up resistor corresponding to the first slave device pulls the level high to release the bus occupation; The recovery signal includes the address corresponding to the first slave device.
[0006] In the above scheme, determining the time threshold for each slave device in each communication stage within a first time window during the communication process between the host and multiple slave devices includes: During communication between the master and multiple slaves, determine the start and end times of each slave in each communication phase within the first time window; The duration of each slave device in each communication phase is determined based on the start and end times of each slave device in each communication phase. Based on the duration of each slave device in each communication phase within the first time window, determine the average duration and duration variance of each slave device in each communication phase; Based on the average duration and duration variance of each slave device in each communication phase, the time threshold of each slave device in each communication phase is determined.
[0007] In the above scheme, determining the start and end times of each slave device in each communication phase within a first time window during the communication process between the host and multiple slave devices includes: During communication between the master and multiple slave devices, monitor the serial signal lines and serial clock lines; Based on the first time window, the serial signal line and serial clock line determine the start and end times of each slave device in each communication phase.
[0008] In the above scheme, determining the duration of each slave device in each communication phase based on the start and end times of each slave device in each communication phase includes: The difference between the end time and the start time of any slave device in any communication phase is determined as the duration of that slave device in that communication phase.
[0009] In the above scheme, determining the average duration and duration variance of each slave device in each communication phase based on the duration of each slave device in each communication phase within the first time window includes performing the following operations on the first communication phase of each slave device: Determine the duration of each first communication phase for the slave device within the first time window; The average duration and duration variance of the slave device in the first communication phase are determined based on the duration of the slave device in each first communication phase. The first time window includes at least two communication processes between the host and multiple slave devices.
[0010] In the above scheme, determining the time threshold for each slave device in each communication phase based on the average duration and duration variance of each slave device in each communication phase includes: Based on the duration variance and preset coefficients of each slave device in each communication phase, preset variables for each slave device in each communication phase are determined. Based on the average duration of each slave device in each communication phase and the preset variables, the time threshold for each slave device in each communication phase is determined.
[0011] The method in the above scheme further includes: Determine the time threshold for each slave device in each communication phase within the second window; Based on the time threshold of each slave device in each communication stage within the first window and the time threshold of each slave device in each communication stage within the second window, update the time threshold of each slave device in each communication stage.
[0012] In the above scheme, sending a recovery signal to the plurality of slave devices includes: In response to the fact that the duration of the first slave device in the first communication phase is greater than or equal to the time threshold of the first slave device in the first communication phase, the address corresponding to the first slave device is determined; The recovery signal is determined based on the address corresponding to the first slave device; The recovery signal is sent to all slave devices corresponding to the host.
[0013] In the above scheme, sending a recovery signal to the plurality of slave devices includes: When the serial clock line goes high, the first communication phase between the master and the first slave is confirmed to be over. In response to the end of the first communication phase, the recovery signal is sent to all slave devices; The recovery signal is used to indicate that when the serial clock line is at a high level, the serial signal line should first be at a low level and then switch to a high level.
[0014] The method in the above scheme further includes: Confirm that the serial signal line corresponding to the first slave device is at a high level; If the serial signal line corresponding to the first slave device is high, it is confirmed that the first slave device has released its occupancy of the bus. In response to the serial signal line corresponding to the first slave being at a low level, it is confirmed that the bus occupancy of the first slave has not been released, and a clock pulse signal is sent to the plurality of slaves to release the first slave from the bus occupancy.
[0015] In the above scheme, after sending clock pulse signals to the plurality of slave devices, the method further includes: In response to the serial signal line corresponding to the first slave device being at a low level, the power supply to the first slave device is cut off.
[0016] In the above scheme, after confirming the release of the first slave device from the bus, the method further includes: A recovery completion signal is sent to the host to enable the host to transmit data with the plurality of slave devices.
[0017] According to a second aspect of this disclosure, a data processing apparatus is provided, the apparatus comprising: The slave behavior profiling unit is used to determine the time threshold of each slave in each communication stage within the first time window during the communication process between the master and multiple slaves. The recovery unit is configured to send a recovery signal to the plurality of slave devices in response to the fact that the duration of the first slave device in the first communication phase is greater than or equal to the time threshold of the first slave device in the first communication phase, thereby causing the first slave device to stop pulling the serial data line low and pulling the level high by the pull-up resistor corresponding to the first slave device to release the bus occupation. The recovery signal includes the address corresponding to the first slave device.
[0018] According to a third aspect of this disclosure, an electronic device is provided, comprising: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods of this disclosure.
[0019] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions for causing the computer to perform the methods described in this disclosure.
[0020] The data processing method disclosed herein determines the time threshold for each slave device in each communication phase within a first time window during communication between the master and multiple slave devices. In response to a first slave device whose duration in the first communication phase is greater than or equal to the time threshold, a recovery signal is sent to the multiple slave devices, causing the first slave device to stop pulling the serial data line low and pulling up the SDA level using the corresponding pull-up resistor, thus releasing the bus from occupancy. The recovery signal includes the address corresponding to the first slave device. This allows for early prediction of deadlock risks through slave device behavior profiling, intervention before the bus crashes, and prevention of fault escalation. Furthermore, the recovery signal and address filtering mechanism ensure precise recovery only for faulty slave devices without interfering with normal equipment.
[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0022] The above and other objects, features, and advantages of this disclosure will become readily apparent from the following detailed description of exemplary embodiments, taken in conjunction with the accompanying drawings. Several embodiments of this disclosure are illustrated in the drawings by way of example and not limitation, in which: In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
[0023] Figure 1 This illustration shows an optional flowchart of a data processing method provided in an embodiment of the present disclosure; Figure 2 A schematic diagram illustrating the communication process between a host and a slave device provided in an embodiment of this disclosure is shown. Figure 3 A schematic diagram of another optional flow of the data processing method provided in an embodiment of this disclosure is shown; Figure 4 A schematic diagram of another optional flow of the data processing method provided in an embodiment of this disclosure is shown; Figure 5 A schematic diagram of an optional structure of the data processing apparatus provided in an embodiment of this disclosure is shown; Figure 6 A schematic diagram of the composition structure of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation
[0024] To make the objectives, features, and advantages of this disclosure more apparent and understandable, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.
[0025] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0026] In the following description, the terms "first" and "second" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0027] Unless otherwise defined, all technical and scientific terms used in this disclosure have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs. The terminology used in this disclosure is for the purpose of describing embodiments of this disclosure only and is not intended to be limiting of this disclosure.
[0028] It should be understood that in the various embodiments of this disclosure, the sequence number of each implementation process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this disclosure.
[0029] Figure 1 An optional flowchart of the data processing method provided in an embodiment of this disclosure is shown, and the steps will be described accordingly.
[0030] Step S101: During the communication process between the host and multiple slave devices, determine the time threshold for each slave device in each communication stage within the first time window.
[0031] Figure 2 A schematic diagram illustrating the communication process between a host and a slave device provided in an embodiment of this disclosure is shown.
[0032] like Figure 2 As shown, the communication process includes five stages: Start, Address, Acknowledgment, Data, and Stop. The initial state is the idle state, waiting for the communication process to begin. At this time, both the serial clock line and serial data line are high, and the bus is idle. The master waits to initiate communication (Start), and all slave devices are in standby mode, monitoring the Start condition of the bus.
[0033] During the initial communication phase, with SCL high, the master pulls SDA low to generate the Start condition, transitioning from the idle state to the address communication phase. The slave detects the start signal and prepares to receive the address.
[0034] During the address communication phase, the master sends slave addresses and read / write bits to multiple slave devices, and the slave devices monitor the address signals on the bus. The main monitoring points during this phase are the start and end times of slave address reception to determine the duration of address reception.
[0035] During the response communication phase, after the master sends the slave address and read / write bits, it releases SDA (restoring SDA from low to high) and waits for the slave's response. For example... Figure 2 As shown, after "address reception complete", the monitoring switches from the start and end times of the slave receiving the address to the start and end times of the slave sending the response to the master, thus determining the duration of the slave's response.
[0036] During this phase, the slave device that matches the slave address sent by the master pulls SDA low in the 9th SCL clock cycle to generate an ACK (acknowledgment); if the address does not match, there is no response (NACK).
[0037] During the data communication phase, such as Figure 2As shown, after receiving an ACK, the start and end times of data transmission are monitored. Specifically, if the read / write bit is set to write, the master sends data to the slave, monitoring the start and end times of data transmission; if the read / write bit is set to read, the slave sends data to the master, monitoring the start and end times of data transmission to determine the duration of the data communication phase. Correspondingly, if a NACK or Stop response is received from the slave (address mismatch), the system returns to a bus idle state, and communication terminates.
[0038] During this phase, the master or slave sends bytes one by one, according to the direction of the read / write bits, with each byte occupying 8 SCL clock cycles, such as... Figure 2 As shown, after each byte, the response communication stage begins, waiting for ACK.
[0039] Specifically, if the read / write bit is set to write, the master sends multiple bytes to the slave, with each byte occupying 8 SCL clock cycles. For example... Figure 2 As shown, after each byte, the acknowledgment communication phase begins. The slave device pulls SDA low in the 9th clock cycle to send an ACK to the master, indicating successful reception, and continues data transmission. If the master sends the last byte and the slave device sends a NACK, it indicates the end of transmission.
[0040] Specifically, if the read / write bit is set to read, the slave device sends multiple bytes to the master device, with each byte occupying 8 SCL clock cycles. For example... Figure 2 As shown, after each byte, the acknowledgment communication phase begins. The master pulls SDA low in the 9th clock cycle to send an ACK to the slave, indicating successful reception, and continues data transmission. If the slave sends the last byte and the master sends a NACK, it indicates the end of transmission.
[0041] During the communication termination phase, after data transmission is complete, the host pulls the SDA level high from low when SCL is high, such as... Figure 2 If a Stop is detected (i.e., SCL high, SDA low to high), the system returns to the idle state. The communication termination phase also includes scenarios of abnormal termination, where receiving a NACK or detecting a Stop at any stage results in a return to the idle state. The idle state refers to the idle state of the I2C bus corresponding to the host.
[0042] In some embodiments, within a first time window, the host communicates with at least one slave device through multiple communication processes, each communication process including multiple communication stages. The carrier implementing the data processing method (hereinafter referred to as the carrier) statistically analyzes the communication processes of each slave device and determines the time threshold for the same communication stage within the multiple communication processes of each slave device.
[0043] For example, within the first window, the host and slave 1 generate a1 communication processes; the host and slave 2 generate a2 communication processes, ..., the host and slave n generate an communication processes. Then, statistics are performed on each slave as an individual to determine the time threshold for each slave in each communication stage. For instance, the time thresholds for the start communication stage, address communication stage, response communication stage, data communication stage, and end communication stage are calculated for the an communication processes of slave m. n is a positive integer, and m is a positive integer ranging from [1, n].
[0044] Step S102: In response to the first slave device having a duration greater than or equal to a time threshold of the first slave device in the first communication phase, a recovery signal is sent to the plurality of slave devices.
[0045] In some embodiments, the first slave device is any one of a plurality of slave devices communicating with the master device; the first communication stage is any communication stage in the communication process between the master device and the first slave device.
[0046] In some embodiments, in response to the first slave device having a duration greater than or equal to a time threshold of the first slave device in the first communication phase, indicating that the first slave device may have failed, a recovery signal is sent to the plurality of slave devices; the recovery signal includes the address of the first slave device.
[0047] In some embodiments, after receiving the recovery signal, the plurality of slave devices match the address of the first slave device included in the recovery signal with their own address. If the match fails, it means that the address of the first slave device included in the recovery signal is not the address of the current slave device, and the slave device does not respond to the recovery signal. If the match succeeds, it means that the address of the first slave device included in the recovery signal is the address of the current slave device, and the recovery signal is a recovery signal for the current slave device. The first slave device then responds to the recovery signal by stopping the serial data line SDA from being pulled low, and pulling up the SDA level by the pull-up resistor corresponding to the first slave device, thereby releasing the first slave device from occupying the bus.
[0048] Thus, the data processing method provided in this embodiment can predict deadlock risks in advance through slave behavior profiling, intervene before the bus hangs, and prevent the fault from escalating; with the help of recovery signal and address filtering mechanism, only faulty slaves can be accurately restored without interfering with normal equipment.
[0049] Figure 3 A schematic diagram of another optional flow of the data processing method provided in the embodiments of this disclosure is shown, and will be described according to each step.
[0050] Step S201: During the communication process between the host and multiple slave devices, determine the start and end times of each slave device in each communication phase within the first time window.
[0051] In some embodiments, the host communicates with multiple slave devices via an internal integrated circuit (I2C) bus (or bus), and the carrier statistically analyzes the start and end times of each slave device in each communication phase within a first time window. The first time window can be any time window, and includes at least two communication processes between the host and the multiple slave devices.
[0052] In some embodiments, the carrier monitors the SDA and SCL between the host and multiple slave devices to determine the current communication phase, start time, end time, and slave device address.
[0053] Step S202: Based on the start and end times of each slave device in each communication phase, determine the time threshold for each slave device in each communication phase.
[0054] In some embodiments, the start and end times of each slave device in each communication phase are monitored based on SDA and SCL. Based on the start and end times of each slave device in each communication phase, the duration of each slave device in each communication phase is determined. Based on the duration of each slave device in each communication phase within a first time window, the average duration and duration variance of each slave device in each communication phase are determined.
[0055] In some embodiments, the carrier performs statistical analysis on a per-slave basis to determine the duration of each slave device in each communication phase across multiple communication processes. The average duration and duration variance of each slave device in each communication phase are determined on a per-slave-device and per-communication-phase basis.
[0056] In practice, the host communicates with slave 1, slave 2, ..., slave n. Within the first time window, the start and end times of different communication stages of slave 1 in communication processes b1, b2, ..., bk are collected. This allows the determination of the start and end times of the start communication stage, address communication stage, response communication stage, data communication stage, and end communication stage within each of the communication processes b1, b2, ..., bk. Furthermore, the duration of each of these stages is determined. Here, k is a positive integer.
[0057] The carrier will count the duration of each slave device in each communication stage of each communication process; taking slave device 1 as an example, the carrier will count the duration of k initial communication stages, k address communication stages, k response communication stages, k data communication stages and k end communication stages in communication processes b1, b2, ..., bk. Based on the duration of k initial communication phases of slave device 1, the average duration and duration variance of each initial communication phase are determined; based on the duration of k address communication phases of slave device 1, the average duration and duration variance of each address communication phase are determined; based on the duration of k response communication phases of slave device 1, the average duration and duration variance of each response communication phase are determined; based on the duration of k data communication phases of slave device 1, the average duration and duration variance of each data communication phase are determined; based on the duration of k final communication phases of slave device 1, the average duration and duration variance of each final communication phase are determined. The methods for determining the average duration and duration variance of other slave devices in different communication phases are similar to those for slave device 1 and will not be repeated here.
[0058] In some embodiments, the carrier determines the time threshold for each slave device in each communication phase based on the average duration and duration variance of each slave device in each communication phase.
[0059] In specific implementation, the carrier can directly determine the time threshold of each slave device in each communication phase based on the average duration of each slave device in each communication phase; it can also determine a preset variable for each slave device in each communication phase based on the variance of the duration of each slave device in each communication phase and a preset coefficient; based on the value of the average duration of each slave device in each communication phase and the value of the preset variable, the value of the time threshold of each slave device in each communication phase is determined, and a time unit is assigned to this value, wherein the time unit is the same as the unit of the average duration. Specifically, the first... The slave machine in the first The value of the time threshold for each communication stage for:
[0060] in, For the first The slave machine in the first The average duration of each communication phase. For the first The slave machine in the first The numerical value of the duration variance of each communication phase. This is a preset coefficient that can be set according to actual needs or experimental results; for example, it can be set to 3.
[0061] Alternatively, in specific implementation, the carrier can also determine a preset variable for each slave device in each communication stage based on the standard deviation of the duration of each slave device in each communication stage and a preset coefficient; and determine a time threshold for each slave device in each communication stage based on the average duration of each slave device in each communication stage and the preset variable, wherein the standard deviation of the duration is determined based on the variance of the duration.
[0062] In some optional embodiments, the carrier can further determine the time threshold for each slave device in each communication stage within the second window; based on the time thresholds for each slave device in each communication stage within the first window and the second window, the carrier updates the time threshold for each slave device in each communication stage. That is, as communication between the master and slave devices proceeds, the carrier updates the time thresholds using the latest monitored duration of each slave device in each communication stage, making the time thresholds more suitable for the current stage and enabling a more accurate determination of which slave device might malfunction.
[0063] Step S203: Monitor the duration of all slave devices in different communication phases.
[0064] In some embodiments, the carrier monitors the duration of all slave devices in different communication phases based on SDA and SCL, obtains the duration of all slave devices in different communication phases, and compares it with the time threshold of the corresponding slave device in the corresponding communication phase.
[0065] If the duration is less than the time threshold, it indicates that the communication between the slave and the master is normal; if the duration is greater than or equal to the time threshold, it indicates that the slave may be deadlocked, that is, the slave may be occupying the bus.
[0066] Step S204: In response to the first slave device having a duration greater than or equal to a time threshold of the first slave device in the first communication phase, a recovery signal is sent to the plurality of slave devices.
[0067] In some embodiments, in response to the first slave device having a duration greater than or equal to a time threshold of the first slave device during the first communication phase, a recovery signal is determined based on the address of the first slave device, and the recovery signal is sent to the plurality of slave devices.
[0068] In step S205, the first slave device responds to the recovery signal and releases the first slave device from the bus.
[0069] In some embodiments, after receiving the recovery signal, the plurality of slave devices match the address of the first slave device included in the recovery signal with their own address. If the match fails, it means that the address of the first slave device included in the recovery signal is not the address of the current slave device, and the slave device does not respond to the recovery signal. If the match succeeds, it means that the address of the first slave device included in the recovery signal is the address of the current slave device, and the recovery signal is a recovery signal for the current slave device. The first slave device then responds to the recovery signal by stopping the serial data line SDA from being pulled low, and pulling up the SDA level by the pull-up resistor corresponding to the first slave device, thereby releasing the first slave device from occupying the bus.
[0070] In specific implementation, in response to SCL being high, the first communication phase between the master and the first slave is confirmed to be over; in response to the end of the first communication phase, the recovery signal is sent to all slaves; wherein, the recovery signal is used to indicate that when SCL is high, SDA should first be low and then high.
[0071] The data processing method provided by this disclosure can predict deadlock risks in advance through slave behavior profiling, intervene before the bus crashes, and prevent the fault from escalating; with the help of recovery signal and address filtering mechanism, it can accurately restore only the faulty slave without interfering with normal equipment; it can accumulate and update the duration of different slaves in different communication stages based on multiple time windows, so that the slave profile library can learn online and adapt to the timing differences of different slaves without manual configuration.
[0072] Figure 4 A schematic diagram of another optional flow of the data processing method provided in the embodiments of this disclosure is shown, and will be described in accordance with each step.
[0073] In some embodiments, after step S102 or step S205, the method further includes: Step S301: Confirm whether the SDA corresponding to the first slave device is high.
[0074] If the serial signal line corresponding to the first slave device is high, it is confirmed that the first slave device has released its occupancy of the bus. If the serial signal line corresponding to the first slave device is at a low level, it is confirmed that the bus corresponding to the first slave device has not been released from occupancy, and step S302 is executed.
[0075] Step S302: Send clock pulse signals to the plurality of slave devices.
[0076] The clock pulse signal can be 9 clock pulses, used to force a bus reset.
[0077] In step S303, in response to the serial signal line corresponding to the first slave device being at a low level, the power supply to the first slave device is cut off.
[0078] In some embodiments, if the SDA of the first slave device remains low after the clock pulse signal is sent, meaning the clock pulse signal cannot release the first slave device from its bus occupation, then hardware means are used to cut off the power supply to the first slave device to release its bus occupation.
[0079] Thus, by utilizing the data processing method provided by this disclosure, deadlock risks can be predicted in advance through slave behavior profiling, allowing intervention before the bus crashes and preventing the fault from escalating; with the help of recovery signal and address filtering mechanisms, accurate recovery is performed only on faulty slaves without interfering with normal equipment; the profile library can learn online and adapt to the timing differences of different slaves without manual configuration; a hierarchical recovery strategy is adopted, gradually executing from software to hardware, improving the recovery success rate and extending the service life of the equipment.
[0080] Figure 5 A schematic diagram of an optional structure of the data processing apparatus provided in an embodiment of this disclosure is shown, and will be described in terms of each part.
[0081] In some embodiments, the data processing apparatus includes a slave behavior profiling unit and a recovery unit.
[0082] The slave behavior profiling unit is used to determine the time threshold of each slave in each communication stage within a first time window during the communication process between the host and multiple slaves. The recovery unit is configured to send a recovery signal to the plurality of slave devices in response to the first slave device having a duration greater than or equal to a time threshold of the first slave device in the first communication phase, thereby causing the first slave device to stop pulling the serial data line SDA low and pulling the SDA level high by the pull-up resistor corresponding to the first slave device to release the bus occupation. The recovery signal includes the address corresponding to the first slave device.
[0083] In some embodiments, the data processing apparatus may further include a monitoring unit.
[0084] The monitoring unit is used to determine the start and end times of each slave device in each communication phase within a first time window during the communication process between the host and multiple slave devices.
[0085] The slave behavior profiling unit is specifically used to determine the duration of each slave in each communication phase based on the start and end times of each slave in each communication phase; to determine the average duration and duration variance of each slave in each communication phase based on the duration of each slave in each communication phase within a first time window; and to determine the time threshold of each slave in each communication phase based on the average duration and duration variance of each slave in each communication phase.
[0086] The monitoring unit is specifically used to monitor the serial signal line and serial clock line during communication between the host and multiple slave devices. Based on the first time window, the serial signal line and serial clock line determine the start and end times of each slave device in each communication phase.
[0087] The slave behavior profiling unit is specifically used to determine the difference between the end time and the start time of any slave device in any communication phase, which is the duration of the slave device in that communication phase.
[0088] The slave behavior profiling unit is specifically used to perform the following operations on the first communication phase of each slave: Determine the duration of each first communication phase for the slave device within the first time window; The average duration and duration variance of the slave device in the first communication phase are determined based on the duration of the slave device in each first communication phase. The first time window includes at least two communication processes between the host and multiple slave devices.
[0089] The slave behavior profiling unit is specifically used to include: Based on the duration variance and preset coefficients of each slave device in each communication phase, preset variables for each slave device in each communication phase are determined. Based on the average duration of each slave device in each communication phase and the preset variables, the time threshold for each slave device in each communication phase is determined.
[0090] The slave behavior profiling unit is also used for: Determine the time threshold for each slave device in each communication phase within the second window; Based on the time threshold of each slave device in each communication stage within the first window and the time threshold of each slave device in each communication stage within the second window, update the time threshold of each slave device in each communication stage.
[0091] The recovery unit is specifically used to determine the address corresponding to the first slave device in response to the fact that the duration of the first slave device in the first communication phase is greater than or equal to the time threshold of the first slave device in the first communication phase. The recovery signal is determined based on the address corresponding to the first slave device; The recovery signal is sent to all slave devices corresponding to the host.
[0092] The recovery unit is specifically used to confirm the end of the first communication phase between the master and the first slave in response to the serial clock line being at a high level. In response to the end of the first communication phase, the recovery signal is sent to all slave devices; The recovery signal is used to indicate that when the serial clock line is at a high level, the serial signal line should first be at a low level and then switch to a high level.
[0093] The recovery unit is also used to confirm whether the serial signal line corresponding to the first slave device is at a high level; If the serial signal line corresponding to the first slave device is high, it is confirmed that the first slave device has released its occupancy of the bus. In response to the serial signal line corresponding to the first slave being at a low level, it is confirmed that the bus occupancy of the first slave has not been released, and a clock pulse signal is sent to the plurality of slaves to release the first slave from the bus occupancy.
[0094] After sending clock pulse signals to the plurality of slave devices, the recovery unit is further configured to: In response to the serial signal line corresponding to the first slave device being at a low level, the power supply to the first slave device is cut off.
[0095] After confirming the release of the first slave device from the bus, the recovery unit is further configured to: A recovery completion signal is sent to the host to enable the host to transmit data with the plurality of slave devices.
[0096] In some embodiments, the data processing method or data processing apparatus may be implemented based on a field-programmable gate array (FPGA).
[0097] In some embodiments, the data processing device may further include a bus interface and a master control communication interface. The bus interface is connected to the SDA and SCL of the I2C bus, respectively. The bus interface is also connected to a monitoring unit, so that the monitoring unit can collect the start and end times of each slave device in each communication phase through the bus interface.
[0098] The slave behavior profiling unit is communicatively connected to the monitoring unit and the recovery unit, respectively.
[0099] The slave device behavior profiling unit receives the start and end times of each slave device in each communication phase from the monitoring unit, and determines the time threshold for each slave device in each communication phase based on the start and end times of each communication phase. It then transmits the time threshold for each slave device in each communication phase to the recovery unit.
[0100] The recovery unit is connected to the main control communication interface.
[0101] The recovery unit is used to receive the time threshold of each slave device in each communication stage, monitor the duration of each slave device in each communication stage and compare it with the time threshold. In response to any slave device having a duration of more than or equal to the time threshold in the corresponding communication stage, a recovery signal is determined and sent to the slave device through the master control communication interface.
[0102] In some embodiments, the master control communication interface is connected to the master controller corresponding to the slave device, and is used to send the received recovery signal to multiple slave devices.
[0103] In practice, the monitoring unit monitors the SDA and SCL signals in real time, parses the I2C protocol, identifies the initial communication phase (e.g., address phase) and counts the address reception duration; the address communication phase (e.g., determining the ACK phase) and counts the slave response time, response communication phase, data communication phase (e.g., single-byte / multi-byte communication duration), and each phase of the stop communication phase (start time, end time, duration), and outputs the current phase status (in which phase) and the slave address of the current communication.
[0104] In practice, the monitoring unit divides the continuous SDA / SCL signals based on the communication phase and determines the start and end times of each communication phase.
[0105] The slave behavior profiling unit maintains a dynamic behavior model for each slave address, recording its typical communication duration, response time distribution, clock delay characteristics, etc., and continuously learns and updates online.
[0106] The recovery unit triggers a recovery process when it detects an abnormal pause (such as a slave device pulling SDA low for more than its time threshold during the data phase). A virtual Stop condition is inserted during the bus idle phase (during the SCL high level), which is only responded to by the target slave device; other slave devices are ignored through a hardware mask. If the virtual Stop condition is invalid, backup recovery strategies are sequentially activated, such as a 9-pulse with address filtering or bus isolation.
[0107] The bus interface is responsible for the interface connecting to the physical bus, including level monitoring, signal driving, and hardware masking logic.
[0108] The main control communication interface is used to communicate with the main controller and report recovery events and status.
[0109] In some embodiments, after the system is powered on, the monitoring unit begins to monitor the bus and outputs the current phase (start time, end time, and communication stage) and slave address in real time.
[0110] During normal communication, the slave behavior profiling unit records the duration of each slave in each communication phase and establishes a statistical model (such as mean and variance).
[0111] If a slave device stays in a specific communication phase (such as the data communication phase) for more than its time threshold (e.g., mean + 3 times variance), a deadlock is predicted to occur.
[0112] The recovery unit immediately inserts a virtual Stop signal after the current byte transmission is complete (SCL high level). This signal, through the hardware mask of the bus interface unit, ensures that only devices with addresses matching the faulty slave can recognize and reset the internal state machine; other slaves treat it as an invalid signal.
[0113] If the slave device's SDA is successfully released, the recovery ends; if SDA is still low, the second-level recovery is initiated, which involves sending nine clock pulses with address filtering; if this is still ineffective, hardware-level bus isolation is triggered (e.g., cutting off the power to the faulty slave device).
[0114] Typically, I2C bus deadlock occurs when a slave device keeps pulling SDA or SCL low during a certain communication phase (such as the acknowledgment or data communication phase) without releasing it. This prevents the master from sending a Stop signal to forcibly terminate the process, resulting in the bus being occupied and all slave devices being unable to perform any operations. The root cause is that the slave device's internal state machine is stuck, believing that the communication phase has not ended and therefore continues to occupy the bus.
[0115] The virtual Stop signal can force a stuck slave device to terminate the current communication phase.
[0116] In some embodiments, communication between the master and slave must end with a Stop signal before the slave releases SDA or SCL. When the slave is stuck, the master cannot send a Stop signal. In this case, the recovery unit inserts a virtual Stop signal at a high level on SCL, which is equivalent to giving the slave an end signal. This forces the slave's internal state machine back to the idle state, thereby causing the slave to automatically release SDA to restore the bus.
[0117] In some embodiments, the monitoring unit uses a high-impedance input to acquire SDA / SCL levels in real time and removes glitches through digital filtering.
[0118] In some embodiments, the slave behavior profiling unit may employ a dual-port RAM to store the start time, end time, duration, and count of different communication stages corresponding to each slave address, and to determine the time threshold for each slave in different communication stages.
[0119] In some embodiments, in response to the start of monitoring, the bus phase tracker included in the monitoring unit is initialized.
[0120] The monitoring unit analyzes the bus phase in real time, identifies Start, Address, R / W, Response, Data, Stop, etc., and records the current communication slave address.
[0121] The slave behavior profiling unit updates the corresponding slave behavior profile based on the analysis results. For example, it records the duration of the slave during the data phase and updates its mean and variance.
[0122] The recovery unit determines whether the current phase dwell time exceeds the profile threshold (e.g., mean + 3 times variance). If it does not exceed the threshold, it returns to continue monitoring; if it does exceed the threshold, it is determined to be a potential deadlock risk and triggers the recovery process.
[0123] The recovery unit waits for the current byte transmission to complete, i.e., waits for SCL to go high (bus idle phase). During the SCL high level, the recovery unit generates a virtual Stop condition through the bus driver unit (SDA low then high, SCL high). At the same time, the hardware mask logic is enabled, and only devices whose addresses match the faulty slave will respond to this Stop condition.
[0124] The monitoring unit detects the SDA status. If SDA goes high, it indicates successful recovery. The unit then sends a recovery completion signal to the main controller via the main control communication interface, and bus control is returned to the main controller.
[0125] If SDA goes high, the second-stage recovery is initiated by sending nine clock pulses with address filtering. Before sending each pulse, the address matching signal is checked; the pulse is only valid if the clock is for the faulty slave, and ignored for other slaves. The SDA status is checked again. If the release is successful, the recovery is successful, and a recovery completion signal is sent to the master controller via the master communication interface, returning bus control to the master controller; otherwise, hardware-level bus isolation is triggered, for example, by cutting off power to the faulty slave via a power switch, or by forcibly pulling SDA high and generating a Stop signal.
[0126] According to embodiments of this disclosure, this disclosure also provides an electronic device and a readable storage medium.
[0127] Figure 6A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown in this disclosure, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure as described and / or claimed herein.
[0128] like Figure 6 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. The RAM 803 may also store various programs and data required for the operation of the electronic device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0129] Multiple components in electronic device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of displays, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows electronic device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0130] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as data processing methods. For example, in some embodiments, the data processing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the data processing method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform data processing methods by any other suitable means (e.g., by means of firmware).
[0131] Various embodiments of the systems and techniques described above in this disclosure can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0132] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0133] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0134] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0135] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0136] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0137] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this disclosure does not impose any limitations herein.
[0138] 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 at least one of that feature. In the description of this disclosure, "a plurality of" means two or more, unless otherwise explicitly specified.
[0139] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.
Claims
1. A data processing method, characterized in that, The method includes: During communication between the master and multiple slaves, determine the time threshold for each slave in each communication stage within the first time window; In response to the fact that the duration of the first slave device in the first communication phase is greater than or equal to the time threshold of the first slave device in the first communication phase, a recovery signal is sent to the plurality of slave devices, causing the first slave device to stop pulling the serial data line SDA low, and the pull-up resistor corresponding to the first slave device pulls the SDA level high to release the bus occupation; The recovery signal includes the address corresponding to the first slave device.
2. The method according to claim 1, characterized in that, The step of determining the time threshold for each slave device in each communication stage within a first time window during communication between the master and multiple slave devices includes: During communication between the master and multiple slaves, determine the start and end times of each slave in each communication phase within the first time window; The duration of each slave device in each communication phase is determined based on the start and end times of each slave device in each communication phase. Based on the duration of each slave device in each communication phase within the first time window, determine the average duration and duration variance of each slave device in each communication phase; Based on the average duration and duration variance of each slave device in each communication phase, the time threshold of each slave device in each communication phase is determined.
3. The method according to claim 2, characterized in that, During communication between the host and multiple slave devices, determining the start and end times of each slave device in each communication phase within a first time window includes: During communication between the master and multiple slave devices, monitor the serial signal lines and serial clock lines; Based on the first time window, the serial signal line and serial clock line determine the start and end times of each slave device in each communication phase.
4. The method according to claim 2, characterized in that, The determination of the duration of each slave device in each communication phase based on the start and end times of each slave device in each communication phase includes: The difference between the end time and the start time of any slave device in any communication phase is determined as the duration of that slave device in that communication phase.
5. The method according to claim 2, characterized in that, The determination of the average duration and duration variance of each slave device in each communication phase based on the duration of each slave device in each communication phase within the first time window includes performing the following operations for the first communication phase of each slave device: Determine the duration of each first communication phase for the slave device within the first time window; The average duration and duration variance of the slave device in the first communication phase are determined based on the duration of the slave device in each first communication phase. The first time window includes at least two communication processes between the host and multiple slave devices.
6. The method according to claim 2, characterized in that, The step of determining the time threshold for each slave device in each communication phase based on the average duration and duration variance of each slave device in each communication phase includes: Based on the duration variance and preset coefficients of each slave device in each communication phase, preset variables for each slave device in each communication phase are determined. Based on the average duration of each slave device in each communication phase and the preset variables, the time threshold for each slave device in each communication phase is determined.
7. The method according to claim 1 or 2, characterized in that, The method further includes: Determine the time threshold for each slave device in each communication phase within the second window; Based on the time threshold of each slave device in each communication stage within the first window and the time threshold of each slave device in each communication stage within the second window, update the time threshold of each slave device in each communication stage.
8. The method according to claim 1, characterized in that, Sending a recovery signal to the plurality of slave devices includes: In response to the fact that the duration of the first slave device in the first communication phase is greater than or equal to the time threshold of the first slave device in the first communication phase, the address corresponding to the first slave device is determined; The recovery signal is determined based on the address corresponding to the first slave device; The recovery signal is sent to all slave devices corresponding to the host.
9. The method according to claim 1 or 8, characterized in that, Sending a recovery signal to the plurality of slave devices includes: When the serial clock line goes high, the first communication phase between the master and the first slave is confirmed to be over. In response to the end of the first communication phase, the recovery signal is sent to all slave devices; The recovery signal is used to indicate that when the serial clock line is at a high level, the serial signal line should first be at a low level and then switch to a high level.
10. The method according to claim 1, characterized in that, The method further includes: Confirm that the serial signal line corresponding to the first slave device is at a high level; If the serial signal line corresponding to the first slave device is high, it is confirmed that the first slave device has released its occupancy of the bus. In response to the serial signal line corresponding to the first slave being at a low level, it is confirmed that the bus occupancy of the first slave has not been released, and a clock pulse signal is sent to the plurality of slaves to release the first slave from the bus occupancy.
11. The method according to claim 10, characterized in that, After sending clock pulse signals to the plurality of slave devices, the method further includes: In response to the serial signal line corresponding to the first slave device being at a low level, the power supply to the first slave device is cut off.
12. The method according to claim 1, characterized in that, After confirming the release of the first slave device from the bus, the method further includes: A recovery completion signal is sent to the host to enable the host to transmit data with the plurality of slave devices.
13. A data processing apparatus, characterized in that, The device includes: The slave behavior profiling unit is used to determine the time threshold of each slave in each communication stage within the first time window during the communication process between the master and multiple slaves. The recovery unit is configured to send a recovery signal to the plurality of slave devices in response to the fact that the duration of the first slave device in the first communication phase is greater than or equal to the time threshold of the first slave device in the first communication phase, thereby causing the first slave device to stop pulling the serial data line SDA low and pulling the SDA level high by the pull-up resistor corresponding to the first slave device to release the bus occupation. The recovery signal includes the address corresponding to the first slave device.
14. An electronic device, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-12.
15. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-12.