Master-slave communication method and device, electronic equipment, chip and storage medium

CN122903361APending Publication Date: 2026-10-13GUANGZHOU ZHONO ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611037489.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-13
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0004]本申请实施例提供了一种主从机通信方法、装置、电子设备、芯片以及存储介质,解决了相关技术中抵御重放攻击所采用的方式容易导致硬件与算力开销过高,无法适配低成本量产需求的问题,能够通过从机主动管控总线电平的方式破坏重放攻击的传输时序,降低硬件成本和算力开销,提升总线通信安全的同时,兼顾从机的低成本量产需求

Benefits of technology

[0012]本申请实施例中,通过从机主动控制总线电平的方式,从物理时序层面直接阻断重放攻击的有效传输,无需依赖高算力的随机数生成模块与同步时钟单元;由主机动态下发的第一时间系数结合锁定指令码参与运算,使得每次通信的静默窗口具备可变特性,大幅提升攻击者预判并规避锁定时段的难度;整体方案硬件实现成本低,可以适配耗材芯片等资源受限的从机设备。上述方案能够通过从机主动管控总线电平的方式破坏重放攻击的传输时序,降低硬件成本和算力开销,提升总线通信安全的同时,兼顾从机的低成本量产需求。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122903361A_ABST
    Figure CN122903361A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a master-slave communication method and device, electronic equipment, a chip and a storage medium. The method comprises: receiving lock instruction information sent by a host through a data bus, wherein the lock instruction information comprises a lock instruction code and a first time coefficient, and the lock instruction information is sent when the host determines that a lock operation needs to be triggered; converting and processing the first time coefficient based on the lock instruction code to obtain a lock duration, and driving the data bus to maintain a second level state based on the lock duration to suspend data transmission of the data bus; and after the lock duration ends, stopping driving the data bus to make the data bus return to a first level state to restore data transmission of the data bus. The present scheme can destroy the transmission timing of the replay attack by actively controlling the bus level of the slave, reduce the hardware cost and computing power overhead, improve the bus communication security, and at the same time, meet the low-cost mass production demand of the slave.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a master-slave communication method, apparatus, electronic device, chip, and storage medium. Background Technology

[0002] In communication systems, a master-slave architecture is the standard networking topology for serial buses such as I2C. In this architecture, a single master acts as the bus master, and multiple slave devices are connected in parallel to the same physical bus. During communication, the master addresses the target slave device by sending data frames and controls it to perform corresponding operations. The slave device with the matching address responds to the command, while the other devices remain silent. This architecture is widely used in various embedded scenarios, such as communication between a printing device and multiple consumable chips, or communication between an industrial terminal and multiple sensors. However, this bus communication mode has a serious replay attack security risk. Attackers can eavesdrop on legitimate commands transmitted on the bus and then repeatedly send those commands in subsequent periods, causing the slave devices to repeatedly perform unexpected operations, such as resetting internal counter parameters, reporting false status information, or skipping security verification processes, thereby achieving the purpose of cracking or fraud.

[0003] In related technologies, timestamp verification or random number challenge-response mechanisms are usually used to resist replay attacks. However, for cost-sensitive consumable chips such as ink cartridges and toner cartridges, which are limited in both computing and hardware resources, maintaining a synchronous clock or generating high-quality random numbers can easily lead to excessive hardware and computing power costs, making it unsuitable for low-cost mass production requirements. Summary of the Invention

[0004] This application provides a master-slave communication method, device, electronic device, chip, and storage medium, which solves the problem that the methods used to resist replay attacks in related technologies are prone to excessive hardware and computing power consumption, making them unsuitable for low-cost mass production. It can disrupt the transmission timing of replay attacks by actively controlling the bus level of the slave device, thereby reducing hardware costs and computing power consumption, improving bus communication security, and taking into account the low-cost mass production requirements of the slave device.

[0005] In a first aspect, embodiments of this application provide a master-slave communication method applied to a slave device, wherein the slave device and the master device are respectively connected to the same data bus, and the data bus is in a first level state when the slave device and the master device are not communicating. The master-slave communication method includes: The system receives a locking instruction message sent by the host through the data bus. The locking instruction message includes a locking instruction code and a first time coefficient. The locking instruction message is sent by the host when it determines that a locking operation needs to be triggered. The first time coefficient is converted based on the locking instruction code to obtain the locking duration, and the data bus is driven to maintain a second level state based on the locking duration to suspend the data transmission of the data bus; After the lock duration ends, the data bus is stopped from being driven, and the data bus is restored to the first level state to resume data transmission.

[0006] Secondly, embodiments of this application also provide a master-slave communication method applied to a master unit, wherein the master unit and multiple slave units are respectively connected to the same data bus, and the data bus is in a first-level state when the slave units are not communicating with the master unit. The master-slave communication method includes: Obtain the slave address corresponding to each slave currently connected to the data bus; Each slave device is assigned a corresponding locking instruction code and a first time coefficient, wherein the locking instruction code and / or first time coefficient are different for different slave devices; Locking instruction information is generated based on the slave address corresponding to the target slave, the locking instruction code corresponding to the target slave, and the first time coefficient corresponding to the target slave. The locking instruction information is sent to the target slave device via the data bus; While the target slave device drives the data bus to maintain a second level state based on the locking instruction information, data transmission through the data bus is suspended.

[0007] Thirdly, embodiments of this application also provide a master-slave communication device, wherein the master-slave communication device serves as a slave device connected to a data bus, and the data bus is in a first-level state when no communication is being performed. The master-slave communication device includes: The transceiver module is configured to receive locking instruction information sent by the host through the data bus. The locking instruction information includes a locking instruction code and a first time coefficient. The locking instruction information is sent by the host when it determines that a locking operation needs to be triggered. The processing module is configured to convert the first time coefficient based on the locking instruction code to obtain the locking duration; The driving module is configured to drive the data bus to maintain a second level state based on the lock duration to suspend data transmission of the data bus; after the lock duration ends, it stops driving the data bus to restore the data bus to the first level state to resume data transmission of the data bus.

[0008] Fourthly, embodiments of this application also provide a master-slave communication device, wherein the master-slave communication device serves as a master connected to a data bus, and multiple slave devices are connected to the data bus. The master-slave communication device includes: The acquisition module is configured to acquire the slave addresses corresponding to each slave device currently connected to the data bus; The allocation module is configured to allocate a corresponding locking instruction code and a first time coefficient to each of the slave devices, wherein the locking instruction code and / or the first time coefficient are different for different slave devices; The sending module is configured to generate locking instruction information based on the slave address corresponding to the target slave, the locking instruction code corresponding to the target slave, and the first time coefficient corresponding to the target slave; send the locking instruction information to the target slave through the data bus; and pause data transmission through the data bus while the target slave drives the data bus to maintain a second level state based on the locking instruction information.

[0009] Fifthly, embodiments of this application also provide an electronic device, the device comprising: One or more processors; Storage device, configured to store one or more programs, When one or more programs are executed by one or more processors, the one or more processors implement the master-slave communication method of the embodiments of this application.

[0010] Sixthly, embodiments of this application also provide a chip, which includes a communication interface for accessing a data bus, and the chip is used to execute the master-slave communication method of embodiments of this application.

[0011] In a seventh aspect, embodiments of this application also provide a non-volatile storage medium for storing computer-executable instructions, which, when executed by a computer processor, are configured to execute the master-slave communication method of embodiments of this application.

[0012] In this embodiment, the effective transmission of replay attacks is directly blocked at the physical timing level by the slave device actively controlling the bus level, without relying on a high-performance random number generation module and a synchronization clock unit. The first time coefficient dynamically issued by the host, combined with the locking instruction code, participates in the calculation, making the silent window of each communication variable, significantly increasing the difficulty for attackers to predict and circumvent the locking period. The overall solution has low hardware implementation cost and can be adapted to slave devices with limited resources such as consumable chips. The above solution can disrupt the transmission timing of replay attacks by the slave device actively controlling the bus level, reducing hardware costs and computing power overhead, improving bus communication security, while also meeting the low-cost mass production requirements of the slave device. Attached Figure Description

[0013] Figure 1 A flowchart illustrating a master-slave communication method provided in an embodiment of this application; Figure 2 A flowchart illustrating a master-slave communication method, including a specific implementation process for determining the lock duration, is provided as an embodiment of this application. Figure 3 A flowchart illustrating the specific implementation process of determining the target mapping relationship from a set of mapping relationships based on a locking instruction code, provided for embodiments of this application; Figure 4 A flowchart illustrating a master-slave communication method that includes a specific implementation process for verifying and locking instruction codes, provided in this application embodiment; Figure 5 A flowchart illustrating another master-slave communication method provided in this application embodiment; Figure 6 A structural block diagram of a master-slave communication device provided in an embodiment of this application; Figure 7 A structural block diagram of another master-slave communication device provided in the embodiments of this application; Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0014] The embodiments of this application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the embodiments of this application and are not intended to limit the scope of the embodiments. Furthermore, it should be noted that, for ease of description, only the parts relevant to the embodiments of this application are shown in the accompanying drawings, not the entire structure.

[0015] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0016] Figure 1This is a flowchart illustrating a master-slave communication method provided in an embodiment of this application. This method is applied to a slave device. Taking a printing device as the master, the slave device can be a consumable chip, which can be installed on various printing consumables, such as ink cartridges, toner cartridges, ribbons, and other consumable components. Furthermore, the slave and master devices are connected to the same data bus. Taking the I2C bus as an example, the SDA (Serial Data) line and the SCL (Serial Clock) line constitute the transmission channel. The data bus mentioned in this application can be the SDA line. Additionally, this data bus is in a first level state, for example, a high level state, when the slave and master are not communicating. Figure 1 As shown, the master-slave communication method specifically includes the following steps: Step S101: Receive the locking instruction information sent by the host through the data bus. The locking instruction information includes a locking instruction code and a first time coefficient. The locking instruction information is sent by the host when it determines that a locking operation needs to be triggered.

[0017] The lock command information can be a complete data frame used to trigger the slave device to perform a bus lock operation. In addition to the lock command code and the first time coefficient, the lock command information may also include the slave address and checksum. For example, the specific fields of the lock command information are as follows: Start bit (1 bit) — Slave address (7 bits) — Lock instruction code (8 bits) — First time coefficient (16 bits) — ... — Check code (8 bits) — Stop bit (1 bit).

[0018] The slave address is used to uniquely address the target slave device. The slave device uses the clock bus as a reference and continuously samples the data bus level signal after detecting the start bit. When it identifies whether the slave address matches its own address, it continuously samples subsequent bytes of data and writes them to the internal instruction register, completing the acquisition of the lock instruction information. The checksum is used to verify the completeness of the lock instruction information. The lock instruction code can be a predefined instruction code with a specific value range, used to identify the current instruction as a bus lock instruction, distinguishing it from ordinary business instructions such as reading / writing registers and reporting status. For example, in a printing scenario, the range 0xF0~0xFF is used as the encoding range for the lock instruction code, and different sub-ranges can correspond to different colored consumable chips. For example, a printing device is equipped with four types of consumable chips: black, cyan, magenta, and yellow. The range 0xF0~0xFF can be divided into four sub-ranges: black corresponds to sub-range 0xF0~0xF3, cyan to sub-range 0xF4~0xF7, magenta to sub-range 0xF8~0xFB, and yellow to sub-range 0xFC~0xFF. Taking the consumable chip corresponding to black as an example, any code within the sub-range 0xF0~0xF3 can represent a bus locking operation performed by that consumable chip. During the specific communication process, if the locking command code received by the consumable chip is within 0xF0~0xF3, it indicates that the locking command code is correct, and subsequent bus locking operations are allowed to continue. If the locking command code received by the consumable chip is not within 0xF0~0xF3, it indicates that the locking command code is incorrect, and subsequent bus locking operations are not allowed to continue. The first time coefficient can be an unsigned integer field representing the lock duration parameter, serving as an input variable for calculating the lock duration of the data bus. It should be noted that the first time coefficient is dynamically issued by the host, and different values ​​can be configured for each communication. This allows different slave devices or the same slave device to obtain different lock durations under different commands, increasing the difficulty for attackers to predict.

[0019] In one embodiment, the locking instruction information further includes verification information, which is used to verify the integrity of the locking instruction code and the first time coefficient; the specific implementation process of receiving the locking instruction information sent by the host through the data bus is as follows: The integrity of the lock command code and the first time coefficient is checked based on the verification information. If the verification passes, the lock duration is obtained by converting the first time coefficient based on the lock command code.

[0020] Optionally, the verification information can be a cyclic redundancy check (CRC) code. The method for verifying the integrity of the locking command code and the first time coefficient based on the verification information can be as follows: take the locking command code and the first time coefficient as input, perform a CRC (Cyclic Redundancy Check) operation through a preset generator polynomial to generate a fixed-length CRC value, and compare the CRC value with the CRC code. If they match, the verification is deemed successful, and the subsequent steps are continued. If they do not match, the verification is deemed unsuccessful, and the subsequent steps are stopped.

[0021] Optionally, the verification information can be a byte sum and a checksum. The method for verifying the integrity of the lock command code and the first time coefficient based on the verification information can be to perform a sequential summation operation on each byte of the lock command code and the first time coefficient, discard the carry and take the low-order result (or invert the result bit by bit) to obtain the result value, compare the result value with the byte sum and the checksum, if they match, the verification is deemed to have passed and the subsequent steps are continued, if they do not match, the verification is deemed to have failed and the subsequent steps are stopped.

[0022] Therefore, by verifying the lock command code and the first time coefficient, we can ensure that the lock command code and the first time coefficient are accurate, avoid the slave device from triggering data bus lock due to erroneous data, and ensure the stability of the normal communication process.

[0023] Step S102: Based on the lock instruction code, the first time coefficient is converted to obtain the lock duration, and the data bus is driven to maintain the second level state based on the lock duration to suspend the data transmission of the data bus.

[0024] The lock duration can be the total duration of the slave device actively clamping the bus level, which is the actual time value obtained after converting the first time coefficient, and its unit can be in milliseconds. In one embodiment, the method of converting the first time coefficient based on the lock command code to obtain the lock duration can be to select a mapping table based on the lock command code. This mapping table can store the correspondence between the first time coefficient and the lock duration, and the lock duration can be directly obtained by querying the mapping table using the first time coefficient. In another embodiment, the method of converting the first time coefficient based on the lock command code to obtain the lock duration can be to select a linear operation formula based on the lock command code, and then substitute the first time coefficient into the linear operation formula to calculate the lock duration. In yet another embodiment, the method of converting the first time coefficient based on the lock command code to obtain the lock duration can be to perform a second mapping process on the lock command code to obtain a time weighting factor; and then integrate the time weighting factor with the first time coefficient to obtain the lock duration. The second mapping process can be performed by looking up a table or numerical calculation, taking the lock command code as input and outputting the time weighting factor. This time weighting factor can be a coefficient parameter used to adjust the contribution ratio of the first time coefficient to the final lock duration, with different command codes corresponding to different weight values. The time weighting factor and the first time coefficient are integrated. One approach is to multiply the time weighting factor and the first time coefficient, and then multiply the product by a base time unit to obtain the final lock duration. Another approach is to multiply the time weighting factor and the first time coefficient, and then add a preset base duration offset to the product to obtain the final lock duration. Therefore, by flexibly configuring the lock duration by adjusting the lock command code and the first time coefficient, the scheduling flexibility is increased, the cost of attackers enumerating and cracking the code is significantly improved, and the security strength is enhanced.

[0025] The first and second level states differ. The second level state can be a fixed level maintained by the slave device actively driving the bus. Taking the I2C bus as an example, the second level state can be a logic low level (e.g., 0~0.7V). By maintaining the data bus at a low level, effective data transmission is prevented. It's important to note that when the data bus maintains the first level state, it is in an idle state, allowing data transmission. However, when the data bus maintains the second level state, it is in an occupied state, disallowing data transmission. The slave device drives the data bus to maintain the second level state based on the lock duration, effectively forcibly occupying the data bus for the duration of the lock, thus constructing a communication silence window. Within this communication silence window, no other bus device (including attackers) can initiate effective data transmission, causing the pre-recorded replay command frame to fail due to timing misalignment. Furthermore, this lock duration is determined by the lock command code and the first time coefficient. For the slave device, the lock command code and the first time coefficient for each legitimate communication can change dynamically, and the length of the corresponding communication silence window also changes accordingly, making it impossible for attackers to predict and circumvent the communication silence window.

[0026] Optionally, after converting the first time coefficient based on the locking instruction code to obtain the locking duration, the method further includes: Before the lock duration ends, monitor the real-time level signal of the data bus; if the real-time level signal of the data bus is found to be inconsistent with the second level state, set the security register to the error state and feed back the bus abnormality information to the host.

[0027] The real-time level signal can be the actual voltage state of the data bus at each moment during the locked period, serving as a direct indicator of whether the data bus has been abnormally driven. Monitoring the data bus involves the slave device continuously sampling the actual voltage value of the bus while actively driving it to maintain the second level state. If the real-time level signal of the data bus is found to be inconsistent with the second level state, it can be considered an abnormality in the current data bus level state, triggering an anomaly protection mechanism. This anomaly protection mechanism is implemented in two steps. The first step requires setting the security register to an error state. The security register can be a dedicated register inside the slave device used to store the device's security status. Its status value determines whether the slave device responds to subsequent instructions and whether it enables service functions. By setting the security register to an error state, it can be indicated that the slave device has detected a security anomaly, triggering protective actions such as locking the slave device and stopping the response to instructions. The second step requires feeding back bus anomaly information to the master device. The bus anomaly information can be status information indicating an abnormal event such as an illegal drive on the bus. Therefore, upon detecting an abnormal level, immediately setting the security register to an error state triggers the slave device to enter a lockout protection mode, ceasing to respond to all subsequent instructions and preventing attackers from forcibly breaking through the bus lockout to launch further attacks. Simultaneously, it feeds back the abnormal information to the master, enabling the master to synchronously enter the security processing flow, achieving coordinated protection between the master and slave devices and improving the overall system security level. The following provides a specific example of a practical application: Taking the I2C bus as an example, in the 5ms of the slave device performing data bus lockout (pulling the SDA line low), an external device performing a replay attack attempts to pull the SDA line high to initiate an illegal read operation. The slave continuously monitors the level of its driven SDA pin and finds that the actual voltage on the SDA line has been pulled high above the logic '1' threshold (e.g., exceeding 2.7V). The slave determines this to be a bus conflict abnormality and triggers a preset abnormality handling strategy: the slave's internal security register is configured to an error state, and the chip no longer responds to any subsequent instructions, i.e., it actively locks. Simultaneously, the slave reports an error to the printing device via another interrupt pin, and the printing device synchronously enters error handling mode, thereby preventing further operations by the attacker.

[0028] Optionally, the maximum lock duration can be preset internally by the slave device to prevent the master from sending a first time coefficient that results in an excessively large calculated lock duration due to software errors or interference, which could severely affect subsequent communication. Specifically, the implementation process of driving the data bus to maintain a second-level state based on the lock duration is as follows: If the lock duration is less than or equal to the set maximum lock duration, the data bus is driven to maintain the second level state according to the lock duration. If the lock duration is greater than the maximum lock duration, the data bus is driven to maintain the second level state according to the maximum lock duration.

[0029] Specifically, if the lock duration is less than or equal to the set maximum lock duration (e.g., 50ms), it is considered within a reasonable range, and the data bus can be driven to maintain the second-level state according to the lock duration. If the lock duration exceeds the maximum lock duration, it is considered to exceed the reasonable range, and the excessive duration will affect subsequent communication. Therefore, it needs to be limited to driving the data bus to maintain the second-level state according to the maximum lock duration to prevent the data bus from being locked due to erroneous lock commands, ensuring system robustness. Simultaneously, this timeout event can be recorded as a communication error for the host to query. Thus, by setting a limiting mechanism for the maximum lock duration, an upper limit is set for the bus lock operation, providing a safety net for bus availability. This limiting mechanism effectively avoids prolonged bus lock-up caused by erroneous commands or signal interference, preventing a single point of failure from paralyzing the entire communication system.

[0030] Optionally, driving the data bus to maintain a second-level state based on the lock duration includes: The target locking duration is obtained by adding the locking duration to the set second time coefficient; The data bus is driven to maintain a second-level state according to the target lock duration.

[0031] The second time coefficient can be a pre-configured time coefficient within the slave device, used to increase the lock duration within an allowed range. Understandably, the second time coefficient is used to make a small positive adjustment to the baseline lock duration; for example, the second time coefficient could be 2ms. The target lock duration can be the total duration of the actual bus lock driven by the slave device, and its value is always no less than the lock duration expected by the master. Therefore, by adding the second time coefficient, it is ensured that the actual lock duration is not less than the theoretical value expected by the master, guaranteeing the effectiveness and reliability of the bus silence protection window, while further increasing the unpredictability of the lock duration and significantly increasing the timing alignment difficulty of replay attacks. Furthermore, the incremental value brought by the second time coefficient is limited to the range allowed by the master and will not cause lock anomalies.

[0032] Step S103: After the lock duration ends, stop driving the data bus and restore the data bus to the first level state to resume data transmission.

[0033] The slave device can use an internal timer to keep track of the data bus. When the internal timer reaches the lock duration, the slave device can release the data bus, allowing it to return to an idle state and regain normal data transmission conditions. The master device or other slave devices can then initiate new communication according to the protocol specifications.

[0034] Optionally, during subsequent communication, the same slave device can continue to receive locking instruction information issued by the master device and repeat the above steps S102-S103. The first time coefficient and locking instruction code in the newly received locking instruction information can be different from the first time coefficient and locking instruction code received in the previous order to generate different locking durations, further increasing the difficulty of reverse engineering for attackers.

[0035] As can be seen from steps S101-S103 above, by actively controlling the bus level, the effective transmission of replay attacks is directly blocked at the physical timing level, without relying on a high-performance random number generation module and a synchronization clock unit. The first time coefficient dynamically issued by the host, combined with the locking instruction code, participates in the calculation, making the silent window of each communication variable, significantly increasing the difficulty for attackers to predict and circumvent the locking period. The overall solution has low hardware implementation cost and can be adapted to slave devices with limited resources such as consumable chips. The above solution can disrupt the transmission timing of replay attacks by actively controlling the bus level by the slave, reducing hardware costs and computing power overhead, improving bus communication security, while also meeting the low-cost mass production needs of slave devices.

[0036] Figure 2 A flowchart of a master-slave communication method, including a specific implementation process for determining the lock duration, is provided for embodiments of this application. Figure 2 As shown, the master-slave communication method specifically includes the following steps: Step S201: Receive the locking instruction information sent by the host through the data bus. The locking instruction information includes a locking instruction code and a first time coefficient. The locking instruction information is sent by the host when it determines that a locking operation needs to be triggered.

[0037] Step S202: Determine the target mapping relationship from the set of mapping relationships according to the locking instruction code.

[0038] The mapping set can be multiple pre-stored conversion rules between the first time coefficient and the lock duration within the slave device. Each mapping relationship corresponds to a different operational logic, and different lock command codes correspond to different mapping rules. The target mapping relationship can be a set of conversion rules that matches the current lock command code and is actually used in this operation. It is the direct basis for converting the first time coefficient into the lock duration. Optionally, the master and slave devices can pre-agree on a set of basic functions, the index of which can be determined by the lock command code. For example, if the function index is F8, its corresponding basic function could be... Its unit of time can be 0.1ms. For example, if the function index is F5, its corresponding base function could be... Its unit of time can be 0.15ms. Of course, there can be other basic functions for computational logic, which are not limited in this application.

[0039] In one embodiment, the method of determining the target mapping relationship from the set of mapping relationships based on the locking instruction code may be to extract the lower four bits of data from the locking instruction code and use the lower four bits of data as a mapping relationship index to obtain the target mapping relationship it points to from the set of mapping relationships.

[0040] In one embodiment, a specific implementation process for determining a target mapping relationship from a set of mapping relationships based on a locking instruction code is described. Please refer to [reference needed]. Figure 3 This is a flowchart illustrating the specific implementation process of determining the target mapping relationship from the set of mapping relationships based on the locking instruction code, as provided in the embodiments of this application. Figure 3 As shown, the specific implementation steps for determining the target mapping relationship from the set of mapping relationships based on the locking instruction code are as follows: Step S301: Perform bitwise operations on the lock instruction code and the preset bit mask to obtain the first bit data.

[0041] The preset bit mask can be a binary constant where specific bits are 1 and the rest are 0, used to extract bit segments at specified positions in the lock instruction code. For example, the preset bit mask can be used to extract odd-numbered bits from the lock instruction code. Or, for example, it can be used to extract even-numbered bits. Bitwise operations can be bitwise AND operations, using the mask to mask irrelevant bits in the instruction code, retaining only the valid bits at the specified positions. The first bit data can be a numerical value composed of local bit segments of the lock instruction code. This first bit data can be used directly as a lookup index for the mapping relationship, or as intermediate data for generating subsequent lookup indexes.

[0042] Step S302: Perform a first mapping process on the first bit data to obtain the query index data.

[0043] The first mapping process can be to convert the extracted intermediate data used to generate the query index into index values ​​suitable for table entry addressing. In one embodiment, the method of obtaining query index data by performing the first mapping process on the first bit data can be to add a preset base address offset to the first bit data to directly generate the query index data with the mapping relationship. In another embodiment, the method of obtaining query index data by performing the first mapping process on the first bit data can be to look up the query index data in a table using the first bit data as input.

[0044] Step S303: Obtain the target mapping relationship pointed to by the query index data from the set mapping relationship set.

[0045] The query index data and the mapping relationship are in a one-to-one correspondence. Therefore, the query index data can uniquely determine its corresponding target mapping relationship.

[0046] As can be seen from steps S301-S303 above, through the two-stage processing of bit extraction and secondary mapping, the addressing basis of the mapping relationship is extracted from the locking instruction code, improving the information utilization rate of the locking instruction code without increasing its transmission length. Furthermore, the two-stage conversion mechanism decouples the original value of the locking instruction code from the mapping relationship, significantly increasing the difficulty for attackers to reverse-engineer the mapping logic.

[0047] Step S203: Calculate the locking duration by using the first time coefficient according to the target mapping relationship.

[0048] If the target mapping relationship follows a table lookup rule, the pre-stored duration value table is read using the first time coefficient as the address offset to obtain the lock duration. If the target mapping relationship involves function operation, the first time coefficient is substituted into the relevant function for calculation to obtain the lock duration. For example, if the slave device receives a lock instruction code 0xFA and a first time coefficient of 0x0032, its lower four bits 0xA can be used as a lookup index to locate the underlying function. Substituting the first time coefficient 0x0032 into the calculation, the lock duration can be obtained.

[0049] Step S204: Drive the data bus to maintain the second level state based on the lock duration to suspend data transmission on the data bus.

[0050] Step S205: After the lock duration ends, stop driving the data bus and restore the data bus to the first level state to resume data transmission.

[0051] As can be seen from the above steps S201-S205, by configuring multiple sets of mapping relationships in a set manner, the locking instruction code is used as the basis for selecting the mapping relationship. This makes the locking duration depend not only on the first time coefficient, but also on the locking instruction code itself. This makes it impossible for attackers to accurately calculate the locking duration without knowing the mapping relationship, even if they obtain the first time coefficient. This increases the difficulty of reverse engineering for attackers.

[0052] Figure 4 A flowchart illustrating a master-slave communication method that includes a specific implementation process for verifying and locking instruction codes, as provided in this application embodiment, is shown below. Figure 4 As shown, the master-slave communication method specifically includes the following steps: Step S401: Receive the locking instruction information sent by the host through the data bus. The locking instruction information includes a locking instruction code and a first time coefficient. The locking instruction information is sent by the host when it determines that a locking operation needs to be triggered.

[0053] Step S402: Compare the lock command code with the preset command code range.

[0054] Step S403: If the lock command code is not within the preset command code range, send an abnormal command response message to the host.

[0055] The preset instruction code range can be a pre-defined range of valid locking instruction codes within the slave device. For example, referring to the aforementioned embodiment, taking the black consumable chip as an example, its preset instruction code range is 0xF0~0xF3. Only locking instruction codes falling within this range will be considered valid locking instructions. If the locking instruction code is not within the preset instruction code range, then for the current slave device, the locking instruction is an invalid instruction and does not need to be executed. An instruction exception response information is then sent back to the master device. The instruction exception response information can be a response indicating that the current locking instruction is invalid.

[0056] Step S404: If the locking command code is within the preset command code range, the first time coefficient is converted based on the locking command code to obtain the locking duration.

[0057] If the lock command code is within the preset command code range, then for the current slave device, the lock command is a valid command and needs to be executed.

[0058] Step S405: Drive the data bus to maintain the second level state based on the lock duration to suspend data transmission on the data bus.

[0059] Step S406: After the lock duration ends, stop driving the data bus and restore the data bus to the first level state to resume data transmission.

[0060] As can be seen from steps S401-S406 above, a pre-entry threshold is set for bus locking operations through a verification mechanism based on a preset instruction code range, which can directly filter illegal instructions and replay attacks across slave devices; different slave devices are configured with exclusive legal instruction code ranges, so that replay instructions recorded for a single slave device cannot be effective on other slave devices, thereby improving the overall security of multi-slave systems.

[0061] Figure 5 This is a flowchart of another master-slave communication method provided in an embodiment of this application. This master-slave communication method is applied to a master unit, which is connected to the same data bus as multiple slave units. The data bus is in a first-level state when the slave units are not communicating with the master unit. Figure 5 As shown, the master-slave communication method specifically includes the following steps: Step S501: Obtain the slave address corresponding to each slave device currently connected to the data bus.

[0062] The slave address can be coded information on the data bus used to uniquely identify each slave. The master specifies the slave via address lookup, and only slaves with matching addresses will respond to master commands. The master can scan the bus to send addressing commands to all possible addresses sequentially, determine whether a slave exists at the corresponding address based on whether a response is received, and collect all responding addresses to obtain a list of online slave addresses.

[0063] Step S502: Assign each slave device its corresponding locking instruction code and first time coefficient, wherein the locking instruction code and / or first time coefficient are different for different slave devices.

[0064] The host can independently configure a unique locking command code and a first time coefficient for each slave device according to a preset parameter library. The parameters of different slave devices are different, thus achieving differentiated security configuration.

[0065] In one embodiment, the specific implementation process of assigning the corresponding locking instruction code and first time coefficient to each slave device is as follows: The preset locking command code encoding range is divided into multiple command code sub-ranges, and each command code sub-range corresponds to a slave device; Select the corresponding lock instruction code from the instruction code range corresponding to each slave device; The first time coefficient corresponding to each slave device is determined based on its security level.

[0066] The lock command code range can be a pre-defined total range of codes that can be used to identify lock commands, for example, 0xF0~0xFF. The command code sub-range can be a subset of codes extracted from the lock command code range and specific to a single slave device; the command code sub-ranges of different slave devices do not overlap. Optionally, the preset lock command code range can be divided into multiple command code sub-ranges by dividing it evenly according to the number of slave devices. For example, if the lock command code range is 0xF0~0xFF and there are 4 slave devices, then there are 4 sub-ranges: 0xF0~0xF3, 0xF4~0xF7, 0xF8~0xFB, and 0xFC~0xFF. Each time a lock command is issued to a specific slave device, a lock command code can be selected from its corresponding command code sub-range for issuance. Optionally, a random selection method can be used, where the host randomly selects an encoding value from the corresponding instruction code range as the locking instruction code for this time, changing the encoding code for each locking process. Optionally, a polling selection method can be used, where the host sequentially selects various encoding values ​​from the instruction code range according to a preset order, using the locking instruction code in a cyclical manner. Additionally, the security level of the slave device can be pre-defined according to the importance and protection requirements of the slave device. For example, in a printing scenario, the ink cartridge chip has a higher security level, while the acquisition chip in normal state has a lower security level. For slave devices with higher security levels, their first time coefficient should be configured to be larger, the locking duration longer, and the protection strength higher. Optionally, the method for determining the corresponding first time coefficient based on the security level of each slave device can be based on a pre-set correspondence between security levels and coefficient ranges. The corresponding coefficient range is retrieved from this correspondence according to the security level of each slave device, and a specific value is randomly selected from this coefficient range as the first time coefficient. Here, a higher security level corresponds to a first time coefficient with a larger value range, and a lower security level corresponds to a first time coefficient with a smaller value range.

