Serial port thread-based information transmission method, device and system

By managing the serial port thread state, the problem of multi-device information transmission caused by insufficient built-in serial ports in the microcontroller unit is solved, achieving efficient information transmission.

CN115718719BActive Publication Date: 2026-06-19GUANGZHOU SHIYUAN ELECTRONICS CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU SHIYUAN ELECTRONICS CO LTD
Filing Date
2021-08-24
Publication Date
2026-06-19

Smart Images

  • Figure CN115718719B_ABST
    Figure CN115718719B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, and system for information transmission based on a serial port thread, belonging to the field of data processing technology. The method includes: after sending first data information to an external device via the serial port thread, changing the state of the serial port thread from a message sending state to a message receiving state; if second data information is not received from the external device within a preset first time period, changing the state of the serial port thread from a message receiving state to a serial port conversion state; and upon obtaining third data information to be sent to another external device, sending the third data information to the other external device via the serial port thread. Using the method in this application embodiment can improve the problem of insufficient built-in serial ports, which prevents information transmission with multiple external devices, without increasing costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and in particular to information transmission methods, apparatus and systems based on serial port threads. Background Technology

[0002] Currently, there is a frequent problem of insufficient built-in serial ports in microcontroller units. When multiple external devices need to be connected, the built-in serial ports often cannot meet the requirements.

[0003] Existing solutions generally involve selecting chips with more serial ports or adding external interface conversion chips to improve the communication by converting other protocol communication ports into serial ports. However, both of these existing solutions require increased costs and redesigns, and they cannot solve the problem once the hardware PCB design is finalized.

[0004] Therefore, there is an urgent need for a method that can improve the problem of insufficient built-in serial ports, which prevents information transmission with multiple external devices, without increasing costs. Summary of the Invention

[0005] This application provides a method, apparatus, and system for information transmission based on serial port threads, which can solve the problem of insufficient built-in serial ports causing the inability to transmit information with multiple external devices.

[0006] The technical solution is as follows:

[0007] In a first aspect, embodiments of this application provide an information transmission method based on a serial port thread, the method being applied to a microcontroller unit, the microcontroller unit running a serial port thread, the method comprising:

[0008] After the serial port thread sends the first data information to an external device, the state of the serial port thread is changed from message sending state to message receiving state.

[0009] If the second data information sent by the external device is not received within the preset first time period, the state of the serial port thread is changed from message receiving state to serial port conversion state, and when the third data information to be sent to another external device is obtained, the third data information is sent to the other external device through the serial port thread.

[0010] Optionally, upon obtaining third data information to be sent to another external device, the third data information is sent to the other external device via the serial port thread, including:

[0011] Change the state of the serial port thread from serial port conversion state to initialization state, and establish a connection between the serial port thread and the control thread corresponding to the other external device.

[0012] Change the state of the serial port thread from the initialization state to the message waiting state;

[0013] If third data information is obtained within a preset second time period from the control thread corresponding to the other external device, the third data information is sent to the other external device through the serial port thread.

[0014] Optionally, changing the state of the serial port thread from serial port conversion state to initialization state includes:

[0015] In response to the user-initiated initialization operation, the state of the serial port thread is changed from the serial port conversion state to the initialization state.

[0016] Optionally, the method further includes:

[0017] If second data information sent by the external device is received within a preset first time period, the second data information is transmitted to the control thread corresponding to the external device through the serial port thread, and the state of the serial port thread is changed from message receiving state to message receiving completed state.

[0018] Optionally, after changing the state of the serial port thread from message receiving state to message receiving completed state, the method further includes:

[0019] If it is determined that no other data information is received from the control thread corresponding to the external device within the preset third time period, the state of the serial port thread is changed from message reception completion state to serial port conversion state.

[0020] Optionally, the method further includes:

[0021] In response to the user-initiated initialization operation, the state of the serial port thread is changed from the initialization state to the message waiting state;

[0022] If the first data information transmitted by the control thread corresponding to the external device is obtained within the preset fourth time period, the state of the serial port thread is changed from the message waiting state to the message sending state, and the first data information is sent to the external device through the serial port thread.

[0023] Optionally, in response to a user-initiated initialization operation, the state of the serial port thread is changed from the initialization state to the message waiting state, including:

[0024] In response to an initialization operation initiated by the user, the state of the serial port thread is set to the initialization state;

[0025] Establish a connection between the serial port thread and the control thread corresponding to the external device, and change the state of the serial port thread from the initialization state to the message waiting state.

[0026] Optionally, the method further includes:

[0027] If the first data information corresponding to the control thread of the external device is not obtained within the preset fourth time period, the state of the serial port thread is changed from the message waiting state to the serial port conversion state.

[0028] Secondly, embodiments of this application provide an information transmission device based on a serial port thread. The device is applied to a microcontroller unit, which runs a serial port thread. The device includes:

[0029] The first data information sending module is used to change the state of the serial port thread from message sending state to message receiving state after the first data information to be sent to an external device is sent through the serial port thread.

[0030] The third data information sending module is used to change the state of the serial port thread from message receiving state to serial port conversion state if the second data information sent by the external device is not received within a preset first time period, and to send the third data information to the other external device through the serial port thread when the third data information to be sent to the other external device is obtained.

[0031] Optionally, the third data information sending module is used for:

[0032] Change the state of the serial port thread from serial port conversion state to initialization state, and establish a connection between the serial port thread and the control thread corresponding to the other external device.

[0033] Change the state of the serial port thread from the initialization state to the message waiting state;

[0034] If third data information is obtained within a preset second time period from the control thread corresponding to the other external device, the third data information is sent to the other external device through the serial port thread.

[0035] Optionally, the third data information sending module is used for:

[0036] In response to the user-initiated initialization operation, the state of the serial port thread is changed from the serial port conversion state to the initialization state.

[0037] Optionally, the device further includes:

[0038] The second data information sending module is used to transmit the second data information to the control thread corresponding to the external device through the serial port thread if the second data information sent by the external device is received within a preset first time period, and to change the state of the serial port thread from message receiving state to message receiving completed state.

[0039] Optionally, the device further includes:

[0040] The other data information determination module is used to change the status of the serial port thread from message reception completion status to serial port conversion status if it is determined that no other data information is received from the control thread corresponding to the external device within a preset third time period.

[0041] Optionally, the device further includes:

[0042] The initialization module is used to respond to user-initiated initialization operations by changing the state of the serial port thread from the initialization state to the message waiting state.

[0043] The first data information acquisition module is used to, if it acquires the first data information transmitted by the control thread corresponding to the external device within a preset fourth time period, change the state of the serial port thread from the message waiting state to the message sending state, and send the first data information to the external device through the serial port thread.

[0044] Optional, an initialization module, used for:

[0045] In response to an initialization operation initiated by the user, the state of the serial port thread is set to the initialization state;

[0046] Establish a connection between the serial port thread and the control thread corresponding to the external device, and change the state of the serial port thread from the initialization state to the message waiting state.

[0047] Optionally, the device further includes:

[0048] The first data information judgment module is used to change the state of the serial port thread from the message waiting state to the serial port conversion state if the first data information transmitted by the control thread corresponding to the external device is not obtained within the preset fourth time period.

[0049] Thirdly, embodiments of this application provide an information transmission system based on a serial port thread, comprising: a microcontroller unit and multiple external devices; the microcontroller unit is electrically connected to each of the external devices;

[0050] The microcontroller unit is used to perform the method as described in the first aspect.

[0051] Fourthly, embodiments of this application provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the method described in the first aspect.

[0052] Fifthly, embodiments of this application provide a microcontroller unit, including: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed as described in the first aspect.

[0053] In a sixth aspect, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.

[0054] In this embodiment, the method is applied to a microcontroller unit that runs a serial port thread. After sending first data information to an external device via the serial port thread, the state of the serial port thread is changed from message sending to message receiving. If second data information is not received from the external device within a preset first time period, the state of the serial port thread is changed from message receiving to serial port conversion. Upon receiving third data information to be sent to another external device, the third data information is sent to that other external device via the serial port thread. Using the method in this embodiment, the problem of insufficient built-in serial ports preventing information transmission with multiple external devices can be improved without increasing costs. Attached Figure Description

[0055] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0056] Figure 1 This is a flowchart illustrating an information transmission method based on a serial port thread provided in Embodiment 1 of this application;

[0057] Figure 2 This is a flowchart illustrating an information transmission method based on a serial port thread provided in Embodiment 2 of this application;

[0058] Figure 3 This is a flowchart illustrating an information transmission method based on a serial port thread provided in Embodiment 3 of this application;

[0059] Figure 4This is a schematic diagram illustrating the interaction process between a microcontroller unit and an external device, as provided in Embodiment 3 of this application.

[0060] Figure 5 This is a schematic diagram of the structure of an information transmission device based on a serial port thread provided in Embodiment 4 of this application;

[0061] Figure 6 This is a schematic diagram of the structure of an information transmission system based on a serial port thread provided in Embodiment 5 of this application;

[0062] Figure 7 This is a schematic diagram of the structure of a microcontroller unit provided in an embodiment of this application. Detailed Implementation

[0063] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0064] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0065] In the following description, when referring to the accompanying drawings, the same numbers in different drawings denote the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0066] In the description of this application, it should be understood that the terms "first," "second," "third," etc., are used only to distinguish similar objects and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances. Furthermore, in the description of this application, unless otherwise stated, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0067] It should be noted that, due to space limitations, this application specification does not exhaustively list all possible implementation methods. Those skilled in the art should be able to conceive after reading this application specification that, as long as the technical features do not contradict each other, any combination of technical features can constitute an optional implementation method.

[0068] The various embodiments are described in detail below.

[0069] Example 1

[0070] This application discloses an information transmission method based on a serial port thread, which is applied to a microcontroller unit, wherein the microcontroller unit runs a serial port thread.

[0071] The information transmission method based on serial port thread provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0072] Please see Figure 1 This is a flowchart illustrating an information transmission method based on a serial port thread, as disclosed in an embodiment of this application. The method includes the following steps:

[0073] S110. After sending the first data information to be sent to an external device through the serial port thread, the state of the serial port thread is changed from message sending state to message receiving state.

[0074] In this embodiment, the serial port thread refers to a time-division multiplexing (TDM) thread. Specifically, TDM is a technology that transmits different signals in the same channel at different time periods. The external device is a device that interacts with the microcontroller unit (MCU). The external device can be a tablet, smartphone, or computer. The first data information is information sent by the MCU to an external device; it can be notification data or data information carrying data content. For example, it could be image data sent by the MCU to an external device.

[0075] In this embodiment, the state of the serial port thread is an indicator used to characterize the current working status of the serial port. Specifically, the state of the serial port thread can include: initialization state, message sending state, message receiving state, serial port conversion state, message waiting state, and message receiving completed state. The initialization state means that all parameters of the serial port thread are in their initial settings; for example, the initialization state can be that all parameters are 0. The message sending state means that the current serial port thread has data to be sent and can execute the data sending command. The message receiving state means that the serial port thread is waiting to receive data from other external devices. The serial port conversion state means that the serial port thread is switching from connecting to one external device to connecting to another. The message waiting state means that the serial port thread is waiting for other threads to send data. The message receiving completed state means that other external devices have successfully sent data to the serial port thread.

[0076] S120. If the second data information sent by the external device is not received within the preset first time period, the state of the serial port thread is changed from the message receiving state to the serial port conversion state, and when the third data information to be sent to another external device is obtained, the third data information is sent to the other external device through the serial port thread.

[0077] In this embodiment, the preset first time period can be adjusted, for example, it can be 20 seconds or other time periods. The second data information is the information exchanged between the external device and the microcontroller unit. This data information can be feedback information regarding the first data information, or it can be data information unrelated to the first data information. The other external device is an electronic device different from the first external device. The other external device can be one or more devices, and it can be a device of the same type as the first external device, or a device of a different type. For example, one external device can be a smartphone, and the other external device can also be a smartphone, or one external device can be a smartphone, and the other external device can be a tablet computer.

[0078] The third data information is the information that the microcontroller specifies to be sent to another external device.

[0079] In this embodiment, if no second data information is received, it indicates that an external device is not currently interacting with the microcontroller, and the serial port thread does not need to be in the message receiving state. If the microcontroller needs to interact with another external device, before doing so, the serial port thread's state is changed from message receiving to serial port conversion state to instruct the microcontroller to interact with the other external device.

[0080] In this embodiment, after sending the first data information to an external device via a serial port thread, if the second data information sent by the external device is not received within a preset first time period, the serial port thread is converted to interact with another external device. This technical solution addresses the problem of insufficient built-in serial ports, which prevents information transmission with multiple external devices, without increasing costs.

[0081] Example 2

[0082] See Figure 2 This is a flowchart illustrating an information transmission method based on a serial port thread, as disclosed in an embodiment of this application. The method includes the following steps:

[0083] S210. After sending the first data information to be sent to an external device through the serial port thread, the state of the serial port thread is changed from message sending state to message receiving state.

[0084] S220. Determine whether a second data message sent by an external device has been received within a preset first time period. If yes, execute S230; otherwise, execute S250.

[0085] S230. If second data information sent by the external device is received within a preset first time period, the second data information is transmitted to the control thread corresponding to the external device through the serial port thread, and the state of the serial port thread is changed from message receiving state to message receiving completed state.

[0086] In this embodiment, the control thread corresponding to an external device is a thread that runs in parallel with the serial port thread, both configured within the microcontroller unit. The control thread can process the received second data information. If second data information sent by an external device is received within a preset first time period, the serial port thread sends it to the corresponding control thread so that the control thread can process the second data information, while the serial port thread continues to perform other operations. In this embodiment, after successfully receiving the second data information, the state of the serial port thread is changed from message receiving state to message receiving completed state.

[0087] S240. If it is determined that no other data information is received from the control thread corresponding to the external device within the preset third time period, the state of the serial port thread is changed from message reception completion state to serial port conversion state.

[0088] In this embodiment, the preset third time period is a user-configurable time period. If no other data information is received from an external device within this time period, it indicates that there is no data exchange between the external device and the microcontroller unit. The microcontroller unit can then interact with another external device and change the serial port thread status from message reception complete to serial port conversion state.

[0089] S250. If the second data information sent by the external device is not received within the preset first time period, the state of the serial port thread is changed from message receiving state to serial port conversion state.

[0090] S260. Change the state of the serial port thread from serial port conversion state to initialization state, and establish a connection between the serial port thread and the control thread corresponding to the other external device.

[0091] In this embodiment, after the serial port thread's state is changed from serial port conversion state to initialization state, it indicates that the microcontroller unit will interact with another external device. Specifically, a connection is first established between the serial port thread and the control thread, which corresponds to the other external device. After the connection is established, the microcontroller unit can interact with the other external device.

[0092] Optionally, changing the state of the serial port thread from serial port conversion state to initialization state includes:

[0093] In response to the user-initiated initialization operation, the state of the serial port thread is changed from the serial port conversion state to the initialization state.

[0094] In this embodiment, the user-initiated initialization operation can be to power on the microcontroller unit, or it can be an initialization operation set by the user to set the current serial port thread to the initialization state.

[0095] S270. Change the state of the serial port thread from the initialization state to the message waiting state.

[0096] In this embodiment, the serial port thread's state is changed from the initialization state to the message waiting state, so the microcontroller unit can receive and process the data information.

[0097] S280. If third data information corresponding to the control thread of the other external device is obtained within a preset second time period, the third data information is sent to the other external device through the serial port thread.

[0098] In this embodiment, the preset second time period can be the same as the first time period or a different time period. During this time period, the control thread sends third data information to the serial port thread and then sends the third data information to another external device, so that the other external device receives and processes the third data information. The control thread corresponds to the other external device.

[0099] In this embodiment, if second data information sent by an external device is received within a preset first time period, the second data information is processed by the control thread. After interacting with an external device via the serial port thread, if no other data information for interaction with a device is received within a preset third time period, the microcontroller is instructed to interact with another external device through a change in the serial port thread state. Using the technical means in this embodiment, the process of the microcontroller interacting with one device can be completed, and after fully completing the interaction with one device, the microcontroller can then interact with another device. This ensures a complete interaction process with devices and allows interaction with multiple devices at different times without increasing costs.

[0100] Implementation 3

[0101] See Figure 3 This is a flowchart illustrating an information transmission method based on a serial port thread, as disclosed in an embodiment of this application. The method includes the following steps:

[0102] S310. In response to the user-initiated initialization operation, change the state of the serial port thread from the initialization state to the message waiting state.

[0103] Optionally, in this embodiment, in response to a user-initiated initialization operation, the state of the serial port thread is changed from the initialization state to the message waiting state, including:

[0104] In response to an initialization operation initiated by the user, the state of the serial port thread is set to the initialization state;

[0105] Establish a connection between the serial port thread and the control thread corresponding to the external device, and change the state of the serial port thread from the initialization state to the message waiting state.

[0106] In this embodiment, a connection is first established between the serial port thread and the control thread. Each control thread corresponds to an external device. After the connection is established, the microcontroller unit can interact with the external device. It is worth noting that different control threads correspond to different external devices. After establishing the connection between the microcontroller unit and an external device, the state of the serial port thread is changed from the initialization state to the message waiting state, so that the microcontroller unit can receive data information sent by the external device.

[0107] S320. Determine whether the first data information transmitted by the control thread corresponding to an external device has been obtained within the preset fourth time period; if yes, execute S330; if no, execute S340.

[0108] S330. If the first data information transmitted by the control thread corresponding to the external device is obtained within the preset fourth time period, the state of the serial port thread is changed from the message waiting state to the message sending state, and the first data information is sent to the external device through the serial port thread.

[0109] S340. If the first data information transmitted by the control thread corresponding to the external device is not obtained within the preset fourth time period, the state of the serial port thread is changed from the message waiting state to the serial port conversion state.

[0110] In this embodiment, if no data is received within the preset fourth time period, it indicates that an external device and the microcontroller unit are not exchanging data. The serial port thread state is then modified to allow the microcontroller unit to interact with another external device. For details, please refer to... Figure 4 The diagram illustrates a process of interaction between a microcontroller unit and an external device. Figure 4 As can be seen, the microcontroller interacts with different external devices at different times.

[0111] In this embodiment, in response to a user-initiated initialization operation, the state of the serial port thread is changed from the initialization state to the message waiting state. It also determines whether the first data information has been received within a preset fourth time period. If not, the interaction between the microcontroller and another external device is established by modifying the state of the serial port thread. This technical solution allows for better utilization of the microcontroller, enabling it to establish connections with external devices more efficiently.

[0112] Example 4

[0113] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0114] Please see Figure 5 This illustration shows a schematic diagram of a serial port thread-based information transmission device provided in an exemplary embodiment of this application. This serial port thread-based information transmission device can be implemented as all or part of a smart interactive flat panel through software, hardware, or a combination of both. The device includes a first data information sending module 510, a third data information sending module 520, a second data information sending module 530, an other data information determining module 540, an initialization module 550, a first data information acquisition module 560, and a first data information judgment module 570.

[0115] The first data information sending module 510 is used to change the state of the serial port thread from message sending state to message receiving state after sending the first data information to be sent to an external device through the serial port thread.

[0116] The third data information sending module 520 is used to change the state of the serial port thread from message receiving state to serial port conversion state if the second data information sent by the external device is not received within a preset first time period, and to send the third data information to the other external device through the serial port thread when the third data information to be sent to the other external device is obtained.

[0117] Optionally, the third data information sending module 520 is used for:

[0118] Change the state of the serial port thread from serial port conversion state to initialization state, and establish a connection between the serial port thread and the control thread corresponding to the other external device.

[0119] Change the state of the serial port thread from the initialization state to the message waiting state;

[0120] If third data information is obtained within a preset second time period from the control thread corresponding to the other external device, the third data information is sent to the other external device through the serial port thread.

[0121] Optionally, the third data information sending module 520 is used for:

[0122] In response to the user-initiated initialization operation, the state of the serial port thread is changed from the serial port conversion state to the initialization state.

[0123] Optionally, the device further includes:

[0124] The second data information sending module 530 is used to transmit the second data information to the control thread corresponding to the external device through the serial port thread if it receives the second data information sent by the external device within a preset first time period, and to change the state of the serial port thread from message receiving state to message receiving completed state.

[0125] Optionally, the device further includes:

[0126] The other data information determination module 540 is used to change the status of the serial port thread from the message receiving completion status to the serial port conversion status if it is determined that no other data information transmitted by the control thread corresponding to the external device is received within a preset third time period.

[0127] Optionally, the device further includes:

[0128] The initialization module 550 is used to respond to user-initiated initialization operations by changing the state of the serial port thread from the initialization state to the message waiting state.

[0129] The first data information acquisition module 560 is used to, if it acquires the first data information transmitted by the control thread corresponding to the external device within a preset fourth time period, change the state of the serial port thread from the message waiting state to the message sending state, and send the first data information to the external device through the serial port thread.

[0130] Optionally, initialization module 550 is used for:

[0131] In response to an initialization operation initiated by the user, the state of the serial port thread is set to the initialization state;

[0132] Establish a connection between the serial port thread and the control thread corresponding to the external device, and change the state of the serial port thread from the initialization state to the message waiting state.

[0133] Optionally, the device further includes:

[0134] The first data information judgment module 570 is used to change the state of the serial port thread from the message waiting state to the serial port conversion state if the first data information transmitted by the control thread corresponding to the external device is not obtained within a preset fourth time period.

[0135] It should be noted that the serial port thread-based information transmission device provided in the above embodiments is only illustrated by the division of the above functional modules when executing the serial port thread-based information transmission method. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the serial port thread-based information transmission device and the serial port thread-based information transmission method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.

[0136] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0137] In this embodiment, after sending the first data information to an external device via a serial port thread, if the second data information sent by the external device is not received within a preset first time period, the serial port thread is converted to interact with another external device. This technical solution addresses the problem of insufficient built-in serial ports, which prevents information transmission with multiple external devices, without increasing costs.

[0138] Example 5

[0139] This application also provides an information transmission system based on a serial port thread. For details, please refer to [link to relevant documentation]. Figure 6 The diagram shows a schematic of an information transmission system based on a serial port thread. It includes a microcontroller unit 610 and multiple external devices 620; the microcontroller unit is electrically connected to each of the external devices.

[0140] The microcontroller unit is used to perform the above-described actions. Figures 1-3 The method steps of the illustrated embodiment can be found in the following documentation for detailed execution. Figures 1-3 The specific details of the illustrated embodiments will not be elaborated here.

[0141] Example 6

[0142] This application also provides a computer storage medium that can store multiple instructions, which are adapted to be loaded and executed by a processor as described above. Figures 1-3 The method steps of the illustrated embodiment can be found in the following documentation for detailed execution. Figures 1-3 The specific details of the illustrated embodiments will not be elaborated here.

[0143] The device containing the storage medium can be a microcontroller unit.

[0144] Example 7

[0145] Please see Figure 7 The diagram below provides a schematic representation of a microcontroller unit according to an embodiment of this application. Figure 7 As shown, the microcontroller unit 1000 may include at least one processor 1001 and a memory 1005.

[0146] The processor 1001 may include one or more processing cores. The processor 1001 connects to various parts within the microcontroller 1000 using various interfaces and lines. It executes various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 1005, and by calling data stored in the memory 1005. Optionally, the processor 1001 may be implemented using at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 1001 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed on the screen; and the modem handles wireless communication. It is understood that the modem may also be implemented as a separate chip without being integrated into the processor 1001.

[0147] The memory 1005 may include random access memory (RAM) or read-only memory. Optionally, the memory 1005 may include a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 7 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an operating application program for a microcontroller unit.

[0148] exist Figure 7In the microcontroller unit 1000 shown, the processor 1001 can be used to call the microcontroller's operating application stored in the memory 1005, and specifically perform the following operations:

[0149] After the serial port thread sends the first data information to an external device, the state of the serial port thread is changed from message sending state to message receiving state.

[0150] If the second data information sent by the external device is not received within the preset first time period, the state of the serial port thread is changed from message receiving state to serial port conversion state, and when the third data information to be sent to another external device is obtained, the third data information is sent to the other external device through the serial port thread.

[0151] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0152] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0153] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0154] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0155] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0156] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0157] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

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

[0159] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for information transmission based on serial port threads, characterized in that, The method is applied to a microcontroller unit, which runs a serial port thread, and the method includes: After the serial port thread sends the first data information to an external device, the state of the serial port thread is changed from message sending state to message receiving state. If the second data information sent by the external device is not received within the preset first time period, the state of the serial port thread is changed from the message receiving state to the serial port conversion state, and when the third data information to be sent to another external device is obtained, the third data information is sent to the other external device through the serial port thread. Upon receiving third data information to be sent to another external device, the third data information is sent to the other external device via the serial port thread, including: Change the state of the serial port thread from serial port conversion state to initialization state, and establish a connection between the serial port thread and the control thread corresponding to the other external device. Change the state of the serial port thread from the initialization state to the message waiting state; If third data information is obtained within a preset second time period from the control thread corresponding to the other external device, the third data information is sent to the other external device through the serial port thread.

2. The method of claim 1, wherein, Changing the state of the serial port thread from the serial port conversion state to the initialization state includes: In response to the user-initiated initialization operation, the state of the serial port thread is changed from the serial port conversion state to the initialization state.

3. The method according to claim 1, characterized in that, The method further includes: If second data information sent by the external device is received within a preset first time period, the second data information is transmitted to the control thread corresponding to the external device through the serial port thread, and the state of the serial port thread is changed from message receiving state to message receiving completed state.

4. The method according to claim 3, characterized in that, After changing the status of the serial port thread from message receiving status to message receiving completed status, the process also includes: If it is determined that no other data information is received from the control thread corresponding to the external device within the preset third time period, the state of the serial port thread is changed from message reception completion state to serial port conversion state.

5. The method of claim 1, wherein, The method further includes: In response to the user-initiated initialization operation, the state of the serial port thread is changed from the initialization state to the message waiting state; If the first data information transmitted by the control thread corresponding to the external device is obtained within the preset fourth time period, the state of the serial port thread is changed from the message waiting state to the message sending state, and the first data information is sent to the external device through the serial port thread.

6. The method of claim 5, wherein, In response to a user-initiated initialization operation, the serial port thread's state is changed from the initialization state to the message waiting state, including: In response to an initialization operation initiated by the user, the state of the serial port thread is set to the initialization state; Establish a connection between the serial port thread and the control thread corresponding to the external device, and change the state of the serial port thread from the initialization state to the message waiting state.

7. The method according to claim 5, characterized in that, The method further includes: If the first data information corresponding to the control thread of the external device is not obtained within the preset fourth time period, the state of the serial port thread is changed from the message waiting state to the serial port conversion state.

8. A serial port thread-based information transmission apparatus, characterized by comprising: The device is applied to a microcontroller unit, the microcontroller unit running a serial port thread, and the device includes: The first data information sending module is used to change the state of the serial port thread from message sending state to message receiving state after the first data information to be sent to an external device is sent through the serial port thread. The third data information sending module is used to change the state of the serial port thread from message receiving state to serial port conversion state if the second data information sent by the external device is not received within a preset first time period, and to send the third data information to the other external device through the serial port thread when the third data information to be sent to the other external device is obtained. The third data information sending module is used for: Change the state of the serial port thread from serial port conversion state to initialization state, and establish a connection between the serial port thread and the control thread corresponding to the other external device. Change the state of the serial port thread from the initialization state to the message waiting state; If third data information is obtained within a preset second time period from the control thread corresponding to the other external device, the third data information is sent to the other external device through the serial port thread.

9. The apparatus of claim 8, wherein, The third data information sending module is used for: In response to the user-initiated initialization operation, the state of the serial port thread is changed from the serial port conversion state to the initialization state.

10. The apparatus of claim 8, wherein, The device further includes: The second data information sending module is used to transmit the second data information to the control thread corresponding to the external device through the serial port thread if the second data information sent by the external device is received within a preset first time period, and to change the state of the serial port thread from message receiving state to message receiving completed state.

11. The apparatus of claim 10, wherein, The device further includes: The other data information determination module is used to change the status of the serial port thread from message reception completion status to serial port conversion status if it is determined that no other data information is received from the control thread corresponding to the external device within a preset third time period.

12. The apparatus of claim 8, wherein, The device further includes: The initialization module is used to respond to user-initiated initialization operations by changing the state of the serial port thread from the initialization state to the message waiting state. The first data information acquisition module is used to, if it acquires the first data information transmitted by the control thread corresponding to the external device within a preset fourth time period, change the state of the serial port thread from the message waiting state to the message sending state, and send the first data information to the external device through the serial port thread.

13. The apparatus of claim 12, wherein, The initialization module is used for: In response to an initialization operation initiated by the user, the state of the serial port thread is set to the initialization state; Establish a connection between the serial port thread and the control thread corresponding to the external device, and change the state of the serial port thread from the initialization state to the message waiting state.

14. The apparatus of claim 13, wherein, The device further includes: The first data information judgment module is used to change the state of the serial port thread from the message waiting state to the serial port conversion state if the first data information transmitted by the control thread corresponding to the external device is not obtained within the preset fourth time period.

15. An information transmission system based on serial port threads, characterized in that, include: Microcontroller unit, multiple external devices; The microcontroller unit is electrically connected to each external device; The microcontroller unit is configured to perform the method as described in any one of claims 1-7.

16. A computer storage medium, comprising, The computer storage medium stores a plurality of instructions adapted for loading by a processor and executing the method as claimed in any one of claims 1-7.

17. A micro control unit, characterized by include: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed as claimed in any one of claims 1-7.

18. A computer program product comprising a computer program that, when executed by a processor, implements the method of any one of claims 1-7.