CN114338530A - Method and device for adjusting equipment state, storage medium and electronic device - Google Patents

Method and device for adjusting equipment state, storage medium and electronic device Download PDF

Info

Publication number
CN114338530A
CN114338530A CN202111576260.XA CN202111576260A CN114338530A CN 114338530 A CN114338530 A CN 114338530A CN 202111576260 A CN202111576260 A CN 202111576260A CN 114338530 A CN114338530 A CN 114338530A
Authority
CN
China
Prior art keywords
state value
target
target port
value
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111576260.XA
Other languages
Chinese (zh)
Other versions
CN114338530B (en
Inventor
余成林
胡绍江
高松全
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Huaruijie Technology Co ltd
Original Assignee
Zhejiang Huaruijie Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Huaruijie Technology Co ltd filed Critical Zhejiang Huaruijie Technology Co ltd
Priority to CN202111576260.XA priority Critical patent/CN114338530B/en
Publication of CN114338530A publication Critical patent/CN114338530A/en
Application granted granted Critical
Publication of CN114338530B publication Critical patent/CN114338530B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Communication Control (AREA)

Abstract

The embodiment of the invention provides a method and a device for adjusting equipment states, a storage medium and an electronic device, wherein the method comprises the following steps: acquiring a state value of a first target port of a sending device and a state value of a second target port of a receiving device; under the condition that the state value of the first target port and the state value of the second target port meet the first preset relationship, determining that the sending equipment is in a first state allowing data to be sent to the receiving equipment; and under the condition that the sending equipment is determined to send the target data to the receiving equipment, adjusting the state value of the first target port to enable the state value of the first target port and the state value of the second target port to meet a second preset relation, and enabling the sending equipment to be in a second state which does not allow the sending equipment to send the data to the receiving equipment. According to the invention, the problem of poor equipment interaction reliability caused by untimely equipment state adjustment in the related technology is solved, and the effect of improving the equipment interaction reliability is achieved.

Description

Method and device for adjusting equipment state, storage medium and electronic device
Technical Field
The embodiment of the invention relates to the technical field of electronics, in particular to a method and a device for adjusting equipment states, a storage medium and an electronic device.
Background
In the application of electronic technology, various communication bus technologies such as SPI, UART, I2C are generally adopted for data interaction between functional modules, and in the following, by taking SPI as an example, when a bus with a flow control-free mechanism such as SPI is used, if the amount of data sent by a sender exceeds the processing capacity of a receiver, Buffer overflow of the receiver Buffer is caused, and communication data loss is caused, which seriously affects the reliability of communication. At this time, a handshake mechanism is needed to ensure that the receiver can reliably receive the data sent by the sender, thereby ensuring the reliability of communication. In the related technology, a slave drives two IO interfaces to indicate whether the slave can receive data or not to a host according to the state of receiving the Buffer by the slave, but in the method, the slave cannot know the state of the host, and only can inquire the state of the Buffer by a certain timing mechanism to drive the IO interfaces, so that the Buffer of the slave is full, the slave cannot know the state of the slave in time without inquiring the slave, and the data sent by the host is lost, namely, the problem of poor interactive reliability caused by untimely adjustment of the equipment state exists in the related technology.
Aiming at the problem of poor reliability of equipment interaction caused by untimely equipment state adjustment in the related technology, an effective solution is not provided at present.
Disclosure of Invention
The embodiment of the invention provides a method and a device for adjusting equipment states, a storage medium and an electronic device, which are used for at least solving the problem of poor reliability of equipment interaction caused by untimely equipment state adjustment in the related art.
According to an embodiment of the present invention, there is provided a method for adjusting a device status, including: acquiring a state value of a first target port of a sending device and a state value of a second target port of a receiving device, wherein the sending device is used for sending data to the receiving device; under the condition that the state value of the first target port and the state value of the second target port are determined to meet a first preset relation, determining that the sending equipment is in a first state allowing data to be sent to the receiving equipment; and under the condition that the sending device is determined to send the target data to the receiving device, adjusting the state value of the first target port so that the state value of the first target port and the state value of the second target port meet a second preset relationship, wherein under the condition that the state value of the first target port and the state value of the second target port meet the second preset relationship, the sending device is in a second state that the sending device is not allowed to send the data to the receiving device.
In one exemplary embodiment, before obtaining the state value of the first target port of the sending device and the state value of the second target port of the receiving device, the method further comprises: performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the first target port to a first target value, and sending the first target value to the receiving device, so that the receiving device sets the state value of the second target port to a second target value based on the first target value, wherein the first target value and the second target value satisfy the first preset relationship.
In one exemplary embodiment, after adjusting the state value of the first target port, the method further comprises: executing a predetermined detection operation to determine a state value of a first target flag bit, wherein the state value of the first target flag bit is used for indicating whether the sending equipment is abnormal or not; and executing predetermined processing under the condition that the state value of the first target zone bit is determined to be a first preset value.
In one exemplary embodiment, performing the predetermined detection operation to determine the state value of the first target flag bit comprises: obtaining the state value of the current first target port and the state value of the previous first target port, and obtaining the state value of the current second target port and the state value of the previous second target port, wherein the current state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device finishes sending the target data at the current time, the current state value of the second target port is the state value of the second target port after the sending device finishes sending the target data at the current time, the previous state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device has sent data to the receiving device for the previous time, the previous state value of the second target port is the state value of the second target port after the sending device sends data to the receiving device for the previous time; comparing the state value of the current first target port with the state value of the previous first target port to obtain a first comparison result, and comparing the state value of the current second target port with the state value of the previous second target port to obtain a second comparison result; and determining the state value of the first target flag bit as the first preset value under the condition that the first comparison result indicates that the state value of the current first target port is the same as the state value of the previous first target port, and/or determining the second comparison result indicates that the state value of the current second target port is the same as the state value of the previous second target port.
In one exemplary embodiment, performing the predetermined detection operation to determine the state value of the first target flag bit comprises: acquiring a state value of a first target port before adjustment and a state value of the first target port after adjustment, wherein the state value of the first target port before adjustment is the state value of the first target port before the sending device sends the target data, and the state value of the first target port after adjustment is the state value of the first target port after the sending device sends the target data; comparing the state value of the first target port before adjustment with the state value of the first target port after adjustment to obtain a third comparison result; and determining the state value of the first target zone bit as the first preset value under the condition that the third comparison result indicates that the state value of the first target port before adjustment is the same as the state value of the first target port after adjustment.
In one exemplary embodiment, performing the predetermined process includes: performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the first target port to a first target value, and sending the first target value to the receiving device, so that the receiving device sets the state value of the second target port to a second target value based on the first target value, wherein the first target value and the second target value satisfy the first preset relationship.
In one exemplary embodiment, determining that the sending device is in a first state that allows data to be sent to the receiving device comprises: determining that the transmitting device is in the first state under the condition that the state value of the first target port is determined to be the same as the state value of the second target port; adjusting the state value of the first target port comprises: and adjusting the state value of the first target port to a value different from the state value of the second target port.
In one exemplary embodiment, determining that the sending device is in a first state that allows data to be sent to the receiving device comprises: determining that the transmitting device is in the first state if it is determined that the state value of the first destination port and the state value of the second destination port are different; adjusting the state value of the first target port comprises: and adjusting the state value of the first target port to be the same value as the state value of the second target port.
According to another embodiment of the present invention, there is also provided a method for adjusting a device status, including: acquiring a state value of a first target port of a sending device and a state value of a second target port of a receiving device, wherein the receiving device is used for receiving data sent by the sending device; determining that the receiving device is in a third state allowing the receiving device to receive data transmitted by the transmitting device, in a case where it is determined that the state value of the first target port and the state value of the second target port satisfy a first preset relationship; determining that the receiving device is in a fourth state not allowing reception of the data transmitted by the transmitting device in a case where it is determined that the target data transmitted by the transmitting device is received; and under the condition that the target data is determined to be taken out of the target buffer included in the receiving equipment, adjusting the state value of the second target port so that the state value of the second target port and the state value of the first target port meet the first preset relation.
In one exemplary embodiment, before obtaining the state value of the first target port of the sending device and the state value of the second target port of the receiving device, the method further comprises: performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the second target port to a second target value so that the second target value and the first target value satisfy the first preset relationship, wherein the first target value is the state value of the first target port after the sending device performs an initialization operation.
In one exemplary embodiment, after adjusting the state value of the second target port, the method further comprises: performing a predetermined detection operation to determine a state value of a second target flag, wherein the state value of the second target flag is used for indicating whether the receiving device is abnormal or not; and executing predetermined processing under the condition that the state value of the second target zone bit is determined to be a first preset value.
In one exemplary embodiment, performing the predetermined detection operation to determine the state value of the second target flag bit includes: obtaining the state value of the current first target port and the state value of the previous first target port, and obtaining the state value of the current second target port and the state value of the previous second target port, wherein the current state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device finishes sending the target data at the current time, the current state value of the second target port is the state value of the second target port after the sending device finishes sending the target data at the current time, the previous state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device has sent data to the receiving device for the previous time, the previous state value of the second target port is the state value of the second target port after the sending device sends data to the receiving device for the previous time; comparing the state value of the current first target port with the state value of the previous first target port to obtain a first comparison result, and comparing the state value of the current second target port with the state value of the previous second target port to obtain a second comparison result; and determining the state value of the second target flag bit as the first preset value under the condition that the first comparison result indicates that the state value of the current first target port is the same as the state value of the previous first target port, and/or determining the second comparison result indicates that the state value of the current second target port is the same as the state value of the previous second target port.
In one exemplary embodiment, performing the predetermined detection operation to determine the state value of the second target flag bit includes: acquiring a state value of a second target port before adjustment and a state value of the second target port after adjustment, wherein the state value of the second target port before adjustment is the state value of the second target port before the receiving device determines that the target data is taken out from the target buffer, and the state value of the second target port after adjustment is the state value of the second target port after the receiving device determines that the target data is taken out from the target buffer; comparing the state value of the first target port before adjustment with the state value of the first target port after adjustment to obtain a third comparison result; and determining the state value of the second target zone bit as the first preset value under the condition that the third comparison result indicates that the state value of the second target port before the adjustment is the same as the state value of the second target port after the adjustment.
In one exemplary embodiment, performing the predetermined detection operation to determine the state value of the second target flag bit includes: detecting whether the state of the target buffer, the state value of the first target port and the state value of the second target port meet preset conditions according to a preset period to obtain a detection result; and determining the state value of the second target zone bit as the first preset value under the condition that the detection result indicates that the preset condition is not met among the state of the target buffer, the state value of the first target port and the state value of the second target port.
In one exemplary embodiment, performing the predetermined process includes: performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the second target port to a second target value so that the second target value and the first target value satisfy the first preset relationship, wherein the first target value is the state value of the first target port after the sending device performs an initialization operation.
In one exemplary embodiment, determining that the receiving device is in a third state that allows receiving data transmitted by the transmitting device comprises: determining that the receiving device is in the third state if it is determined that the state value of the second destination port is the same as the state value of the first destination port; adjusting the state value of the second target port comprises: and adjusting the state value of the second target port to be the same value as the state value of the first target port.
In one exemplary embodiment, determining that the receiving device is in a third state that allows receiving data transmitted by the transmitting device comprises: determining that the receiving device is in the third state if it is determined that the state value of the second destination port and the state value of the first destination port are different; adjusting the state value of the second target port comprises: and adjusting the state value of the second target port to a value different from the state value of the first target port.
According to another embodiment of the present invention, there is also provided an apparatus for adjusting a device status, including: a first obtaining module, configured to obtain a state value of a first target port of a sending device and a state value of a second target port of a receiving device, where the sending device is configured to send data to the receiving device; a first determining module, configured to determine that the sending device is in a first state in which data is allowed to be sent to the receiving device when it is determined that the state value of the first target port and the state value of the second target port satisfy a first preset relationship; a first adjusting module, configured to, when it is determined that the sending device has sent target data to the receiving device, adjust a state value of the first target port, so that the state value of the first target port and the state value of the second target port satisfy a second preset relationship, where, when the state value of the first target port and the state value of the second target port satisfy the second preset relationship, the sending device is in a second state where data transmission to the receiving device is not allowed.
According to another embodiment of the present invention, there is also provided an apparatus for adjusting a device status, including: a second obtaining module, configured to obtain a state value of a first target port of a sending device and a state value of a second target port of a receiving device, where the receiving device is configured to receive data sent by the sending device; a second determining module, configured to determine that the receiving device is in a third state where it is allowed to receive data sent by the sending device when it is determined that the state value of the first target port and the state value of the second target port satisfy a first preset relationship; a third determining module, configured to determine that the receiving device is in a fourth state in which reception of data transmitted by the transmitting device is not allowed, in a case where it is determined that target data transmitted by the transmitting device is received; a second adjusting module, configured to, when it is determined that the target data has been fetched from the target buffer included in the receiving device, adjust the state value of the second target port, so that the state value of the second target port and the state value of the first target port satisfy the first preset relationship.
According to a further embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.
According to yet another embodiment of the present invention, there is also provided an electronic device, including a memory in which a computer program is stored and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.
According to the invention, by acquiring the state value of the first target port of the sending equipment and the state value of the second target port of the receiving equipment, when the state value of the first target port and the state value of the second target port are determined to meet the first preset relation, the sending equipment is determined to be in the first state allowing data to be sent to the receiving equipment, and when the sending equipment finishes sending the target data, the state value of the first target port is adjusted to enable the state value of the first target port and the state value of the second target port to meet the second preset relation, and the sending equipment is in the second state not allowing data to be sent to the receiving equipment. The method and the device achieve the purpose of determining the state of the sending device based on the relationship between the state values of the target ports of the interaction devices and the purpose of adjusting the state value of the target port of the sending device based on the state value of the target port of the receiving device after the sending device finishes sending data, namely, the state value of the first target port is adjusted in time by the sending device after the sending device finishes sending data, so that the sending device is in the second state which does not allow sending data, and the problem that the receiving party cannot adjust the state value of the port in time to cause the loss of the data sent by the sending party in the related art is solved.
Drawings
Fig. 1 is a block diagram of a hardware structure of a mobile terminal according to an embodiment of the present invention;
FIG. 2 is a first flowchart of a method for adjusting the status of a device according to an embodiment of the present invention;
FIG. 3 is a second flowchart of a method for adjusting the status of a device according to an embodiment of the present invention;
fig. 4 is a system architecture diagram of device communication handshaking, in accordance with a specific embodiment of the present invention;
FIG. 5 is a diagram illustrating a device communication handshake method according to an embodiment of the present invention;
FIG. 6 is a diagram of an example communication handshake in accordance with a specific embodiment of the present invention;
FIG. 7 is a timing diagram of a communication handshake mechanism according to a specific embodiment of the present invention;
FIG. 8 is a diagram of an example communication handshake of FIG. two, in accordance with a specific embodiment of the present invention;
FIG. 9 is an exemplary diagram of a communication handshake in accordance with a specific embodiment of the present invention;
FIG. 10 is an exemplary diagram of a communication handshake in accordance with a specific embodiment of the present invention;
FIG. 11 is a diagram of an example of an anomaly detection mechanism according to an embodiment of the present invention;
FIG. 12 is a diagram of an example of an anomaly detection mechanism according to an embodiment of the present invention;
fig. 13 is a first block diagram of an apparatus for adjusting a device status according to an embodiment of the present invention;
fig. 14 is a block diagram of a second configuration of the device state adjustment apparatus according to the embodiment of the present invention.
Detailed Description
Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings in conjunction with the embodiments.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
The method embodiments provided in the embodiments of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking the operation on the mobile terminal as an example, fig. 1 is a hardware structure block diagram of the mobile terminal of the method for adjusting the device status according to the embodiment of the present invention. As shown in fig. 1, the mobile terminal may include one or more (only one shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data, wherein the mobile terminal may further include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration, and does not limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store a computer program, for example, a software program and a module of application software, such as a computer program corresponding to the method for adjusting the device state in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, so as to implement the method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In this embodiment, a method for adjusting a device status is provided, and fig. 2 is a first flowchart of a method for adjusting a device status according to an embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:
step S202, acquiring a state value of a first target port of a sending device and a state value of a second target port of a receiving device, wherein the sending device is used for sending data to the receiving device;
step S204, under the condition that the state value of the first target port and the state value of the second target port are determined to meet a first preset relation, determining that the sending equipment is in a first state allowing data to be sent to the receiving equipment;
step S206, when it is determined that the sending device has sent the target data to the receiving device, adjusting the state value of the first target port so that the state value of the first target port and the state value of the second target port satisfy a second preset relationship, where the sending device is in a second state where the sending device is not allowed to send data to the receiving device when the state value of the first target port and the state value of the second target port satisfy the second preset relationship.
Through the steps, by acquiring the state value of the first target port of the sending device and the state value of the second target port of the receiving device, when the state value of the first target port and the state value of the second target port meet the first preset relationship, the sending device is determined to be in the first state allowing data to be sent to the receiving device, and when the sending device finishes sending the target data, the state value of the first target port is adjusted, so that the state value of the first target port and the state value of the second target port meet the second preset relationship, and the sending device is in the second state not allowing the data to be sent to the receiving device. The method and the device achieve the purpose of determining the state of the sending device based on the relationship between the state values of the target ports of the interaction devices and the purpose of adjusting the state value of the target port of the sending device based on the state value of the target port of the receiving device after the sending device finishes sending data, namely, the state value of the first target port is adjusted in time by the sending device after the sending device finishes sending data, so that the sending device is in the second state which does not allow sending data, and the problem that the receiving party cannot adjust the state value of the port in time to cause the loss of the data sent by the sending party in the related art is solved.
The main body of the above steps may be a device side, for example, the above sending device, or a controller in the sending device, or a processor with human-computer interaction capability configured on a storage device, or a processing device or a processing unit with similar processing capability, and the like, but is not limited thereto. The following description is given by taking the sending device as an example (which is only an exemplary description, and in actual operation, other devices or modules may also perform the above operations):
in the above embodiments, the sending device obtains the state value of the first target port and obtains the state value of the second target port of the receiving device, for example, the first target port is GPIO1, the second target port is GPIO2, and the state values of the ports may include a high level or a low level, and in the case that it is determined that the state values of the first target port and the second target port satisfy a first preset relationship, it is determined that the sending device is in the first state allowing data to be sent to the receiving device, where the first preset relationship may be the same relationship, or an opposite relationship, or a different relationship, for example, when it is determined that the state value of the first target port (such as GPIO1 mentioned above) is the same as the state value of the second target port (such as GPIO2 mentioned above) (e.g., both high level or both low level), it is determined that the sending device is in the first state (such as data sending state), in practical applications, it may also be determined that the sending device is in the first state (e.g., a data-transmittable state) when it is determined that the state value of the first target port (e.g., the GPIO1 mentioned above) and the state value of the second target port (e.g., the GPIO2 mentioned above) are different (or opposite) (e.g., one of the ports is at a high level and the other port is at a low level); in the event that it is determined that the sending device has sent the target data to the receiving device, adjusting a state value of the first target port, so that the state value of the first target port and the state value of the second target port satisfy a second preset relationship, wherein the second predetermined relationship may be an opposite relationship, the same relationship, or a different relationship, such as when the status value of the first destination port is the same as the status value of the second destination port (as if it is high level), the sending device is in the first state (as described above, the data sending state), when the sending device has already sent the target data, the sending device adjusts the state value of the first target port to make the state value of the first target port and the state value of the second target port satisfy different relationships (for example, one of the ports is at a high level, and the other port is at a low level), and at this time, the sending device is in a second state (i.e., a data transmission state is not allowed). According to the embodiment, after the sending equipment finishes sending the data, the sending equipment timely adjusts the state value of the first target port so that the sending equipment is in the second state which does not allow the data to be sent, and the problem that the data sent by the sending party is lost due to the fact that the receiving party cannot timely adjust the state value of the port in the related art is avoided.
In an optional embodiment, before obtaining the state value of the first destination port of the sending device and the state value of the second destination port of the receiving device, the method further includes: performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the first target port to a first target value, and sending the first target value to the receiving device, so that the receiving device sets the state value of the second target port to a second target value based on the first target value, wherein the first target value and the second target value satisfy the first preset relationship. In this embodiment, the sending device may perform an initialization operation first, and in an actual application, the initialization operation may also be performed after receiving an initialization instruction or under a condition that an abnormality occurs, for example, the state value of the first target port is initialized to a first target value (such as a high level or a low level), and in an actual application, the receiving device may also set the state value of the second target port to a second target value (such as a high level or a low level) by obtaining the state value of the first target port of the sending device, where the first preset relationship may be the same relationship, and for example, the first target value and the second target value are both a high level or both low levels; the first preset relationship may be a different relationship, for example, the first target value is a high level, and the second target value is a low level, or the first target value is a low level and the second target value is a high level. By the embodiment, the purpose of initializing the target port is achieved.
In an optional embodiment, after adjusting the state value of the first target port, the method further comprises: executing a predetermined detection operation to determine a state value of a first target flag bit, wherein the state value of the first target flag bit is used for indicating whether the sending equipment is abnormal or not; and executing predetermined processing under the condition that the state value of the first target zone bit is determined to be a first preset value. In this embodiment, the sending device may further perform a predetermined detection operation to determine a status value of the first target flag, where the status value of the first target flag is used to indicate whether the sending device is abnormal, for example, when the sending device has an abnormality, the first target flag is 1 (or 0), at which point the sending device will perform a predetermined process, that is, perform the abnormality process, for example, at which point the initialization operation may be performed again on the sending device. With the present embodiment, the purpose of determining whether the device has an abnormality by detecting the first target flag and executing predetermined processing is achieved.
In an alternative embodiment, performing the predetermined detection operation to determine the state value of the first target flag bit comprises: obtaining the state value of the current first target port and the state value of the previous first target port, and obtaining the state value of the current second target port and the state value of the previous second target port, wherein the current state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device finishes sending the target data at the current time, the current state value of the second target port is the state value of the second target port after the sending device finishes sending the target data at the current time, the previous state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device has sent data to the receiving device for the previous time, the previous state value of the second target port is the state value of the second target port after the sending device sends data to the receiving device for the previous time; comparing the state value of the current first target port with the state value of the previous first target port to obtain a first comparison result, and comparing the state value of the current second target port with the state value of the previous second target port to obtain a second comparison result; and determining the state value of the first target flag bit as the first preset value under the condition that the first comparison result indicates that the state value of the current first target port is the same as the state value of the previous first target port, and/or determining the second comparison result indicates that the state value of the current second target port is the same as the state value of the previous second target port. In this embodiment, the state value of the first target flag bit may be determined by comparing the state values of the first target port (e.g., GPIO1) and the second target port (e.g., GPIO2) when the data is transmitted at the current time with the state values of the first target port (e.g., GPIO1) and the second target port (e.g., GPIO2) when the data is transmitted at the previous time, for example, the state values of the GPIO1 when the data is transmitted at the current time and the state values of the GPIO2 when the data is transmitted at the previous time are the same, for example, when an error or an abnormality is detected, the state value of the first target flag bit is determined to be a first preset value, for example, the first preset value is 1 (or high level), and the first preset value may also be 0 (or low level). Through the embodiment, the purpose of detecting whether the abnormality exists or not by executing the abnormality detection mechanism is achieved, and the effect of further improving the reliability of interaction between the devices is achieved.
In an alternative embodiment, performing the predetermined detection operation to determine the state value of the first target flag bit comprises: acquiring a state value of a first target port before adjustment and a state value of the first target port after adjustment, wherein the state value of the first target port before adjustment is the state value of the first target port before the sending device sends the target data, and the state value of the first target port after adjustment is the state value of the first target port after the sending device sends the target data; comparing the state value of the first target port before adjustment with the state value of the first target port after adjustment to obtain a third comparison result; and determining the state value of the first target zone bit as the first preset value under the condition that the third comparison result indicates that the state value of the first target port before adjustment is the same as the state value of the first target port after adjustment. In this embodiment, the state value of the first target flag may be determined by comparing the state value of the first target port (e.g., GPIO1) before being adjusted with the state value of the first target port (e.g., GPIO1) after being adjusted, for example, when the GPIO1 has the same state value before being adjusted and the GPIO1 after being adjusted, that is, an error or an abnormality is detected, the state value of the first target flag is determined to be a first preset value, for example, the first preset value is 1 (or high level), and the first preset value may also be 0 (or low level). Through the embodiment, the purpose of detecting whether the abnormality exists or not by executing the abnormality detection mechanism is achieved, and the effect of further improving the reliability of interaction between the devices is achieved.
In an alternative embodiment, performing the predetermined process includes: performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the first target port to a first target value, and sending the first target value to the receiving device, so that the receiving device sets the state value of the second target port to a second target value based on the first target value, wherein the first target value and the second target value satisfy the first preset relationship. In this embodiment, the performing the predetermined processing may include performing an initialization operation, for example, initializing the state value of the first target port to a first target value (e.g., a high level or a low level), and in practical applications, the receiving device may also set the state value of the second target port to a second target value (e.g., a high level or a low level) by acquiring the state value of the first target port of the sending device, where the first preset relationship may be the same relationship, for example, the first target value and the second target value are both a high level or both low levels; the first preset relationship may be a different relationship, for example, the first target value is a high level, and the second target value is a low level, or the first target value is a low level and the second target value is a high level. With the present embodiment, the object of executing the abnormality processing in the case where the presence of the abnormality is detected is achieved.
In an optional embodiment, determining that the sending device is in the first state allowing sending data to the receiving device comprises: determining that the transmitting device is in the first state under the condition that the state value of the first target port is determined to be the same as the state value of the second target port; adjusting the state value of the first target port comprises: and adjusting the state value of the first target port to a value different from the state value of the second target port. In this embodiment, when the state value of the first target port (e.g., GPIO1) is the same as the state value of the second target port (e.g., GPIO2), for example, when both GPIO1 and GPIO2 are at a high level or a low level, the transmitting device is in a first state, for example, the first state is a data transmittable state, and when it is determined that the transmitting device has transmitted target data to the receiving device, the state value of the first target port (e.g., GPIO1) is adjusted to a value different from the state value of the second target port (e.g., GPIO2), for example, when both GPIO1 and GPIO2 are at a high level (or 1) before adjustment, the state value of the GPIO1 after adjustment is at a low level (or 0); through the embodiment, the purpose that the state value of the first target port is adjusted in time by the sending equipment after the data is sent is achieved, and the effect of improving the interactive reliability of the equipment is achieved.
In an optional embodiment, determining that the sending device is in the first state allowing sending data to the receiving device comprises: determining that the transmitting device is in the first state if it is determined that the state value of the first destination port and the state value of the second destination port are different; adjusting the state value of the first target port comprises: and adjusting the state value of the first target port to be the same value as the state value of the second target port. Optionally, in this embodiment, when the state value of the first target port (e.g., GPIO1) and the state value of the second target port (e.g., GPIO2) are different, for example, GPIO1 is at a high level and GPIO2 is at a low level, or GPIO1 is at a low level and GPIO2 is at a high level, the transmitting device is in a first state, for example, the first state is a data transmittable state, and when it is determined that the transmitting device has transmitted the target data to the receiving device, the state value of the first target port (e.g., GPIO1) is adjusted to a value that is the same as the state value of the second target port (e.g., GPIO2), for example, the GPIO1 is at a high level (or 1) before adjustment, and GPIO2 is at a low level (or 0), the state value of the adjusted GPIO1 is at a low level (or 0); through the embodiment, the purpose that the state value of the first target port is adjusted in time by the sending equipment after the data is sent is achieved, and the effect of improving the interactive reliability of the equipment is achieved.
In this embodiment, a method for adjusting a device status is provided, and fig. 3 is a second flowchart of the method for adjusting a device status according to the embodiment of the present invention, as shown in fig. 3, the flowchart includes the following steps:
step S302, acquiring a state value of a first target port of a sending device and a state value of a second target port of a receiving device, wherein the receiving device is used for receiving data sent by the sending device;
step S304, under the condition that the state value of the first target port and the state value of the second target port are determined to meet a first preset relation, determining that the receiving equipment is in a third state allowing to receive the data sent by the sending equipment;
a step S306 of determining that the receiving device is in a fourth state not allowing reception of the data transmitted by the transmitting device, in a case where it is determined that the target data transmitted by the transmitting device is received;
step S308, when it is determined that the target data has been fetched from the target buffer included in the receiving device, adjusting the state value of the second target port so that the state value of the second target port and the state value of the first target port satisfy the first preset relationship.
Through the steps, by acquiring the state value of the first target port of the sending device and the state value of the second target port of the receiving device, determining that the receiving device is in the third state allowing to receive the data sent by the sending device under the condition that the state value of the first target port and the state value of the second target port meet the first preset relation, determining that the receiving device is in the fourth state not allowing to receive the data under the condition that the state value of the first target port and the state value of the second target port meet the first preset relation, namely that the receiving device is adjusted to be in the third state from the fourth state under the condition that the target data is determined to be taken out of the target buffer of the receiving device, the receiving device adjusts the state value of the second target port so that the state value of the second target port and the state value of the first target port meet the first preset relation, under the condition that the receiving device receives the target data, the receiving device is in a fourth state which does not allow the receiving of data, and the receiving device adjusts the state value of the second target port in time after the data in the target buffer in the receiving device is taken out, so that the receiving device is in a third state which allows the receiving of data, and the problem that the data sent by a sending party is easy to lose due to the fact that a receiving party cannot adjust the state value of the port in time in the related technology is solved, therefore, the problem that the reliability of device interaction is poor due to the fact that the device state in the related technology is not adjusted in time is solved, and the effect of improving the reliability of the device interaction is achieved.
The main body of the above steps may be an apparatus side, for example, the receiving apparatus, or a controller in the receiving apparatus, or a processor with human-computer interaction capability configured on a storage apparatus, or a processing apparatus or a processing unit with similar processing capability, and the like, but is not limited thereto. The following description is given by taking the receiving device as an example (which is only an exemplary description, and in actual operation, other devices or modules may also perform the above operations):
in the above embodiment, the receiving device obtains the state value of the first target port of the sending device and the state value of the second target port of the receiving device itself, for example, the first target port is GPIO1, the second target port is GPIO2, and the state values of the ports may include a high level or a low level, and in a case where it is determined that the state values of the first target port and the second target port satisfy a first preset relationship, it is determined that the receiving device is in a third state that allows receiving data sent by the sending device, where the first preset relationship may be the same relationship, or an opposite relationship, or a different relationship, for example, when it is determined that the state values of the first target port (such as GPIO1) and the second target port (such as GPIO2) are the same (such as both high levels or both low levels), it is determined that the receiving device is in the third state, for example, the third state is a data receivable state, that is, a target Buffer (or Buffer) in the receiving device is in an empty state, it should be noted that, at this time, the corresponding transmitting device is in the aforementioned first state (i.e., a data transmittable state), and in practical applications, it may also be determined that the receiving device is in the third state (e.g., a data receivable state, or a target Buffer in the receiving device is in an empty state) when it is determined that a state value of the first target port (e.g., the GPIO1) is different from (or opposite to) a state value of the second target port (e.g., the GPIO2) (e.g., one of the ports is at a high level and the other port is at a low level); in a case where it is determined that the target data transmitted by the transmitting device is received, determining that the receiving device is in a fourth state in which reception of the data transmitted by the transmitting device is not permitted, that is, a target buffer in the receiving device is in a full state; when it is determined that the target data has been fetched from the target buffer, the receiving device adjusts the state value of the second target port, so that the state value of the second target port and the state value of the first target port satisfy a first preset relationship, as described above, where the first preset relationship may be the same relationship, or an opposite relationship, or a different relationship, it should be noted that when the receiving device receives the target data, the sending device has sent out the target data, as described in the foregoing embodiment, at this time, the sending device has adjusted the state value of its own first target port; in this embodiment, after the data in the destination buffer is removed, the receiving device makes the receiving device be in a data receivable state by adjusting the state value of the second destination port in time, so as to indicate that the sending device can send the data to the receiving device. The problem that data sent by a sender is easy to lose due to the fact that a receiver cannot timely adjust the state value of a port in the related technology is solved, therefore, the problem that the reliability of equipment interaction is poor due to the fact that the equipment state is not timely adjusted in the related technology is solved, and the effect of improving the reliability of the equipment interaction is achieved.
In an optional embodiment, before obtaining the state value of the first destination port of the sending device and the state value of the second destination port of the receiving device, the method further includes: performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the second target port to a second target value so that the second target value and the first target value satisfy the first preset relationship, wherein the first target value is the state value of the first target port after the sending device performs an initialization operation. In this embodiment, the receiving device may perform an initialization operation first, and in practical applications, may also perform the initialization operation after receiving the initialization instruction or under the condition that an abnormality occurs, for example, the state value of the second target port is initialized to a second target value (such as a high level or a low level), and in practical applications, the receiving device may also obtain the state value of the first target port of the sending device, where the first preset relationship may be the same relationship, for example, the first target value and the second target value are both a high level or both low levels; the first preset relationship may be a different relationship, for example, the first target value is a high level, and the second target value is a low level, or the first target value is a low level and the second target value is a high level. By the embodiment, the purpose of initializing the target port is achieved.
In an optional embodiment, after adjusting the state value of the second target port, the method further comprises: performing a predetermined detection operation to determine a state value of a second target flag, wherein the state value of the second target flag is used for indicating whether the receiving device is abnormal or not; and executing predetermined processing under the condition that the state value of the second target zone bit is determined to be a first preset value. In this embodiment, the receiving device may further perform a predetermined detection operation to determine a state value of the second target flag, where the state value of the second target flag is used to indicate whether the receiving device is abnormal, for example, when the receiving device has an abnormality, the second target flag is 1 (or 0), at which point the receiving device will perform a predetermined process, that is, perform an abnormality process, for example, at which point the initialization operation may be performed again on the receiving device. With the present embodiment, the purpose of determining whether the device has an abnormality by detecting the second target flag and executing predetermined processing is achieved.
In an alternative embodiment, performing the predetermined detection operation to determine the state value of the second target flag bit comprises: obtaining the state value of the current first target port and the state value of the previous first target port, and obtaining the state value of the current second target port and the state value of the previous second target port, wherein the current state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device finishes sending the target data at the current time, the current state value of the second target port is the state value of the second target port after the sending device finishes sending the target data at the current time, the previous state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device has sent data to the receiving device for the previous time, the previous state value of the second target port is the state value of the second target port after the sending device sends data to the receiving device for the previous time; comparing the state value of the current first target port with the state value of the previous first target port to obtain a first comparison result, and comparing the state value of the current second target port with the state value of the previous second target port to obtain a second comparison result; and determining the state value of the second target flag bit as the first preset value under the condition that the first comparison result indicates that the state value of the current first target port is the same as the state value of the previous first target port, and/or determining the second comparison result indicates that the state value of the current second target port is the same as the state value of the previous second target port. In this embodiment, the state value of the second target flag bit may be determined by comparing the state values of the first target port (e.g., GPIO1) and the second target port (e.g., GPIO2) when the data is transmitted at the current time with the state values of the first target port (e.g., GPIO1) and the second target port (e.g., GPIO2) when the data is transmitted at the previous time, for example, the state values of the GPIO1 when the data is transmitted at the current time and the state values of the GPIO2 when the data is transmitted at the previous time are the same, for example, when an error or an abnormality is detected, the state value of the second target flag bit is determined to be the first preset value, for example, the first preset value is 1 (or high level), and the first preset value may also be 0 (or low level). Through the embodiment, the purpose of detecting whether the abnormality exists or not by executing the abnormality detection mechanism is achieved, and the effect of further improving the reliability of interaction between the devices is achieved.
In an alternative embodiment, performing the predetermined detection operation to determine the state value of the second target flag bit comprises: acquiring a state value of a second target port before adjustment and a state value of the second target port after adjustment, wherein the state value of the second target port before adjustment is the state value of the second target port before the receiving device determines that the target data is taken out from the target buffer, and the state value of the second target port after adjustment is the state value of the second target port after the receiving device determines that the target data is taken out from the target buffer; comparing the state value of the first target port before adjustment with the state value of the first target port after adjustment to obtain a third comparison result; and determining the state value of the second target zone bit as the first preset value under the condition that the third comparison result indicates that the state value of the second target port before the adjustment is the same as the state value of the second target port after the adjustment. In this embodiment, the state value of the second target flag may be determined by comparing the state value of the second target port (e.g., GPIO2) before being adjusted with the state value of the second target port (e.g., GPIO2) after being adjusted, for example, when the GPIO2 has the same state value before being adjusted and the GPIO status value after being adjusted, that is, an error or an abnormality is detected, the state value of the second target flag is determined to be the first preset value, for example, the first preset value is 1 (or high level), and the first preset value may also be 0 (or low level). Through the embodiment, the purpose of detecting whether the abnormality exists or not by executing the abnormality detection mechanism is achieved, and the effect of further improving the reliability of interaction between the devices is achieved.
In an alternative embodiment, performing the predetermined detection operation to determine the state value of the second target flag bit comprises: detecting whether the state of the target buffer, the state value of the first target port and the state value of the second target port meet preset conditions according to a preset period to obtain a detection result; and determining the state value of the second target zone bit as the first preset value under the condition that the detection result indicates that the preset condition is not met among the state of the target buffer, the state value of the first target port and the state value of the second target port. In this embodiment, a predetermined detection operation may be further performed periodically to determine the state value of the second target flag, for example, periodically detect whether the state (e.g., empty or full state) of the target Buffer (such as Buffer) matches the state of the first target port (e.g., GPIO1) and the state of the second target port (e.g., GPIO2), and if not, enter an abnormal state, i.e., detect that there is an error or an abnormality. Through the embodiment, the purpose of detecting whether the abnormality exists or not by executing the abnormality detection mechanism is achieved, and the effect of further improving the reliability of interaction between the devices is achieved.
In an alternative embodiment, performing the predetermined process includes: performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the second target port to a second target value so that the second target value and the first target value satisfy the first preset relationship, wherein the first target value is the state value of the first target port after the sending device performs an initialization operation. In this embodiment, the performing the predetermined processing may include performing an initialization operation, for example, initializing the state value of the second target port to a second target value (e.g., a high level or a low level), and in practical applications, the receiving device may also obtain the state value of the first target port of the sending device, where the first preset relationship may be the same relationship, for example, the first target value and the second target value are both a high level or both low levels; the first preset relationship may be a different relationship, for example, the first target value is a high level, and the second target value is a low level, or the first target value is a low level and the second target value is a high level. With the present embodiment, the object of executing the abnormality processing in the case where the presence of the abnormality is detected is achieved.
In an alternative embodiment, determining that the receiving device is in the third state allowing reception of data transmitted by the transmitting device comprises: determining that the receiving device is in the third state if it is determined that the state value of the second destination port is the same as the state value of the first destination port; adjusting the state value of the second target port comprises: and adjusting the state value of the second target port to be the same value as the state value of the first target port. In this embodiment, when the state value of the second target port (e.g., GPIO2) is the same as the state value of the first target port (e.g., GPIO1), e.g., GPIO1 and GPIO2 are both high level or low level, the receiving device is in a third state, e.g., the third state is a data receivable state, and when it is determined that the target data has been removed from the target buffer in the receiving device, the state value of the second target port (e.g., GPIO2) is adjusted to the same value as the state value of the first target port (e.g., GPIO1), e.g., when the receiving device does not receive the target data, GPIO1 and GPIO2 are both high level (or 1), and after receiving the target data, i.e., corresponding to the transmitting device having transmitted the target data, as is known from the foregoing embodiment, the transmitting device will adjust the state value of GPIO1, i.e., the state value of the GPIO1 after transmitting the data is low level (or 0), after determining that the target data is removed from the target buffer in the receiving device, the receiving device adjusts the state value of the second target port (e.g., GPIO2) to the same value as the state value of the first target port (e.g., GPIO1), i.e., to be a low level (or 0), and at this time, the receiving device returns to the third state (i.e., a data receiving state, or a state where the target buffer is empty); through the embodiment, the purpose that the receiving equipment timely adjusts the state value of the second target port after the data in the target buffer is taken away is achieved, the purpose that the sending equipment can send the data is indicated is also achieved, and the effect of improving the interaction reliability of the equipment is achieved.
In an alternative embodiment, determining that the receiving device is in the third state allowing reception of data transmitted by the transmitting device comprises: determining that the receiving device is in the third state if it is determined that the state value of the second destination port and the state value of the first destination port are different; adjusting the state value of the second target port comprises: and adjusting the state value of the second target port to a value different from the state value of the first target port. In this embodiment, when the state value of the second target port (e.g., GPIO2) is different from the state value of the first target port (e.g., GPIO1), for example, GPIO1 is at a high level and GPIO2 is at a low level, or GPIO1 is at a low level and GPIO2 is at a high level, the receiving device is in a third state, for example, the third state is a data receivable state of the receiving device, and when it is determined that the target data has been removed from the target buffer in the receiving device, the state value of the second target port (e.g., GPIO2) is adjusted to a value different from the state value of the first target port (e.g., GPIO1), for example, when the receiving device does not receive the target data, GPIO1 is at a high level (or 1) and GPIO2 is at a low level (or 0), and after receiving the target data, the corresponding transmitting device has already transmitted the target data, it can be known from the foregoing embodiment that the transmitting device adjusts 1 the state value after having transmitted the target data, that is, the adjusted state value of GPIO1 is low level (or 0), and after it is determined that the target data has been removed from the target buffer in the receiving device, the receiving device adjusts the state value of the second target port (e.g., GPIO2) to a value different from the state value of the first target port (e.g., GPIO1), that is, high level (or 1), and at this time, the receiving device returns to the third state (i.e., data receiving state, or empty state of the target buffer); through the embodiment, the purpose that the receiving equipment timely adjusts the state value of the second target port after the data in the target buffer is taken away is achieved, the purpose that the sending equipment can send the data is indicated is also achieved, and the effect of improving the interaction reliability of the equipment is achieved.
It is to be understood that the above-described embodiments are only a few, but not all, embodiments of the present invention. The present invention will be described in detail with reference to examples.
Fig. 4 is a system architecture diagram of device communication handshake according to a specific embodiment of the present invention, as shown in fig. 4, the basic hardware elements of the system include a sending party (corresponding to the sending device), a receiving party (corresponding to the receiving device), a communication bus, a GPIO1 (corresponding to the first target port), and a GPIO2 (corresponding to the second target port), wherein the communication data direction is from the sending party to the receiving party, and the communication bus is a communication data transmission channel; the GPIO1 controls the direction from the sender to the receiver and is used for bus communication handshake; the GPIO2 controls the direction from the receiver to the sender for bus communication handshaking. The communication handshake system provided by the embodiment of the invention can avoid the data loss sent by the sender due to the fullness (corresponding to the target Buffer) of the receiver, thereby realizing the purpose of ensuring the reliability of bus communication.
Fig. 5 is a schematic diagram of a device communication handshake method according to a specific embodiment of the present invention, and as shown in fig. 5, the communication handshake method is composed of a handshake mechanism and an error detection mechanism, where the handshake mechanism is cooperatively operated by a sender and a receiver and is used to ensure that the sender sends data again when a receiver Buffer is empty; the error detection mechanism is used for detecting whether the handshake mechanism has errors, and the receiver and the sender respectively operate a set of error detection mechanism independently. The handshake mechanism and the error detection mechanism are described separately below with reference to the drawings.
Fig. 6 is a first exemplary communication handshake diagram according to an embodiment of the present invention, in which a handshake mechanism is cooperatively executed by a sender (corresponding to the sending device) and a receiver (corresponding to the receiving device), and the specific process is as follows:
in the handshake mechanism initialization stage, the transmitter initializes GPIO1 to 1 and GPIO2 to 0, where the state value corresponding to the first target port and the state value corresponding to the second target port satisfy a first preset relationship (the first preset relationship is different), the transmitter enters a data transmittable state (corresponding to the first state), and the receiver enters a Buffer empty state (corresponding to the third state).
When the sender is in a data sending state, if no data packet is sent all the time, the sender is in the data sending state all the time; if the data packet is sent, the GPIO1 is set to a value consistent with the GPIO2 (the state value corresponding to the first target port and the state value corresponding to the second target port satisfy a second preset relationship), and then the data packet enters a non-transmittable data state (corresponding to the second state), which corresponds to the adjustment of the state value of the first target port, that is, the sender enters the non-transmittable data state by adjusting the state value of the GPIO 1.
When the receiver is in the Buffer empty state, if no data packet is received all the time, the receiver is in the Buffer empty state all the time; and entering a Buffer full state (corresponding to the fourth state) if data is received.
When the receiver is in a Buffer full state, if no Buffer data is taken all the time, the receiver is in the Buffer full state all the time; if the Buffer data is taken out, the GPIO2 is set to the value opposite to the GPIO1 (corresponding to the aforementioned adjustment of the state value of the second target port), and enters a Buffer empty state, i.e., the receiving party enters a data receivable state by adjusting the state value of the GPIO 2.
When the data can not be transmitted, the data can not be transmitted until the GPIO1 and the GPIO2 are detected to be opposite, the data can be transmitted, and the data can be transmitted again.
In fig. 6, the receiving side and the sending side further have respective Error detection mechanisms, and if an Error is detected by the Error detection mechanism, the Error flag (corresponding to the first target flag and the second target flag) is set to 1 (corresponding to the first preset value), for example, in fig. 6, the Error flag is set to 1, when the handshake mechanism detects that the Error flag is 1, the handshake mechanism enters an abnormal processing state, and the handshake mechanism is reinitialized after the abnormal processing is completed.
In order to more clearly understand the specific process of the communication handshake mechanism, the description is made by combining the state diagrams of the two communication parties, i.e. the corresponding timing diagrams, fig. 7 is a timing diagram of the communication handshake mechanism according to an embodiment of the present invention, and the adjustment process of the state values of the GPIO1 and the GPIO2 and the state change process of the sender and the receiver can be more clearly understood by combining the timing diagram.
For example, after the sender and the receiver are initialized, GPIO1 is initialized to 1, GPIO2 is initialized to 0, at this time, the sender enters a data-transmittable state, and the receiver enters a Buffer empty state;
when the sender sends a data packet, the sender adjusts the GPIO1 to a value consistent with the GPIO2, namely the GPIO1 is adjusted to 0, and at the moment, the receiver enters a Buffer full state after receiving the data packet;
and when the data in the Buffer is taken out, the receiver adjusts the GPIO2 to a value opposite to the GPIO1 (i.e., to 1), and then enters a Buffer empty state to wait for the sender to send the data.
Optionally, the state diagram of the handshake mechanism may also be as shown in fig. 8, where fig. 8 is a second exemplary diagram of communication handshake according to a specific embodiment of the present invention, where the operation principle is consistent with that in fig. 6, except that the initialization states of GPIO1 and GPIO2 are different, and as shown in fig. 6, the initialization states of GPIO1 and GPIO2 are: (GPIO1 is 1 and GPIO2 is 0), whereas the initialization states of GPIO1 and GPIO2 in fig. 8 are: (GPIO1 is 0, GPIO2 is 1), the operation process and the adjustment method of the state values of GPIO1 and GPIO2 are the same, so the operation process and the corresponding timing diagram are not described again.
Optionally, the handshake mechanism state diagram may also be as shown in fig. 9, where fig. 9 is a third exemplary diagram of communication handshake according to a specific embodiment of the present invention, where an operation principle is consistent with that in fig. 6, and only initialization states of GPIO1 and GPIO2 and GPIO determination logic are different, and initialization states of GPIO1 and GPIO2 in fig. 6 are: (GPIO1 is 1 and GPIO2 is 0), whereas the initialization states of GPIO1 and GPIO2 in fig. 9 are: (GPIO1 is 1 and GPIO2 is 1), and in fig. 6 the sender adjusts GPIO1 to GPIO1 to GPIO2 after sending the packet, and in fig. 9 the sender adjusts GPIO1 to GPIO1 | after sending the packet! The GPIO2 has the same or similar process, so the operation and the corresponding timing diagram are not described again.
Optionally, a state diagram of a handshake mechanism may also be shown in fig. 10, where fig. 10 is a fourth exemplary diagram of a communication handshake according to an embodiment of the present invention, and the working principle is also the same as fig. 6, except that the initialization states of the GPIO1 and the GPIO2 and the GPIO determination logic are different, and similar to the example in fig. 9, the working process is the same as or similar to that in fig. 6 (or fig. 9), so that details of the working process and the corresponding timing diagram are not repeated.
The communication handshake method in the embodiment of the present invention may further include an error detection mechanism, fig. 11 is a first exemplary diagram of an abnormality detection mechanism according to the embodiment of the present invention, fig. 11 corresponds to the abnormality detection mechanism of the sender, and the abnormality detection mechanism of the sender includes two states, namely, normal detection and abnormal detection. The method comprises the following specific steps:
after the transmitter modifies the state of the GPIO1 (i.e., after adjusting the state value of the GPIO1), the transmitter compares whether the state of the GPIO1 after the modification is opposite to that before the modification, and if so, indicates that the detection is normal, and if so, indicates that the detection is abnormal.
In addition, each time the transmitting side transmits data, the transmitting side compares whether the states of the GPIO1 and the GPIO2 are opposite to the states of the GPIO1 and the GPIO2 in the last data transmission, and if the states are opposite, the detection is normal, and if the states are the same, the detection is abnormal.
If the detection is normal, the detection is continued, if the detection is abnormal, the abnormal detection state is entered, then the Error flag is set to be 1, and the abnormal detection is restarted after the abnormal processing of the handshake mechanism is finished.
Fig. 12 is a second exemplary diagram of an anomaly detection mechanism according to an embodiment of the present invention, and fig. 12 corresponds to an anomaly detection mechanism of a receiving party, where the anomaly detection of the receiving party includes three states, detection normal, detection abnormal, and timing detection. Compared with the anomaly detection of the sender, the anomaly detection of the receiver adds a timing detection mechanism, and the others are completely the same as the sender and are not repeated. The timing detection mechanism is explained below.
The timing detection mechanism is used for timing to confirm whether the Buffer state is consistent with the states of the GPIO1 and the GPIO2, if not, the abnormal state is detected, and if so, the normal state is detected.
The timing detection mechanism can effectively prevent the situation that the Buffer of the receiving party is empty and the data can not be sent by the sending party due to unexpected factors.
In the embodiment, a communication handshake mechanism is realized by adopting two GPIOs, one of the two GPIOs is driven by a data sending party, and the other GPIO is driven by a data receiving party; when the data sender sends data, the GPIO1 is driven to be 'bus locked' (the data sending is completed and the sender can not send data any more), and when the data receiver takes Buffer data, the GPIO2 is driven to be 'bus unlocked' (the sender can send data); GPIO state driving is processed in the original bus communication interruption, and extra interruption overhead is not required to be added in the embodiment; in addition, the sender and the receiver independently operate an error detection mechanism; the error detection mechanism of the sender and the receiver is realized by comparing the difference of the states of the two GPIOs at the current specific moment and the last specific moment; the error detection mechanism of the receiver also comprises a timing detection mechanism which detects whether the states of the two GPIOs are consistent with the Buffer state of the receiver at regular time. According to the embodiment of the invention, a very reliable handshaking mechanism is adopted to ensure the reliability of communication data, and an error detection mechanism is adopted to monitor the handshaking mechanism, so that the reliability of the handshaking mechanism is ensured; meanwhile, a specific error detection and recovery mechanism is adopted to avoid that a sender can not send data permanently due to unexpected errors of a handshake mechanism, so that the effect of further improving the reliability of communication is achieved.
Compared with the related technology, the embodiment of the invention adopts two GPIOs to realize a handshake mechanism, and has low requirement on a hardware system; two handshake GPIOs are respectively controlled by a sender and a receiver, the sender drives the GPIO1 to set a data unsemissible state, and the receiver drives the GPIO2 to remove the data unsemissible state, so that the interactive mechanism has extremely high reliability, no time sequence loophole and no system real-time requirement; an additional error detection mechanism is adopted to ensure the reliability of a handshake mechanism, so that the reliability of the whole communication handshake system is further improved; the whole GPIO state drive is carried out during normal data transmission (data is written in a Buffer in the transmission direction) or data reception (data is fetched by a receiving party), so that no extra interrupt overhead exists.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
In this embodiment, an apparatus for adjusting a device status is further provided, and fig. 13 is a first block diagram of a structure of the apparatus for adjusting a device status according to an embodiment of the present invention, as shown in fig. 13, the apparatus includes:
a first obtaining module 1302, configured to obtain a state value of a first target port of a sending device and a state value of a second target port of a receiving device, where the sending device is configured to send data to the receiving device;
a first determining module 1304, configured to determine that the sending device is in a first state allowing data to be sent to the receiving device when it is determined that the state value of the first target port and the state value of the second target port satisfy a first preset relationship;
a first adjusting module 1306, configured to, if it is determined that the sending device has sent target data to the receiving device, adjust a state value of the first target port so that the state value of the first target port and the state value of the second target port satisfy a second preset relationship, where, if the state value of the first target port and the state value of the second target port satisfy the second preset relationship, the sending device is in a second state where data transmission to the receiving device is not allowed.
In an optional embodiment, the apparatus further comprises: a first initialization module, configured to, in an exemplary embodiment, perform an initialization operation before obtaining a state value of a first target port of a sending device and a state value of a second target port of a receiving device, where the initialization operation includes: initializing the state value of the first target port to a first target value, and sending the first target value to the receiving device, so that the receiving device sets the state value of the second target port to a second target value based on the first target value, wherein the first target value and the second target value satisfy the first preset relationship.
In an optional embodiment, the apparatus further comprises: a first detection module, configured to perform a predetermined detection operation after adjusting a state value of the first target port to determine a state value of a first target flag, where the state value of the first target flag is used to indicate whether the sending device is abnormal; and the first processing module is used for executing preset processing under the condition that the state value of the first target zone bit is determined to be a first preset value.
In an optional embodiment, the first detecting module includes: a first obtaining unit, configured to obtain a state value of a first target port of a current time and a state value of a first target port of a previous time, and obtain a state value of a second target port of the current time and a state value of a second target port of the previous time, where the state value of the first target port of the current time is a state value of the first target port that is adjusted by the sending device after the sending device finishes sending the target data of the current time, the state value of the second target port of the current time is a state value of the second target port that is adjusted by the sending device after the sending device finishes sending the target data of the current time to the receiving device, the state value of the first target port of the previous time is a state value of the first target port that is adjusted by the sending device after the sending device finishes sending the data of the previous time to the receiving device, and the state value of the second target port of the previous time is a state value of the second target port after the sending device finishes sending the data of the previous time to the receiving device; a first comparing unit, configured to compare the state value of the current first target port with the state value of the previous first target port to obtain a first comparison result, and compare the state value of the current second target port with the state value of the previous second target port to obtain a second comparison result; a first determining unit, configured to determine, when it is determined that the first comparison result indicates that the state value of the current first target port is the same as the state value of the previous first target port, and/or when it is determined that the second comparison result indicates that the state value of the current second target port is the same as the state value of the previous second target port, the state value of the first target flag is the first preset value.
In an optional embodiment, the first detecting module includes: a second obtaining unit, configured to obtain a state value of a first target port before adjustment and a state value of the first target port after adjustment, where the state value of the first target port before adjustment is the state value of the first target port before the sending device sends the target data, and the state value of the first target port after adjustment is the state value of the first target port after the sending device has sent the target data; the second comparison unit is used for comparing the state value of the first target port before the adjustment with the state value of the first target port after the adjustment to obtain a third comparison result; a second determining unit, configured to determine the state value of the first target flag as the first preset value when the third comparison result indicates that the state value of the first target port before the adjustment is the same as the state value of the first target port after the adjustment.
In an optional embodiment, the first processing module includes: a first execution unit configured to execute an initialization operation, wherein the initialization operation includes: initializing the state value of the first target port to a first target value, and sending the first target value to the receiving device, so that the receiving device sets the state value of the second target port to a second target value based on the first target value, wherein the first target value and the second target value satisfy the first preset relationship.
In an alternative embodiment, the first determining module 1304 includes: a third determining unit, configured to determine that the sending device is in the first state when it is determined that the state value of the first target port is the same as the state value of the second target port; the first adjusting module 1306 includes: a first adjusting unit, configured to adjust the state value of the first target port to a value different from the state value of the second target port.
In an alternative embodiment, the first determining module 1304 includes: a fourth determining unit, configured to determine that the sending device is in the first state when it is determined that the state value of the first target port and the state value of the second target port are different; the first adjusting module 1306 includes: and the second adjusting unit is used for adjusting the state value of the first target port to be the same value as the state value of the second target port.
In this embodiment, an apparatus for adjusting a device status is further provided, and fig. 14 is a block diagram of a structure of the apparatus for adjusting a device status according to the embodiment of the present invention, as shown in fig. 14, the apparatus includes:
a second obtaining module 1402, configured to obtain a state value of a first target port of a sending device and a state value of a second target port of a receiving device, where the receiving device is configured to receive data sent by the sending device;
a second determining module 1404, configured to determine that the receiving device is in a third state allowing receiving of data sent by the sending device, if it is determined that the state value of the first target port and the state value of the second target port satisfy the first preset relationship;
a third determining module 1406, configured to determine that the receiving device is in a fourth state that does not allow receiving of data transmitted by the transmitting device, in a case where it is determined that target data transmitted by the transmitting device is received;
a second adjusting module 1408, configured to, in a case that it is determined that the target data has been fetched from the target buffer included in the receiving apparatus, adjust the state value of the second target port so that the state value of the second target port and the state value of the first target port satisfy the first preset relationship.
In an optional embodiment, the apparatus further comprises: a second initialization module, configured to perform an initialization operation before obtaining a state value of a first target port of a sending device and a state value of a second target port of a receiving device, where the initialization operation includes: initializing the state value of the second target port to a second target value so that the second target value and the first target value satisfy the first preset relationship, wherein the first target value is the state value of the first target port after the sending device performs an initialization operation.
In an optional embodiment, the apparatus further comprises: a second detection module, configured to perform a predetermined detection operation after adjusting a state value of the second target port to determine a state value of a second target flag, where the state value of the second target flag is used to indicate whether the receiving device is abnormal; and the second processing module is used for executing preset processing under the condition that the state value of the second target zone bit is determined to be a first preset value.
In an optional embodiment, the second detecting module includes: a third obtaining unit, configured to obtain a state value of a first target port of a current time and a state value of a first target port of a previous time, and obtain a state value of a second target port of the current time and a state value of a second target port of the previous time, where the state value of the first target port of the current time is a state value of the first target port that is adjusted by the sending device after the sending device finishes sending the target data of the current time, the state value of the second target port of the current time is a state value of the second target port that is adjusted by the sending device after the sending device finishes sending the target data of the current time to the receiving device, the state value of the first target port of the previous time is a state value of the first target port that is adjusted by the sending device after the sending device finishes sending the data of the previous time to the receiving device, and the state value of the second target port of the previous time is a state value of the second target port after the sending device finishes sending the data of the previous time to the receiving device; a third comparing unit, configured to compare the state value of the current first target port with the state value of the previous first target port to obtain a first comparison result, and compare the state value of the current second target port with the state value of the previous second target port to obtain a second comparison result; a fifth determining unit, configured to determine, when it is determined that the first comparison result indicates that the state value of the current first target port is the same as the state value of the previous first target port, and/or when it is determined that the second comparison result indicates that the state value of the current second target port is the same as the state value of the previous second target port, the state value of the second target flag is the first preset value.
In an optional embodiment, the second detecting module includes: a fourth obtaining unit, configured to obtain a state value of a second destination port before adjustment and a state value of the second destination port after adjustment, where the state value of the second destination port before adjustment is the state value of the second destination port before the receiving apparatus determines that the destination data is taken out from the destination buffer, and the state value of the second destination port after adjustment is the state value of the second destination port after the receiving apparatus determines that the destination data is taken out from the destination buffer; a fourth comparing unit, configured to compare the state value of the first target port before the adjustment with the state value of the first target port after the adjustment, so as to obtain a third comparison result; a sixth determining unit, configured to determine the state value of the second target flag as the first preset value when the third comparison result indicates that the state value of the second target port before the adjustment is the same as the state value of the second target port after the adjustment.
In an optional embodiment, the second detecting module includes: the first detection unit is used for detecting whether the state of the target buffer, the state value of the first target port and the state value of the second target port meet preset conditions according to a preset period so as to obtain a detection result; a seventh determining unit, configured to determine the state value of the second target flag as the first preset value when the detection result indicates that the preset condition is not satisfied among the state of the target buffer, the state value of the first target port, and the state value of the second target port.
In an optional embodiment, the second processing module includes: a second execution unit configured to execute an initialization operation, wherein the initialization operation includes: initializing the state value of the second target port to a second target value so that the second target value and the first target value satisfy the first preset relationship, wherein the first target value is the state value of the first target port after the sending device performs an initialization operation.
In an alternative embodiment, the second determining module 1404 includes: an eighth determining unit, configured to determine that the receiving device is in the third state when it is determined that the state value of the second target port is the same as the state value of the first target port; the second adjustment module 1408 adjusts the parameters including: and a third adjusting unit, configured to adjust the state value of the second target port to a value that is the same as the state value of the first target port.
In an alternative embodiment, the second determining module 1404 includes: a ninth determining unit, configured to determine that the receiving device is in the third state when it is determined that the state value of the second target port and the state value of the first target port are different; the second adjustment module 1408 adjusts the parameters including: a fourth adjusting unit, configured to adjust the state value of the second target port to a value different from the state value of the first target port.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.
In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
In an exemplary embodiment, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary embodiments, and details of this embodiment are not repeated herein.
It will be apparent to those skilled in the art that the various modules or steps of the invention described above may be implemented using a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and they may be implemented using program code executable by the computing devices, such that they may be stored in a memory device and executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into various integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (21)

1. A method for adjusting the state of equipment is characterized by comprising the following steps:
acquiring a state value of a first target port of a sending device and a state value of a second target port of a receiving device, wherein the sending device is used for sending data to the receiving device;
under the condition that the state value of the first target port and the state value of the second target port are determined to meet a first preset relation, determining that the sending equipment is in a first state allowing data to be sent to the receiving equipment;
and under the condition that the sending device is determined to send the target data to the receiving device, adjusting the state value of the first target port so that the state value of the first target port and the state value of the second target port meet a second preset relationship, wherein under the condition that the state value of the first target port and the state value of the second target port meet the second preset relationship, the sending device is in a second state that the sending device is not allowed to send the data to the receiving device.
2. The method of claim 1, wherein prior to obtaining the status value for the first destination port of the sending device and the status value for the second destination port of the receiving device, the method further comprises:
performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the first target port to a first target value, and sending the first target value to the receiving device, so that the receiving device sets the state value of the second target port to a second target value based on the first target value, wherein the first target value and the second target value satisfy the first preset relationship.
3. The method of claim 1, wherein after adjusting the state value of the first target port, the method further comprises:
executing a predetermined detection operation to determine a state value of a first target flag bit, wherein the state value of the first target flag bit is used for indicating whether the sending equipment is abnormal or not;
and executing predetermined processing under the condition that the state value of the first target zone bit is determined to be a first preset value.
4. The method of claim 3, wherein performing a predetermined detection operation to determine the state value of the first target flag bit comprises:
obtaining the state value of the current first target port and the state value of the previous first target port, and obtaining the state value of the current second target port and the state value of the previous second target port, wherein the current state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device finishes sending the target data at the current time, the current state value of the second target port is the state value of the second target port after the sending device finishes sending the target data at the current time, the previous state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device has sent data to the receiving device for the previous time, the previous state value of the second target port is the state value of the second target port after the sending device sends data to the receiving device for the previous time;
comparing the state value of the current first target port with the state value of the previous first target port to obtain a first comparison result, and comparing the state value of the current second target port with the state value of the previous second target port to obtain a second comparison result;
and determining the state value of the first target flag bit as the first preset value under the condition that the first comparison result indicates that the state value of the current first target port is the same as the state value of the previous first target port, and/or determining the second comparison result indicates that the state value of the current second target port is the same as the state value of the previous second target port.
5. The method of any one of claims 3 or 4, wherein performing a predetermined detection operation to determine the state value of the first target flag bit comprises:
acquiring a state value of a first target port before adjustment and a state value of the first target port after adjustment, wherein the state value of the first target port before adjustment is the state value of the first target port before the sending device sends the target data, and the state value of the first target port after adjustment is the state value of the first target port after the sending device sends the target data;
comparing the state value of the first target port before adjustment with the state value of the first target port after adjustment to obtain a third comparison result;
and determining the state value of the first target zone bit as the first preset value under the condition that the third comparison result indicates that the state value of the first target port before adjustment is the same as the state value of the first target port after adjustment.
6. The method of claim 3, wherein performing the predetermined process comprises:
performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the first target port to a first target value, and sending the first target value to the receiving device, so that the receiving device sets the state value of the second target port to a second target value based on the first target value, wherein the first target value and the second target value satisfy the first preset relationship.
7. The method of claim 1,
determining that the sending device is in a first state that allows data to be sent to the receiving device comprises: determining that the transmitting device is in the first state under the condition that the state value of the first target port is determined to be the same as the state value of the second target port;
adjusting the state value of the first target port comprises: and adjusting the state value of the first target port to a value different from the state value of the second target port.
8. The method of claim 1,
determining that the sending device is in a first state that allows data to be sent to the receiving device comprises: determining that the transmitting device is in the first state if it is determined that the state value of the first destination port and the state value of the second destination port are different;
adjusting the state value of the first target port comprises: and adjusting the state value of the first target port to be the same value as the state value of the second target port.
9. A method for adjusting the state of equipment is characterized by comprising the following steps:
acquiring a state value of a first target port of a sending device and a state value of a second target port of a receiving device, wherein the receiving device is used for receiving data sent by the sending device;
determining that the receiving device is in a third state allowing the receiving device to receive data transmitted by the transmitting device, in a case where it is determined that the state value of the first target port and the state value of the second target port satisfy a first preset relationship;
determining that the receiving device is in a fourth state not allowing reception of the data transmitted by the transmitting device in a case where it is determined that the target data transmitted by the transmitting device is received;
and under the condition that the target data is determined to be taken out of the target buffer included in the receiving equipment, adjusting the state value of the second target port so that the state value of the second target port and the state value of the first target port meet the first preset relation.
10. The method of claim 9, wherein prior to obtaining the status value for the first destination port of the sending device and the status value for the second destination port of the receiving device, the method further comprises:
performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the second target port to a second target value so that the second target value and the first target value satisfy the first preset relationship, wherein the first target value is the state value of the first target port after the sending device performs an initialization operation.
11. The method of claim 9, wherein after adjusting the state value of the second destination port, the method further comprises:
performing a predetermined detection operation to determine a state value of a second target flag, wherein the state value of the second target flag is used for indicating whether the receiving device is abnormal or not;
and executing predetermined processing under the condition that the state value of the second target zone bit is determined to be a first preset value.
12. The method of claim 11, wherein performing a predetermined detection operation to determine a state value of the second target flag bit comprises:
obtaining the state value of the current first target port and the state value of the previous first target port, and obtaining the state value of the current second target port and the state value of the previous second target port, wherein the current state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device finishes sending the target data at the current time, the current state value of the second target port is the state value of the second target port after the sending device finishes sending the target data at the current time, the previous state value of the first target port is the state value of the first target port adjusted by the sending device after the sending device has sent data to the receiving device for the previous time, the previous state value of the second target port is the state value of the second target port after the sending device sends data to the receiving device for the previous time;
comparing the state value of the current first target port with the state value of the previous first target port to obtain a first comparison result, and comparing the state value of the current second target port with the state value of the previous second target port to obtain a second comparison result;
and determining the state value of the second target flag bit as the first preset value under the condition that the first comparison result indicates that the state value of the current first target port is the same as the state value of the previous first target port, and/or determining the second comparison result indicates that the state value of the current second target port is the same as the state value of the previous second target port.
13. The method of any one of claims 11 or 12, wherein performing a predetermined detection operation to determine a state value of a second target flag bit comprises:
acquiring a state value of a second target port before adjustment and a state value of the second target port after adjustment, wherein the state value of the second target port before adjustment is the state value of the second target port before the receiving device determines that the target data is taken out from the target buffer, and the state value of the second target port after adjustment is the state value of the second target port after the receiving device determines that the target data is taken out from the target buffer;
comparing the state value of the first target port before adjustment with the state value of the first target port after adjustment to obtain a third comparison result;
and determining the state value of the second target zone bit as the first preset value under the condition that the third comparison result indicates that the state value of the second target port before the adjustment is the same as the state value of the second target port after the adjustment.
14. The method of claim 11, wherein performing a predetermined detection operation to determine a state value of the second target flag bit comprises:
detecting whether the state of the target buffer, the state value of the first target port and the state value of the second target port meet preset conditions according to a preset period to obtain a detection result;
and determining the state value of the second target zone bit as the first preset value under the condition that the detection result indicates that the preset condition is not met among the state of the target buffer, the state value of the first target port and the state value of the second target port.
15. The method of claim 11, wherein performing a predetermined process comprises:
performing an initialization operation, wherein the initialization operation comprises: initializing the state value of the second target port to a second target value so that the second target value and the first target value satisfy the first preset relationship, wherein the first target value is the state value of the first target port after the sending device performs an initialization operation.
16. The method of claim 9,
determining that the receiving device is in a third state that allows reception of data transmitted by the transmitting device comprises: determining that the receiving device is in the third state if it is determined that the state value of the second destination port is the same as the state value of the first destination port;
adjusting the state value of the second target port comprises: and adjusting the state value of the second target port to be the same value as the state value of the first target port.
17. The method of claim 9,
determining that the receiving device is in a third state that allows reception of data transmitted by the transmitting device comprises: determining that the receiving device is in the third state if it is determined that the state value of the second destination port and the state value of the first destination port are different;
adjusting the state value of the second target port comprises: and adjusting the state value of the second target port to a value different from the state value of the first target port.
18. An apparatus for adjusting a state of a device, comprising:
a first obtaining module, configured to obtain a state value of a first target port of a sending device and a state value of a second target port of a receiving device, where the sending device is configured to send data to the receiving device;
a first determining module, configured to determine that the sending device is in a first state in which data is allowed to be sent to the receiving device when it is determined that the state value of the first target port and the state value of the second target port satisfy a first preset relationship;
a first adjusting module, configured to, when it is determined that the sending device has sent target data to the receiving device, adjust a state value of the first target port, so that the state value of the first target port and the state value of the second target port satisfy a second preset relationship, where, when the state value of the first target port and the state value of the second target port satisfy the second preset relationship, the sending device is in a second state where data transmission to the receiving device is not allowed.
19. An apparatus for adjusting a state of a device, comprising:
a second obtaining module, configured to obtain a state value of a first target port of a sending device and a state value of a second target port of a receiving device, where the receiving device is configured to receive data sent by the sending device;
a second determining module, configured to determine that the receiving device is in a third state where it is allowed to receive data sent by the sending device when it is determined that the state value of the first target port and the state value of the second target port satisfy a first preset relationship;
a third determining module, configured to determine that the receiving device is in a fourth state in which reception of data transmitted by the transmitting device is not allowed, in a case where it is determined that target data transmitted by the transmitting device is received;
a second adjusting module, configured to, when it is determined that the target data has been fetched from the target buffer included in the receiving device, adjust the state value of the second target port, so that the state value of the second target port and the state value of the first target port satisfy the first preset relationship.
20. A computer-readable storage medium, in which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 8 or 9 to 17.
21. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method as claimed in any one of claims 1 to 8 or 9 to 17 are implemented when the computer program is executed by the processor.
CN202111576260.XA 2021-12-21 2021-12-21 Method and device for adjusting equipment state, storage medium and electronic device Active CN114338530B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111576260.XA CN114338530B (en) 2021-12-21 2021-12-21 Method and device for adjusting equipment state, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111576260.XA CN114338530B (en) 2021-12-21 2021-12-21 Method and device for adjusting equipment state, storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN114338530A true CN114338530A (en) 2022-04-12
CN114338530B CN114338530B (en) 2023-09-29

Family

ID=81054988

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111576260.XA Active CN114338530B (en) 2021-12-21 2021-12-21 Method and device for adjusting equipment state, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN114338530B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5434872A (en) * 1992-07-28 1995-07-18 3Com Corporation Apparatus for automatic initiation of data transmission
US5960215A (en) * 1996-09-12 1999-09-28 Digital Equipment Corporation Transmit data FIFO for flow controlled data
JP2004157631A (en) * 2002-11-05 2004-06-03 Yaskawa Electric Corp I/o transmission master device
JP2004274395A (en) * 2003-03-07 2004-09-30 Omron Corp Duplicate address detecting method, slave and master in field bus system, and field bus
WO2012106973A1 (en) * 2011-02-10 2012-08-16 中兴通讯股份有限公司 Uart-based wake-up from sleep method and device
CN105955920A (en) * 2016-04-25 2016-09-21 浪潮电子信息产业股份有限公司 Credit-based flow control mechanism design method in network on chip
US20190155768A1 (en) * 2017-10-20 2019-05-23 Graphcore Limited Sending data off-chip
CN110380719A (en) * 2018-04-13 2019-10-25 合肥杰发科技有限公司 Data transmission circuit, control system and the control device of chip
US20200214039A1 (en) * 2018-12-31 2020-07-02 Fortinet, Inc. Increasing downstream network throughput from access points in data communication systems using transmit opportunities from rts (request to send)frame errors
CN113312284A (en) * 2021-06-03 2021-08-27 杭州华橙软件技术有限公司 Data transmission method, device, system, storage medium and electronic device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5434872A (en) * 1992-07-28 1995-07-18 3Com Corporation Apparatus for automatic initiation of data transmission
US5960215A (en) * 1996-09-12 1999-09-28 Digital Equipment Corporation Transmit data FIFO for flow controlled data
JP2004157631A (en) * 2002-11-05 2004-06-03 Yaskawa Electric Corp I/o transmission master device
JP2004274395A (en) * 2003-03-07 2004-09-30 Omron Corp Duplicate address detecting method, slave and master in field bus system, and field bus
WO2012106973A1 (en) * 2011-02-10 2012-08-16 中兴通讯股份有限公司 Uart-based wake-up from sleep method and device
CN105955920A (en) * 2016-04-25 2016-09-21 浪潮电子信息产业股份有限公司 Credit-based flow control mechanism design method in network on chip
US20190155768A1 (en) * 2017-10-20 2019-05-23 Graphcore Limited Sending data off-chip
CN110380719A (en) * 2018-04-13 2019-10-25 合肥杰发科技有限公司 Data transmission circuit, control system and the control device of chip
US20200214039A1 (en) * 2018-12-31 2020-07-02 Fortinet, Inc. Increasing downstream network throughput from access points in data communication systems using transmit opportunities from rts (request to send)frame errors
CN113312284A (en) * 2021-06-03 2021-08-27 杭州华橙软件技术有限公司 Data transmission method, device, system, storage medium and electronic device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
黄建国: "PC机与单片机多机实时通信的设计与实现", 电子工程师, no. 07 *

Also Published As

Publication number Publication date
CN114338530B (en) 2023-09-29

Similar Documents

Publication Publication Date Title
CN106817264B (en) Method, device and system for detecting link fault
CN111818632A (en) Method, device, equipment and storage medium for equipment synchronization
WO2019042421A1 (en) Method, apparatus and device for rate adjustment of usb data transmission, and storage medium
CN103577362B (en) Method for improving data transmission and related computer system
CN110662237B (en) Data transmission method and device, storage medium and electronic device
CN115687226A (en) I2c bus communication method, device and readable storage medium
EP0893019B1 (en) Multiplex communication interface circuit and method
CN114338530A (en) Method and device for adjusting equipment state, storage medium and electronic device
CN115733729B (en) Communication fault processing method, system and equipment
US8259609B2 (en) Modem and packet processing method
CN111885022A (en) Mimicry communication method based on communication interface, communication architecture and terminal equipment
CN114338270B (en) Data communication method, device, electronic equipment and storage medium
US20050021892A1 (en) Data transferring system using USB and method thereof
CN114338477A (en) Communication link monitoring method, device, equipment and storage medium
CN112769196A (en) Charging control method and device, electronic equipment and charger
CN106708759B (en) Method for controlling digital input/output interface and processor
US6643717B1 (en) Flow control
US20140153384A1 (en) Electronic device and transmission control method
JP4069125B2 (en) Transmission method, transmission apparatus, and transmission / reception system
US20180076933A1 (en) Usb device, data transfer system and data transfer method
CN113672544B (en) Matching method for serial port communication transmission rate
US10013304B2 (en) Electrical apparatus, control device and communication method that control communications performed at different communication rates
CN109587363B (en) Modem
US11757799B2 (en) Line monitor device and network switch
CN103338124B (en) The processing method of abnormal chain scission, device and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant