CN113177016A - Serial port communication method, device, terminal equipment and storage medium - Google Patents
Serial port communication method, device, terminal equipment and storage medium Download PDFInfo
- Publication number
- CN113177016A CN113177016A CN202110571049.2A CN202110571049A CN113177016A CN 113177016 A CN113177016 A CN 113177016A CN 202110571049 A CN202110571049 A CN 202110571049A CN 113177016 A CN113177016 A CN 113177016A
- Authority
- CN
- China
- Prior art keywords
- serial port
- data
- serial
- processor
- instruction
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000004891 communication Methods 0.000 title claims abstract description 113
- 238000000034 method Methods 0.000 title claims abstract description 42
- 238000012544 monitoring process Methods 0.000 claims description 14
- 230000002618 waking effect Effects 0.000 claims description 8
- 238000012790 confirmation Methods 0.000 claims description 4
- 230000002829 reductive effect Effects 0.000 abstract description 6
- 230000007613 environmental effect Effects 0.000 abstract description 5
- 230000000694 effects Effects 0.000 abstract description 3
- 230000005540 biological transmission Effects 0.000 description 10
- 238000011161 development Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 238000004590 computer program Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 235000013305 food Nutrition 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 2
- 230000036528 appetite Effects 0.000 description 1
- 235000019789 appetite Nutrition 0.000 description 1
- 230000008094 contradictory effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 229920006238 degradable plastic Polymers 0.000 description 1
- 230000005611 electricity Effects 0.000 description 1
- 238000005265 energy consumption Methods 0.000 description 1
- 235000013410 fast food Nutrition 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000000670 limiting effect Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 230000036961 partial effect Effects 0.000 description 1
- 239000004033 plastic Substances 0.000 description 1
- 229920003023 plastic Polymers 0.000 description 1
- 238000004064 recycling Methods 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3234—Power saving characterised by the action undertaken
- G06F1/325—Power saving in peripheral device
- G06F1/3253—Power saving in bus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4418—Suspend and resume; Hibernate and awake
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computer Security & Cryptography (AREA)
- Information Transfer Systems (AREA)
Abstract
The invention discloses a serial communication method, a device, terminal equipment and a storage medium, wherein the method comprises the following steps: the method comprises the steps that control lines with IO port interrupt are respectively added on both sides of serial port communication in advance and used for awakening and opening the serial port, the serial port is in a normally closed state in default, when a serial port data sending end receives a serial port data sending instruction or serial port data, a serial port data receiving end is awakened through the control lines and enabled to open the serial port, the awakened instruction is returned after the serial port data receiving end is awakened and the serial port is opened, when the awakened instruction is received by the serial port data sending end, the serial port is opened and the serial port data is sent, and when the serial port data is sent and the serial port communication is not carried out within preset time, both sides automatically close the serial port. The problem that no technical scheme can limit serial communication power consumption in the prior art is solved, serial communication power consumption is reduced, and the effects of environmental protection and power saving are achieved.
Description
Technical Field
The present invention relates to the field of data transmission, and in particular, to a serial communication method, apparatus, terminal device, and storage medium.
Background
With the development of science and technology, people also pay attention to the protection of the environment when pursuing product performance, for example, the vigorous development of electric vehicle enterprises, the apple mobile phone is changed into new one, and most faucet enterprises are about to advocate the protection of the environment. In electronic products, serial communication is a very common serial communication mode and can be used for data transmission of processors, so that people can realize various functions through a plurality of processors, sensors and other electronic devices, but serial ports for serial communication equipped in the existing processors are usually in a normally open state, so that the processors can continuously generate energy consumption when serial data is not sent, especially in a battery power supply system, the use of serial communication is greatly limited by the problem of power consumption, and no scheme capable of well limiting the power consumption of serial communication exists in the prior art.
Thus, there is still a need for improvement and development of the prior art.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a serial communication method, device, terminal device and storage medium, aiming at the above defects in the prior art, the present invention solves the problem of large power consumption caused by the fact that the serial port of each processor for serial communication is always in a normally open state, and in order to solve the above technical problem, the technical scheme adopted by the present invention is as follows:
a serial port communication method comprises the following steps:
a control line with IO port interruption is respectively added to both sides of serial port communication in advance for awakening and starting the serial port;
monitoring whether a serial port data to-be-sent instruction from the inside of a processor is received or not;
when a serial port data to-be-sent instruction is received, controlling to send a wake-up instruction to a serial port data receiving end through the control line, and informing the serial port data receiving end to wake up and start a serial port;
receiving a command which is returned by a serial port data receiving end and wakes up the serial port and waits for receiving data;
when receiving a command which is returned by the serial port data receiving end and wakes up the serial port and waits for receiving data, controlling to send serial port data to the serial port data receiving end for serial port communication;
and when the serial port data is sent and the serial port communication is not carried out within the preset time, controlling to close the serial port.
The serial port communication method, wherein, the control lines with IO port interrupt are respectively added at both sides of the serial port communication in advance, and the step for waking up and opening the serial port comprises:
the control line with IO port interrupt comprises a wake-up instruction transmitting port and a wake-up instruction receiving port;
a wake-up instruction sending port which is preset on the processor and is used for sending a wake-up instruction to the serial port data receiving terminal to inform the serial port data receiving terminal of starting to send serial port data, so that the serial port data receiving terminal starts a serial port;
the awakening instruction receiving port is arranged on the processor in advance and used for receiving an awakened serial port and waiting for receiving a data instruction sent by the serial port data receiving end, informing the processor of being ready to receive serial port data and enabling the processor to start the serial port.
The serial port communication method, wherein, the step of adding control lines with IO port interrupt at both sides of serial port communication in advance for waking up and opening the serial port further comprises:
presetting a timer, setting preset time T, starting timing when a serial port data to-be-sent instruction is received, and closing the serial port of the processor when the serial port of the processor exceeds the preset time T and serial port communication is not performed;
the serial port is preset on the processor and comprises a sending serial port and a receiving serial port, and the sending serial port and the receiving serial port are used for sending or receiving serial port data during serial port communication;
the serial port on the processor is preset to be initialized to be in a closed state.
The serial port communication method comprises the following steps that when a serial port data to-be-sent instruction is received, a control unit sends a wakeup instruction to a serial port data receiving end through a control line, and the step of informing the serial port data receiving end to wake up and start a serial port comprises the following steps:
monitoring a received serial port data to-be-sent instruction, and informing a serial port of needing to send serial port data;
starting a timer for timing;
and controlling the awakening instruction sending port to send an awakening instruction to the serial port data receiving end so that the serial port data receiving end awakens to open the serial port.
The serial port communication method comprises the following steps of receiving a command which is returned by a serial port data receiving end and awakens a serial port and waits for receiving data, wherein the command comprises:
receiving a command which is returned by a serial port data receiving end and wakes up the serial port and waits for receiving data;
and opening the serial port.
The serial port communication method comprises the following steps of when a command which is returned by a serial port data receiving terminal and awakens a serial port and waits for receiving data is received, controlling to send serial port data to the serial port data receiving terminal for serial port communication:
and sending the serial port data to a serial port data receiving end through a serial port of the processor.
The serial port communication method comprises the following steps that when the serial port data are sent and no serial port communication is carried out within preset time, the serial port is controlled to be closed:
when the serial port data is sent out, and no serial port communication is carried out within preset time;
and closing the serial port.
A serial communication device, wherein the device comprises:
the monitoring module is used for monitoring serial port data to-be-sent instructions sent from the inside of the processor;
the awakening module is used for sending an awakening instruction to the serial port data receiving end and informing the serial port data receiving end that serial port communication is about to be carried out;
the awakening confirmation module is used for receiving an awakened serial port returned by the serial port data receiving end, waiting for a data receiving instruction and controlling to open the serial port of the processor;
the data sending module is used for sending the serial port data to a serial port data receiving end;
and the timing module is used for closing the serial port when the processor does not carry out serial port communication within the preset time.
A serial communication device comprises a memory, a processor and a serial communication program which is stored in the memory and can run on the processor, wherein the processor executes the serial communication program, and the step of realizing any serial communication method is realized.
A computer-readable storage medium, wherein a serial communication program is stored on the computer-readable storage medium, and when the image display program is executed by a processor, the steps of any one of the serial communication methods are implemented.
Has the advantages that: compared with the prior art, the invention provides a serial port communication method, which adopts the following steps: when the processor does not need to carry out serial port communication, the serial port is closed, so that the power consumption of the processor is reduced; when the processor needs to carry out serial port communication, a wake-up instruction is sent to the serial port data receiving end firstly, the serial port data receiving end is waited to return a data to-be-received instruction, when the processor confirms that both sides of the serial port communication open the serial port, the serial port data is sent, when the serial port data is sent completely and no serial port communication exists within preset time, the serial port is closed again, the serial port of the processor is opened only when the serial port communication is required, and the serial port is closed in other time, so that the system power consumption is saved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a specific implementation of a serial communication method according to an embodiment of the present invention.
Fig. 2 is a schematic flow chart illustrating presetting a control line for a serial port in an embodiment of the present invention.
Fig. 3 is a schematic flowchart of a process when a serial data transmitting end receives a serial data to-be-transmitted instruction from a processor according to an embodiment of the present invention.
Fig. 4 is a schematic flowchart of a process of waking up a serial port and waiting for receiving a data instruction when a serial port data transmitting end receives a return instruction, according to an embodiment of the present invention.
Fig. 5 is a schematic flow chart illustrating controlling sending of serial data to perform serial communication according to an embodiment of the present invention.
Fig. 6 is a schematic flowchart of a process of closing a serial port when serial port data is sent and serial port communication is not performed within a predetermined time according to an embodiment of the present invention.
Fig. 7 is a graph of data obtained in a second embodiment of the present invention.
Fig. 8 is a schematic block diagram of a serial communication device according to an embodiment of the present invention.
Fig. 9 is a schematic diagram of an internal structure of a terminal device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
It should be noted that, if directional indications (such as up, down, left, right, front, and back … …) are involved in the embodiment of the present invention, the directional indications are only used to explain the relative positional relationship between the components, the movement situation, and the like in a specific posture (as shown in the drawing), and if the specific posture is changed, the directional indications are changed accordingly.
In addition, if there is a description of "first", "second", etc. in an embodiment of the present invention, the description of "first", "second", etc. is for descriptive purposes only and is not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present invention.
With the development of science and technology, people focus on sustainable development while pursuing high and new science and technology development, and people all realize that resources can be continuously requested and exchanged only on the premise of keeping good relationship with the nature, which is mainly embodied in the wide popularization of degradable plastics, the situation that the cola coffee eaten in fast food restaurants does not provide a cover any more, the situation that the plastic bags in supermarkets start to charge and the like, except for small details in daily life, the policy of encouraging the purchase of electric vehicles and the old and new products of apple companies, and the rise of various electronic goods recycling stations, and the spirit of environmental protection are embodied. The most conceivable words of environmental protection are saving, water resource saving, electricity saving, grain saving and the like, for daily life of people, when a water tap is closed, an electric device is closed and eating, the people can buy the food in an amount equivalent to the appetite of the people as much as possible, for enterprises, particularly electronic equipment enterprises, environment-friendly materials are used, the reduction of power consumption is the target of the enterprises, and when the technological content of the product is high enough, the propaganda of the environmental protection can lead more consumers to buy the food. For example, serial communication between processors and sensors, some processors or between processors and sensors are in serial communication every moment, some processors are in serial communication only when data transmission is required, and some processors are not in serial communication for 99% of the time, such as CSR1020 and NDN 9205. In the existing processor, no matter what kind of processor needs to carry out serial communication, the serial port of the processor is in a normally open state, so that partial power consumption of the processor is wasted, and the processor is not environment-friendly and energy-saving.
In order to solve the problems in the prior art, this embodiment provides a serial port communication method, in which a processor closes its serial port when serial port communication is not performed, and sends a wakeup instruction to a serial port data receiving end when the processor needs to perform serial port data transmission, the receiving end receives the wakeup instruction and then opens the serial port and returns the wakeup serial port and waits for a data receiving instruction to notify that the processor at the serial port data transmitting end is ready to receive serial port data, the processor at the serial port data transmitting end receives the wakeup serial port returned by the serial port data receiving end and then opens the serial port and transmits the serial port data after waiting for a data receiving instruction, and when the serial port data transmission is completed and no more serial port data transmission is performed within a period of time, the serial port is automatically closed to save power consumption. By applying the technical scheme, the system power consumption can be reduced according to the condition that each processor uses serial port communication.
Exemplary method
First embodiment
As shown in fig. 1, an embodiment of the present invention provides a serial communication method, which may be used in devices with processors, such as mobile phones and computers. In an embodiment of the present invention, the method includes the steps of:
step S100, adding control lines with IO port interrupt to both sides of serial port communication in advance for awakening and starting the serial port;
in this embodiment, in order to close the serial port of the processor without performing serial port communication for a long time, control lines with IO port interrupt are respectively added to the transmitting end of the serial port data and the receiving end of the serial port data, so as to control to open the serial port when serial port communication is required, and close the serial port when no serial port communication is performed within a predetermined time.
Specifically, as shown in fig. 2, the step S100 includes:
step S101, the control line with IO port interrupt comprises a wake-up instruction transmitting port and a wake-up instruction receiving port;
step S102, a wakeup instruction sending port which is preset on the processor and used for sending a wakeup instruction to a serial port data receiving terminal to inform the serial port data receiving terminal to start sending serial port data to enable the serial port data receiving terminal to start a serial port;
and step S103, a wakeup instruction receiving port preset on the processor and used for receiving a wakeup serial port sent by the serial port data receiving end and waiting for receiving a data instruction, informing the processor of being ready to receive serial port data and enabling the processor to start the serial port.
For example, to add the function of controlling the opening and closing of the serial port to a processor a for sending serial port data and a processor B for receiving serial port data to reduce the power consumption of serial port communication, two IO ports with interrupts are respectively added to the processor a and the processor B, including a wakeup instruction sending port and a wakeup instruction receiving port, the wakeup instruction sending port arranged on the processor a and the processor B is used for sending a wakeup instruction to a serial port data receiving end, so that the processor a sends the wakeup instruction to the processor B in the case that the processor a is a serial port data sending end, the processor B receives the wakeup instruction sent by the processor a through the wakeup instruction receiving port, opens the serial port, sends the wakeup instruction that has awakened the serial port and waits for receiving data through the wakeup instruction sending port of the processor B, and receives the wakeup instruction by the wakeup instruction receiving port of the processor a, and turns on the serial port of processor a.
Wherein, the control line that has IO mouth interrupt is increased respectively at serial port communication both sides in advance for still include after the step of awakening the serial ports of opening:
presetting a timer, setting preset time T, starting timing when a serial port data to-be-sent instruction is received, and closing the serial port of the processor when the serial port of the processor exceeds the preset time T and serial port communication is not performed;
the serial port is preset on the processor and comprises a sending serial port and a receiving serial port, and the sending serial port and the receiving serial port are used for sending or receiving serial port data during serial port communication;
the serial port on the processor is preset to be initialized to be in a closed state.
For example, in order to enable the processor a and the processor B to perform serial communication, a sending serial port and a receiving serial port are respectively installed on the processor a and the processor B, and the sending serial port and the receiving serial port are preset to be in a closed state. And respectively adding a timer into the processor A and the processor B, setting the time to be 1s, resetting the time of the timer for the last time when the last data transmission is carried out between the processor A and the processor B, and automatically closing the serial ports of the processor A and the processor B if no data transmission exists in the next 1 s.
Further, step S200, monitoring whether a serial port data to-be-sent instruction from the inside of the processor is received;
in this embodiment, when the processor needs to send serial data, it needs to send a serial data to-be-sent instruction to the serial port first, and may also notify the serial port that serial data is about to be sent in a form of directly sending data information, and perform corresponding serial port opening and preparation for waking up a serial data receiving end to open the serial port.
For example, when the processor a needs to transmit the 36.5 ℃ information to the processor B through the serial port, the processor a receives a serial port data to-be-transmitted instruction or directly receives the 36.5 ℃ information, and further sends a wake-up instruction to the processor B through the instruction or the information; and if the processor A does not receive any data or serial port data to-be-sent instructions all the time, the serial port of the processor A keeps in a closed state all the time.
Further, step S300, when receiving a serial port data to-be-sent instruction, controlling to send a wakeup instruction to the serial port data receiving terminal through the control line, and notifying the serial port data receiving terminal to wake up to open the serial port;
in this embodiment, after the serial port receives a data to-be-sent instruction or data information of the processor, the wake-up instruction is sent to the serial port data receiving terminal through the wake-up instruction sending port, and the serial port data receiving terminal is woken up to start the serial port and wait for data reception.
Specifically, as shown in fig. 3, the step S300 includes:
step S301, monitoring a received serial port data to-be-sent instruction, and informing a serial port that serial port data needs to be sent;
step S302, starting a timer to time;
and step S303, controlling the awakening instruction sending port to send an awakening instruction to the serial port data receiving end, so that the serial port data receiving end awakens to open the serial port.
For example, when the serial port of the processor a detects that the serial port data to-be-sent instruction or the temperature data sent by the processor is 36.5 ℃, the timer starts to count time, and controls the wake-up instruction sending port of the processor a to send the wake-up instruction to the serial port of the processor B, so that the processor B opens the serial port to wait for the transmission of the serial port data.
Further, step S400, receiving a command that the serial port has been awakened and waits for receiving data, which is returned by the serial port data receiving terminal;
in this embodiment, after the wake-up instruction sent by the serial data sending terminal is received by the serial data receiving terminal, the serial data receiving terminal wakes up to start the serial port and starts the timer, and the wake-up instruction sending port returns a command that has awakened the serial port and waits for receiving data, and the command is received by the serial data sending terminal.
Specifically, as shown in fig. 4, the step S400 includes:
step S401, receiving a command which is returned by a serial port data receiving end and wakes up a serial port and waits for receiving data;
and step S402, opening the serial port.
For example, after the processor a sends a wake-up instruction to the processor B through the wake-up instruction sending port, the wake-up instruction receiving port of the processor B receives the wake-up instruction and starts the timer to time, and then sends a serial port that has been woken up and waits to receive a data instruction to the processor a through the wake-up instruction sending port of the processor B, and when the wake-up instruction receiving port of the processor a receives the serial port that has been woken up and waits to receive the data instruction, starts the serial port and prepares to start sending data.
Further, step S500, when receiving a command that the serial port has been awakened and waits for receiving data, which is returned by the serial port data receiving terminal, controlling to send serial port data to the serial port data receiving terminal for serial port communication;
in this embodiment, when the serial data transmitting terminal receives a command that the serial data receiving terminal has wakened up the serial port and waits for receiving data, and the receiving terminal and the transmitting terminal both open the serial port, the serial data transmitting terminal is controlled to transmit serial data to the serial data receiving terminal.
Specifically, as shown in fig. 5, the step S500 includes:
step S501, serial port data are sent to a serial port data receiving end through a serial port of the processor.
For example, when the processor a receives the command of waking up the serial port and waiting for receiving data, which is returned by the processor B, through the wake-up command receiving end, the serial port is controlled to send serial port data of 36.5 ℃ to the processor B.
Further, in step S600, when the serial data is sent and the serial communication is not performed within the predetermined time, the serial is controlled to be closed.
In this embodiment, when all serial data are sent and no serial communication is performed between the serial data sending end and the serial data receiving end within a preset time, the serial port is automatically closed, and the preset time is the time for resetting the timers of the serial data sending end and the serial data receiving end.
Specifically, as shown in fig. 6, step S600 includes:
step S601, when the serial port data is sent completely and no serial port communication is carried out within preset time;
and step S602, closing the serial port.
For example, after the processor a finishes sending the data at 36.5 ℃, ten groups of temperature data are sent in series, and one group is sent at an interval of 0.1s, the timers of the processor a and the processor B are overtime after the last data sending is finished and 1s is waited, and the serial port is automatically closed. If the serial port data needs to be sent again after 10s, the serial port data receiving end is awakened in an awakening mode, the serial ports of the two parties are opened, and then serial port communication is continued.
In a second embodiment, as shown in fig. 7, under an MDM9205 platform in actual use, the MDM9205 communicates with a bluetooth IC CSR1020 through a serial port, and before a control line with IO port interrupt is added, the standby current of the MDM9205 is 9mA, and the standby current of the CSR1020 is 1.3 mA; after the control line with IO port interruption is added, the standby current of the MDM9205 is 1mA, the standby current of the CSR1020 is 0.3mA, and compared with the situation that before the serial port is controlled, the serial port of the MDM9205 is in a closed state for 99% of time, the current of 8mA is reduced, the serial port of the CSR1020 is in a closed state for 99% of time, the current of 1mA is reduced, and a very ideal energy-saving effect is achieved.
Exemplary device
As shown in fig. 8, an embodiment of the present invention provides a serial communication device, including: the monitoring module 810, the wake-up module 820, the wake-up confirmation module 830, the data transmission module 840, and the timing module 850. Specifically, the monitoring module 810 is configured to monitor a serial port data to-be-sent instruction sent from inside of the processor; the wake-up module 820 is configured to send a wake-up instruction to a serial data receiving end to notify the serial data receiving end that serial communication is about to be performed; the awakening confirmation module 830 is configured to receive an awakened serial port returned by the serial port data receiving end, wait for a data receiving instruction, and control to open the serial port of the processor; the data sending module 840 is configured to send serial port data to a serial port data receiving end; the timing module 850 is configured to close the serial port when the processor does not perform serial port communication within a preset time.
Based on the above embodiments, the present invention further provides a terminal device, and a schematic block diagram thereof may be as shown in fig. 9. The terminal equipment comprises a processor, a memory, a network interface and a display screen which are connected through a system bus. Wherein the processor of the terminal device is configured to provide computing and control capabilities. The memory of the terminal equipment comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the terminal device is used for connecting and communicating with an external terminal through a network. The computer program is executed by a processor to implement a serial communication method. The display screen of the terminal equipment can be a liquid crystal display screen or an electronic ink display screen.
It will be understood by those skilled in the art that the block diagram of fig. 9 is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation to the terminal device to which the solution of the present invention is applied, and a specific terminal device may include more or less components than those shown in the figure, or combine some components, or have a different arrangement of components.
In one embodiment, there is provided a terminal device, the terminal device comprising a memory, a processor and a terminal data processing program stored on and executable on the processor, the processor performing the steps of:
a control line with IO port interruption is respectively added to both sides of serial port communication in advance for awakening and starting the serial port;
monitoring whether a serial port data to-be-sent instruction from the inside of a processor is received or not;
when a serial port data to-be-sent instruction is received, controlling to send a wake-up instruction to a serial port data receiving end through the control line, and informing the serial port data receiving end to wake up and start a serial port;
receiving a command which is returned by a serial port data receiving end and wakes up the serial port and waits for receiving data;
when receiving a command which is returned by the serial port data receiving end and wakes up the serial port and waits for receiving data, controlling to send serial port data to the serial port data receiving end for serial port communication;
and when the serial port data is sent and the serial port communication is not carried out within the preset time, controlling to close the serial port.
Wherein, the control line that has IO mouth interrupt is increased respectively at serial port communication both sides in advance for awaken the step of opening the serial ports including:
the control line with IO port interrupt comprises a wake-up instruction transmitting port and a wake-up instruction receiving port;
a wake-up instruction sending port which is preset on the processor and is used for sending a wake-up instruction to the serial port data receiving terminal to inform the serial port data receiving terminal of starting to send serial port data, so that the serial port data receiving terminal starts a serial port;
the awakening instruction receiving port is arranged on the processor in advance and used for receiving an awakened serial port and waiting for receiving a data instruction sent by the serial port data receiving end, informing the processor of being ready to receive serial port data and enabling the processor to start the serial port.
Wherein, the control line that has IO mouth interrupt is increased respectively at serial port communication both sides in advance for still include after the step of awakening the serial ports of opening:
presetting a timer, setting preset time T, starting timing when a serial port data to-be-sent instruction is received, and closing the serial port of the processor when the serial port of the processor exceeds the preset time T and serial port communication is not performed;
the serial port is preset on the processor and comprises a sending serial port and a receiving serial port, and the sending serial port and the receiving serial port are used for sending or receiving serial port data during serial port communication;
the serial port on the processor is preset to be initialized to be in a closed state.
When a serial port data to-be-sent instruction is received, the control unit sends a wake-up instruction to the serial port data receiving end through the control line, and the step of informing the serial port data receiving end to wake up and start the serial port comprises the following steps:
monitoring a received serial port data to-be-sent instruction, and informing a serial port of needing to send serial port data;
starting a timer for timing;
and controlling the awakening instruction sending port to send an awakening instruction to the serial port data receiving end so that the serial port data receiving end awakens to open the serial port.
The step of receiving the command which is returned by the serial port data receiving end and wakes up the serial port and waits for receiving data comprises the following steps:
receiving a command which is returned by a serial port data receiving end and wakes up the serial port and waits for receiving data;
and opening the serial port.
When receiving a command which is returned by the serial port data receiving end and awakens the serial port and waits for receiving data, the step of controlling the serial port data to be sent to the serial port data receiving end for serial port communication comprises the following steps:
and sending the serial port data to a serial port data receiving end through a serial port of the processor.
Wherein, when the serial data is sent and no serial communication is carried out within the preset time, the step of controlling to close the serial comprises the following steps:
when the serial port data is sent out, and no serial port communication is carried out within preset time;
and closing the serial port.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, databases, or other media used in embodiments provided herein may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
In summary, the present invention discloses a serial communication method, an apparatus, a terminal device and a storage medium, wherein the method comprises: the method comprises the steps that control lines with IO port interrupt are respectively added on both sides of serial port communication in advance and used for awakening and opening the serial port, the serial port is in a normally closed state in default, when a serial port data sending end receives a serial port data sending instruction or serial port data, a serial port data receiving end is awakened through the control lines and enabled to open the serial port, the awakened instruction is returned after the serial port data receiving end is awakened and the serial port is opened, when the awakened instruction is received by the serial port data sending end, the serial port is opened and the serial port data is sent, and when the serial port data is sent and the serial port communication is not carried out within preset time, both sides automatically close the serial port. The problem that no technical scheme can limit serial communication power consumption in the prior art is solved, serial communication power consumption is reduced, and the effects of environmental protection and power saving are achieved.
It is to be understood that the invention disclosed is not limited to the examples described above, but may be modified or varied by those skilled in the art, all falling within the scope of the invention as defined by the appended claims.
Claims (10)
1. A serial port communication method is characterized by comprising the following steps:
a control line with IO port interruption is respectively added to both sides of serial port communication in advance for awakening and starting the serial port;
monitoring whether a serial port data to-be-sent instruction from the inside of a processor is received or not;
when a serial port data to-be-sent instruction is received, controlling to send a wake-up instruction to a serial port data receiving end through the control line, and informing the serial port data receiving end to wake up and start a serial port;
receiving a command which is returned by a serial port data receiving end and wakes up the serial port and waits for receiving data;
when receiving a command which is returned by the serial port data receiving end and wakes up the serial port and waits for receiving data, controlling to send serial port data to the serial port data receiving end for serial port communication;
and when the serial port data is sent and the serial port communication is not carried out within the preset time, controlling to close the serial port.
2. The serial port communication method according to claim 1, wherein the step of adding control lines with IO port interrupt to both sides of the serial port communication in advance for waking up to open the serial port comprises:
the control line with IO port interrupt comprises a wake-up instruction transmitting port and a wake-up instruction receiving port;
a wake-up instruction sending port which is preset on the processor and is used for sending a wake-up instruction to the serial port data receiving terminal to inform the serial port data receiving terminal of starting to send serial port data, so that the serial port data receiving terminal starts a serial port;
the awakening instruction receiving port is arranged on the processor in advance and used for receiving an awakened serial port and waiting for receiving a data instruction sent by the serial port data receiving end, informing the processor of being ready to receive serial port data and enabling the processor to start the serial port.
3. The serial port communication method according to claim 2, wherein the step of adding control lines with IO port interrupts to both sides of the serial port communication in advance for waking up and opening the serial port further comprises:
presetting a timer, setting preset time T, starting timing when a serial port data to-be-sent instruction is received, and closing the serial port of the processor when the serial port of the processor exceeds the preset time T and serial port communication is not performed;
the serial port is preset on the processor and comprises a sending serial port and a receiving serial port, and the sending serial port and the receiving serial port are used for sending or receiving serial port data during serial port communication;
the serial port on the processor is preset to be initialized to be in a closed state.
4. The serial port communication method according to claim 1, wherein the step of controlling sending a wake-up command to the serial port data receiving terminal through the control line when receiving a serial port data to-be-sent command, and informing the serial port data receiving terminal to wake up and open the serial port comprises:
monitoring a received serial port data to-be-sent instruction, and informing a serial port of needing to send serial port data;
starting a timer for timing;
and controlling the awakening instruction sending port to send an awakening instruction to the serial port data receiving end so that the serial port data receiving end awakens to open the serial port.
5. The serial port communication method according to claim 1, wherein the step of receiving the command that the serial port has been awakened and waits for receiving data, which is returned by the serial port data receiving terminal, comprises:
receiving a command which is returned by a serial port data receiving end and wakes up the serial port and waits for receiving data;
and opening the serial port.
6. The serial port communication method according to claim 1, wherein the step of controlling the serial port data to be sent to the serial port data receiving terminal for serial port communication when receiving the command of waking up the serial port and waiting for receiving the data returned by the serial port data receiving terminal comprises:
and sending the serial port data to a serial port data receiving end through a serial port of the processor.
7. The serial port communication method according to claim 1, wherein the step of controlling to close the serial port when the serial port data is sent and the serial port communication is not performed within a predetermined time comprises:
when the serial port data is sent out, and no serial port communication is carried out within preset time;
and closing the serial port.
8. A serial communication device, comprising:
the monitoring module is used for monitoring serial port data to-be-sent instructions sent from the inside of the processor;
the awakening module is used for sending an awakening instruction to the serial port data receiving end and informing the serial port data receiving end that serial port communication is about to be carried out;
the awakening confirmation module is used for receiving an awakened serial port returned by the serial port data receiving end, waiting for a data receiving instruction and controlling to open the serial port of the processor;
the data sending module is used for sending the serial port data to a serial port data receiving end;
and the timing module is used for closing the serial port when the processor does not carry out serial port communication within the preset time.
9. A serial communication device, comprising a memory, a processor and a serial communication program stored in the memory and operable on the processor, wherein the execution of the serial communication program by the processor is to implement the serial communication method according to any one of claims 1 to 7.
10. A computer-readable storage medium, wherein a serial communication program is stored on the computer-readable storage medium, and when the image display program is executed by a processor, the steps of the serial communication method according to any one of claims 1 to 7 are implemented.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110571049.2A CN113177016A (en) | 2021-05-25 | 2021-05-25 | Serial port communication method, device, terminal equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110571049.2A CN113177016A (en) | 2021-05-25 | 2021-05-25 | Serial port communication method, device, terminal equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113177016A true CN113177016A (en) | 2021-07-27 |
Family
ID=76928184
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110571049.2A Pending CN113177016A (en) | 2021-05-25 | 2021-05-25 | Serial port communication method, device, terminal equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113177016A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114500627A (en) * | 2021-12-27 | 2022-05-13 | 南京南瑞继保电气有限公司 | Method, device and equipment for remotely accessing serial port equipment and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101150809A (en) * | 2007-11-03 | 2008-03-26 | 青岛海信移动通信技术股份有限公司 | Method for arousing and stream control of mobile terminal processor serial port |
CN101504565A (en) * | 2009-03-04 | 2009-08-12 | 上海闻泰电子科技有限公司 | Method for awakening chip module |
CN102096649A (en) * | 2011-02-10 | 2011-06-15 | 中兴通讯股份有限公司 | UART-based sleep wakeup method and device |
CN104597790A (en) * | 2014-12-26 | 2015-05-06 | 北京兆易创新科技股份有限公司 | Serial port controller and awakening method for micro-controller system based on the same |
CN106372012A (en) * | 2016-08-25 | 2017-02-01 | 长沙丰灼通讯科技有限公司 | Serial port awakening system not using handshake control line and serial port communication method |
CN107589824A (en) * | 2017-09-21 | 2018-01-16 | 上海顺舟智能科技股份有限公司 | It is a kind of to reduce the method for only supporting IO to wake up MCU power consumptions |
CN110324748A (en) * | 2019-07-26 | 2019-10-11 | 歌尔股份有限公司 | A kind of wireless headset serial ports control method, device and wireless headset and storage medium |
-
2021
- 2021-05-25 CN CN202110571049.2A patent/CN113177016A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101150809A (en) * | 2007-11-03 | 2008-03-26 | 青岛海信移动通信技术股份有限公司 | Method for arousing and stream control of mobile terminal processor serial port |
CN101504565A (en) * | 2009-03-04 | 2009-08-12 | 上海闻泰电子科技有限公司 | Method for awakening chip module |
CN102096649A (en) * | 2011-02-10 | 2011-06-15 | 中兴通讯股份有限公司 | UART-based sleep wakeup method and device |
CN104597790A (en) * | 2014-12-26 | 2015-05-06 | 北京兆易创新科技股份有限公司 | Serial port controller and awakening method for micro-controller system based on the same |
CN106372012A (en) * | 2016-08-25 | 2017-02-01 | 长沙丰灼通讯科技有限公司 | Serial port awakening system not using handshake control line and serial port communication method |
CN107589824A (en) * | 2017-09-21 | 2018-01-16 | 上海顺舟智能科技股份有限公司 | It is a kind of to reduce the method for only supporting IO to wake up MCU power consumptions |
CN110324748A (en) * | 2019-07-26 | 2019-10-11 | 歌尔股份有限公司 | A kind of wireless headset serial ports control method, device and wireless headset and storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114500627A (en) * | 2021-12-27 | 2022-05-13 | 南京南瑞继保电气有限公司 | Method, device and equipment for remotely accessing serial port equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106828156B (en) | New energy automobile charging control method and system | |
US6018232A (en) | Method of operating battery powered computing device with radio transmitter | |
CN106255184B (en) | A kind of data transmission method and terminal device | |
US20120054523A1 (en) | Electronic device and data transmission method of the same | |
CN109151961B (en) | Operation method of mobile terminal, terminal and computer readable storage medium | |
WO2016180132A1 (en) | Dormancy method and apparatus for wireless fidelity (wi-fi) device | |
CN109041188B (en) | Wireless terminal, wireless terminal power saving method and device | |
CN104620311A (en) | Memory control device, mobile terminal, memory control program, and computer-readable recording medium | |
CN101539797A (en) | Method, system and device for controlling dynamic clock and power supply | |
CN113177016A (en) | Serial port communication method, device, terminal equipment and storage medium | |
WO2020211520A1 (en) | Transfer bin, transfer system, and information display control method thereof | |
CN112948312B (en) | Chip control method and device, intelligent terminal and computer readable storage medium | |
CN104603867A (en) | Memory control device, mobile terminal, memory control program, and computer-readable recording medium | |
CN111417182A (en) | Data transmission method, device, storage medium, processor and system | |
US6529748B1 (en) | Bilateral power management system | |
US9124463B2 (en) | Communication device with sleep state indicator and state machine control | |
JP2003515765A (en) | Display system | |
WO2024109271A1 (en) | Method and apparatus for adjusting working state of module, device, and medium | |
JP5304526B2 (en) | Wireless access point and wireless LAN terminal having wake-up radio wave transmission function | |
CN113645592A (en) | Vehicle-mounted system control method, device and system and storage medium | |
CN100527725C (en) | Method for regulating power consuming of network interface | |
TW201041364A (en) | Mobile device, power saving method and computer executable medium | |
CN115002881A (en) | Upper computer awakening method, device and system, electronic equipment and storage medium | |
JP3991594B2 (en) | Data processing device | |
CN103177283B (en) | A kind of storage card power down prevention method and device |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210727 |
|
RJ01 | Rejection of invention patent application after publication |