[0067] Step S503: Generate locking instruction information based on the slave address corresponding to the target slave, the locking instruction code corresponding to the target slave, and the first time coefficient corresponding to the target slave in each slave device; The target slave device can be the addressing object of this lock command, that is, the specific slave device that the master needs to trigger the bus lock operation. The master assembles the target slave device address, lock command code, first time coefficient and other fields into a complete protocol data frame according to the agreed frame format to obtain the lock command information.

[0068] Step S504: Send a lock command message to the target slave device via the data bus; Step S505: While the target slave device is driving the data bus to maintain the second level state based on the lock command information, pause the transmission of data through the data bus.

[0069] Optionally, the master-slave communication method also includes: Upon receiving bus exception information from the target slave device, the system suspends sending commands via the data bus and records the exception event.

[0070] Before the lockout duration ends, the slave device monitors the real-time level signal of the data bus. If the real-time level signal of the data bus is inconsistent with the second level state, the slave device sets the safety register to an error state and sends a bus abnormality message back to the master device. When the master device receives the bus abnormality message from the target slave device, it can be considered that the data bus has entered an abnormal level state. The master device needs to suspend the transmission of commands through the data bus to prevent the abnormality from continuing and record the abnormal event to provide traceable evidence for subsequent troubleshooting.

[0071] Optionally, the master-slave communication method also includes: After determining that the target slave has completed the bus locking operation, the next instruction is sent to the target slave through the data bus. The completion of the bus locking operation means that the locking duration ends and the data bus returns to the first level state.

[0072] In this process, after the lock duration ends, the slave device stops driving the data bus, restoring it to the first voltage level to resume data transmission. The master device determines whether the target slave device has completed the bus lock operation by detecting whether the data bus has returned to the first voltage level. After confirming that the target slave device has completed the bus lock operation, the master device can send the next instruction to the target slave device through the data bus. This next instruction can be a subsequent business instruction, representing a continuation of the normal communication process.

[0073] The following provides a detailed implementation process of the master-slave communication method provided in this application for a master-slave application in a printing scenario: Specifically, the master unit is a printing device, and the multiple slave units connected to the data bus are four ink cartridge chips: black, cyan, magenta, and yellow. The printing device verifies each ink cartridge chip sequentially. First, the printing device sends a lock command message containing instruction code 0xF1 and first time coefficient 0x0064 to the black ink cartridge chip. The black ink cartridge chip processes instruction code 0xF1 and first time coefficient 0x0064 according to its built-in mapping relationship to obtain a lock duration of 10ms, and its lock data bus is no less than 10ms. Subsequently, the printing device sends a lock command message containing instruction code 0xF6 and first time coefficient 0x00C8 to the cyan ink cartridge chip. The cyan ink cartridge chip processes instruction code 0xF6 and first time coefficient 0x00C8 according to its built-in mapping relationship to obtain a lock duration of 20ms, and its lock data bus is no less than 20ms. It should be noted that different ink cartridge chips use different mapping relationships. Even if an attacker records a locking command for the black ink cartridge chip and replays it to the cyan ink cartridge chip, the cyan ink cartridge chip will either refuse to execute because the locking command code is not within its valid range (for example, 0xF1 is not within the range of 0xF4-0xF7), or it will calculate the wrong duration, causing the attack timing to not match the printing device's expectations, thus being identified as an illegal device by the printing device.

[0074] As can be seen from steps S501-S503 above, the host side achieves individualized security configuration in multi-slave scenarios by assigning differentiated locking instruction codes and first time coefficients to different slave devices, thus avoiding the failure of the entire system's protection due to the leakage of a single parameter. Furthermore, by actively controlling the bus level by the slave devices, the transmission timing of replay attacks is disrupted, reducing hardware costs and computing power overhead, improving bus communication security while also meeting the low-cost mass production requirements of the slave devices.

[0075] Figure 6 This is a structural block diagram of a master-slave communication device provided in an embodiment of this application. The device is configured to execute the master-slave communication method provided in the above embodiment, and possesses the corresponding functional modules and beneficial effects of the method. It should be noted that the master-slave communication device, as a slave device, accesses the data bus. When no communication is being performed, the data bus is in a first-level state, such as... Figure 6 As shown, the master-slave communication device specifically includes: The transceiver module 601 is configured to receive locking instruction information sent by the host through the data bus. The locking instruction information includes a locking instruction code and a first time coefficient. The locking instruction information is sent by the host when it determines that a locking operation needs to be triggered. Processing module 602 is configured to convert the first time coefficient based on the locking instruction code to obtain the locking duration; The drive module 603 is configured to drive the data bus to maintain a second level state based on the lock duration to suspend data transmission of the data bus; after the lock duration ends, it stops driving the data bus and restores the data bus to a first level state to resume data transmission of the data bus.

[0076] The above-described method, by actively controlling the bus level, directly blocks the effective transmission of replay attacks at the physical timing level, without relying on a high-performance random number generation module and synchronization clock unit. The first time coefficient dynamically issued by the host, combined with the locking instruction code, participates in the calculation, making the silent window for each communication variable, significantly increasing the difficulty for attackers to predict and circumvent the locking period. The overall solution has low hardware implementation costs and can be adapted to resource-constrained slave devices such as those with limited consumable chips. This solution can disrupt the transmission timing of replay attacks by actively controlling the bus level, reducing hardware costs and computing power overhead, improving bus communication security while also meeting the low-cost mass production requirements of slave devices.

[0077] In one possible embodiment, the processing module 602 is specifically configured as follows: The target mapping relationship is determined from the set of mapping relationships based on the lock command code; The lock duration is obtained by calculating the first time coefficient according to the target mapping relationship.

[0078] In one possible embodiment, the processing module 602 is further configured as follows: The first bit data is obtained by performing bitwise operations on the lock instruction code and the preset bit mask. The first bit of data is processed by the first mapping to obtain the query index data; Retrieve the target mapping relationship pointed to by the query index data from the set of mapping relationships.

[0079] In one possible embodiment, the processing module 602 is further configured as follows: The time weighting factor is obtained by performing a second mapping process on the lock instruction code; The time weighting factor is integrated with the first time coefficient to obtain the locked duration.

[0080] In one possible embodiment, a comparison module is also included, configured as follows: The lock command code is compared with the preset command code range. If the lock command code is not within the preset command code range, the host is fed back command exception response information. The processing module 602 is further configured as follows: If the locking command code is within the preset command code range, the locking duration is obtained by converting the first time coefficient based on the locking command code.

[0081] In one possible embodiment, a monitoring module is also included, configured to: Monitor the real-time level signal of the data bus before the lock duration ends; If the real-time level signal of the data bus is found to be inconsistent with the second level state, the safety register is set to the error state and the bus abnormality information is fed back to the host.

[0082] In one possible embodiment, the driver module 603 is specifically configured as follows: If the lock duration is less than or equal to the set maximum lock duration, the data bus is driven to maintain the second level state according to the lock duration. If the lock duration is greater than the maximum lock duration, the data bus is driven to maintain the second level state according to the maximum lock duration.

[0083] In one possible embodiment, the driver module 603 is specifically configured as follows: The target locking duration is obtained by adding the locking duration to the set second time coefficient; The data bus is driven to maintain a second-level state according to the target lock duration.

[0084] In one possible embodiment, the locking instruction information further includes verification information, which is used to verify the integrity of the locking instruction code and the first time coefficient. The transceiver module 601 is specifically configured to perform integrity verification on the lock command code and the first time coefficient based on the verification information. If the verification passes, it performs the step of converting the first time coefficient based on the lock command code to obtain the lock duration.

[0085] Figure 7 This is a structural block diagram of another master-slave communication device provided in an embodiment of this application. This device is configured to execute the master-slave communication method provided in the above embodiments, and possesses the corresponding functional modules and beneficial effects of the method. It should be noted that the master-slave communication device acts as a master connected to the data bus, and multiple slave devices are connected to the data bus, such as... Figure 7 As shown, the master-slave communication device specifically includes: The acquisition module 701 is configured to acquire the slave addresses corresponding to each slave device currently connected to the data bus; The allocation module 702 is configured to allocate a corresponding locking instruction code and a first time coefficient to each slave device, wherein the locking instruction code and / or the first time coefficient are different for different slave devices; The transmitting module 703 is configured to generate locking instruction information based on the slave address corresponding to the target slave, the locking instruction code corresponding to the target slave, and the first time coefficient corresponding to the target slave, and to send the locking instruction information to the target slave through the data bus; while the target slave drives the data bus to maintain the second level state based on the locking instruction information, it suspends the transmission of data through the data bus.

[0086] As described above, the host side achieves individualized security configuration in multi-slave scenarios by assigning differentiated locking command codes and first time coefficients to different slave devices, avoiding system-wide protection failure due to the leakage of a single parameter. Furthermore, by actively controlling the bus level by the slave devices, the transmission timing of replay attacks is disrupted, reducing hardware costs and computing power overhead, improving bus communication security while also meeting the low-cost mass production requirements of the slave devices.

[0087] In one possible embodiment, the allocation module 702 is specifically configured as follows: The preset locking command code encoding range is divided into multiple command code sub-ranges, and each command code sub-range corresponds to a slave device; Select the corresponding lock instruction code from the instruction code range corresponding to each slave device; The first time coefficient corresponding to each slave device is determined based on its security level.

[0088] In one possible embodiment, an exception handling module is also included, configured as follows: Upon receiving bus exception information from the target slave device, the system suspends sending commands via the data bus and records the exception event.

[0089] In one possible embodiment, a communication recovery module is also included, configured to: After determining that the target slave has completed the bus locking operation, the next instruction is sent to the target slave through the data bus. The completion of the bus locking operation means that the locking duration ends and the data bus returns to the first level state.

[0090] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 8 As shown, the device includes a processor 801, a memory 802, an input device 803, and an output device 804; the number of processors 801 in the device can be one or more. Figure 8 Taking a processor 801 as an example; the processor 801, memory 802, input device 803, and output device 804 in the device can be connected via a bus or other means. Figure 8Taking a bus connection as an example, the memory 802, as a computer-readable storage medium, can be configured to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the master-slave communication method in this embodiment. The processor 801 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 802, thereby realizing the aforementioned master-slave communication method. The input device 803 can be configured to receive input digital or character information and generate key signal inputs related to user settings and function control of the device. The output device 804 may include a display screen or other display device.

[0091] The electronic device provided above can be used to execute the master-slave communication method provided in any of the above embodiments, and has corresponding functions and beneficial effects.

[0092] This application also provides a non-volatile storage medium containing computer-executable instructions. When executed by a computer processor, the computer-executable instructions are configured to perform a master-slave communication method described in the above embodiments, comprising: receiving locking instruction information sent by a master through a data bus, wherein the locking instruction information includes a locking instruction code and a first time coefficient, and the locking instruction information is sent when the master determines that a locking operation needs to be triggered; converting the first time coefficient based on the locking instruction code to obtain a locking duration, and driving the data bus to maintain a second level state based on the locking duration to suspend data transmission on the data bus; after the locking duration ends, stopping the driving of the data bus, causing the data bus to return to the first level state, to resume data transmission on the data bus. Alternatively, obtain the slave addresses corresponding to each slave currently connected to the data bus; assign a corresponding lock command code and a first time coefficient to each slave, wherein the lock command code and / or first time coefficient are different for different slaves; generate lock command information based on the slave address, lock command code, and first time coefficient of the target slave among the slaves; send the lock command information to the target slave through the data bus; and suspend data transmission through the data bus while the target slave drives the data bus to maintain a second level state based on the lock command information.

[0093] Storage medium – any type of memory device or storage device. The term “storage medium” is intended to include: mounting media, such as CD-ROM, floppy disk, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media, or optical storage; registers or other similar types of memory elements, etc. Storage medium may also include other types of memory or combinations thereof. Furthermore, storage medium may reside in a first computer system in which the program is executed, or it may reside in a different second computer system connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term “storage medium” may include two or more storage media residing in different locations (e.g., in different computer systems connected via a network). Storage medium may store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.

[0094] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the master-slave communication method described above, but can also execute related operations in the master-slave communication method provided in any embodiment of this application.

[0095] It is worth noting that in the above-described master-slave communication device embodiments, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not configured to limit the protection scope of the embodiments of this application.

[0096] It should be noted that the numbering of each step in this solution is only used to describe the overall design framework of this solution and does not indicate a necessary sequential relationship between the steps. As long as the overall implementation process conforms to the overall design framework of this solution, it falls within the protection scope of this solution. The order of the text in the description is not an exclusive limitation on the specific implementation process of this solution. Those skilled in the art should understand that the embodiments of this application can be provided as methods, systems, or computer program products. In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory. Memory may include non-persistent memory in computer-readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0097] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0098] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A master-slave communication method, characterized in that, Applied to a slave device, wherein the slave device and the master device are respectively connected to the same data bus, and the data bus is in a first-level state when the slave device and the master device are not communicating, the master-slave communication method includes: The system receives a locking instruction message sent by the host through the data bus. The locking instruction message includes a locking instruction code and a first time coefficient. The locking instruction message is sent by the host when it determines that a locking operation needs to be triggered. The first time coefficient is converted based on the locking instruction code to obtain the locking duration, and the data bus is driven to maintain a second level state based on the locking duration to suspend the data transmission of the data bus; After the lock duration ends, the data bus is stopped from being driven, and the data bus is restored to the first level state to resume data transmission.

2. The master-slave communication method according to claim 1, characterized in that, The step of converting the first time coefficient based on the locking instruction code to obtain the locking duration includes: The target mapping relationship is determined from the set of mapping relationships based on the locking instruction code; The lock duration is obtained by calculating the first time coefficient according to the target mapping relationship.

3. The master-slave communication method according to claim 2, characterized in that, Determining the target mapping relationship from the set of mapping relationships based on the locking instruction code includes: The first bit data is obtained by performing bit operations on the locking instruction code and the preset bit mask. The first bit data is processed by a first mapping to obtain the query index data; Retrieve the target mapping relationship pointed to by the query index data from the set of mapping relationships.

4. The master-slave communication method according to claim 1, characterized in that, The step of converting the first time coefficient based on the locking instruction code to obtain the locking duration includes: The time weighting factor is obtained by performing a second mapping process on the locking instruction code; The time weighting factor is integrated with the first time coefficient to obtain the locked duration.

5. The master-slave communication method according to claim 1, characterized in that, Before converting the first time coefficient based on the locking instruction code to obtain the locking duration, the method further includes: The locking command code is compared with a preset command code range. If the locking command code is not within the preset command code range, an abnormal command response information is sent back to the host. The step of converting the first time coefficient based on the locking instruction code to obtain the locking duration includes: When the locking command code is within the range of the preset command code, the first time coefficient is converted based on the locking command code to obtain the locking duration.

6. The master-slave communication method according to claim 1, characterized in that, After converting the first time coefficient based on the locking instruction code to obtain the locking duration, the method further includes: Before the lock duration ends, monitor the real-time level signal of the data bus; If the real-time level signal of the data bus is found to be inconsistent with the second level state, the security register is set to an error state, and bus abnormality information is fed back to the host.

7. The master-slave communication method according to claim 1, characterized in that, The step of driving the data bus to maintain a second-level state based on the lock duration includes: If the lock duration is less than or equal to the set maximum lock duration, the data bus is driven to maintain the second level state according to the lock duration. If the lock duration is greater than the maximum lock duration, the data bus is driven to maintain the second level state according to the maximum lock duration.

8. The master-slave communication method according to claim 1, characterized in that, The step of driving the data bus to maintain a second-level state based on the lock duration includes: The target locking duration is obtained by adding the locking duration to the set second time coefficient; The data bus is driven to maintain a second-level state according to the target lock duration.

9. The master-slave communication method according to any one of claims 1 to 8, characterized in that, The locking instruction information also includes verification information, which is used to verify the integrity of the locking instruction code and the first time coefficient; The step of receiving the locking instruction information sent by the host through the data bus includes: Based on the verification information, the integrity of the locking instruction code and the first time coefficient is verified. If the verification passes, the step of converting the first time coefficient based on the locking instruction code to obtain the locking duration is executed.

10. A master-slave communication method, characterized in that, Applied to a host, wherein the host and multiple slave devices are respectively connected to the same data bus, and the data bus is in a first-level state when the slave devices are not communicating with the host, the master-slave communication method includes: Obtain the slave address corresponding to each slave currently connected to the data bus; Each slave device is assigned a corresponding locking instruction code and a first time coefficient, wherein the locking instruction code and / or first time coefficient are different for different slave devices; Locking instruction information is generated based on the slave address corresponding to the target slave, the locking instruction code corresponding to the target slave, and the first time coefficient corresponding to the target slave. The locking instruction information is sent to the target slave device via the data bus; While the target slave device drives the data bus to maintain a second level state based on the locking instruction information, data transmission through the data bus is suspended.

11. The master-slave communication method according to claim 10, characterized in that, The process of assigning a corresponding locking instruction code and a first time coefficient to each of the slave devices includes: The preset locking instruction code encoding range is divided into multiple instruction code sub-ranges, and each instruction code sub-range corresponds to one slave device; Select the corresponding locking instruction code from the instruction code range corresponding to each slave device; The first time coefficient corresponding to each slave device is determined based on its security level.

12. The master-slave communication method according to claim 10, characterized in that, The master-slave communication method further includes: Upon receiving bus error information from the target slave device, the transmission of commands via the data bus is paused, and the error event is recorded.

13. The master-slave communication method according to claim 10, characterized in that, The master-slave communication method further includes: After determining that the target slave device has completed the bus locking operation, the next instruction is sent to the target slave device through the data bus. The completion of the bus locking operation means that the locking duration ends and the data bus returns to the first level state.

14. A master-slave communication device, characterized in that, The master-slave communication device serves as a slave device connected to the data bus. When no communication is being performed, the data bus is in a first-level state. The master-slave communication device includes: The transceiver module is configured to receive locking instruction information sent by the host through the data bus. The locking instruction information includes a locking instruction code and a first time coefficient. The locking instruction information is sent by the host when it determines that a locking operation needs to be triggered. The processing module is configured to convert the first time coefficient based on the locking instruction code to obtain the locking duration; The driving module is configured to drive the data bus to maintain a second level state based on the lock duration to suspend data transmission of the data bus; after the lock duration ends, it stops driving the data bus to restore the data bus to the first level state to resume data transmission of the data bus.

15. A master-slave communication device, characterized in that, The master-slave communication device acts as a master connected to the data bus, and multiple slave devices are connected to the data bus. The master-slave communication device includes: The acquisition module is configured to acquire the slave addresses corresponding to each slave device currently connected to the data bus; The allocation module is configured to allocate a corresponding locking instruction code and a first time coefficient to each of the slave devices, wherein the locking instruction code and / or the first time coefficient are different for different slave devices; The sending module is configured to generate locking instruction information based on the slave address corresponding to the target slave, the locking instruction code corresponding to the target slave, and the first time coefficient corresponding to the target slave; send the locking instruction information to the target slave through the data bus; and pause data transmission through the data bus while the target slave drives the data bus to maintain a second level state based on the locking instruction information.

16. An electronic device, the electronic device comprising: One or more processors; A memory configured to store one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the master-slave communication method according to any one of claims 1-13.

17. A chip, the chip including a communication interface for accessing a data bus, the chip being used to execute the master-slave communication method as described in any one of claims 1-13.

18. A non-volatile storage medium storing computer-executable instructions, which, when executed by a computer processor, are configured to perform the master-slave communication method as described in any one of claims 1-13.