A UART Expansion Application Method, System and Storage Medium Based on the MTK Platform
By obtaining level information and sending handshake instructions to automatically identify and configure the UART interface, the problem that the MTK platform cannot access multiple UART peripherals is solved, the expansion of the UART interface and the automatic identification of peripheral devices is realized, and the system's fault tolerance is improved.
Patent Information
- Application Number
- CN202510093181.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-01-21
AI Technical Summary
Some MTK platforms only have one UART interface, and cannot access peripheral devices with multiple UART interfaces, resulting in the inability to expand the UART interface and automatically identify peripheral devices.
By obtaining level information, judging the access of the peripheral device, sending handshake commands and receiving feedback, determining the peripheral coded information, and finally setting up the UART communication configuration to establish a communication connection.
The number of UART peripherals connected to the MTK platform has been increased, and the peripheral devices have been automatically identified, which avoids the inability to communicate due to accessing the wrong channel, and improves the fault tolerance rate of production work.
Smart Images

Figure CN119537270B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of serial port expansion, and more specifically, to a UART expansion application method, system and storage medium based on the MTK platform. Background Art
[0002] The MTK platform refers to a chip platform developed by MediaTek Inc., which is widely used in intelligent devices such as smart phones, tablets, smart watches, etc. UART, short for serial port, is a universal asynchronous receiver / transmitter, which is an interface standard for asynchronous serial communication. UART is widely used for data communication between microcontrollers, computers and other digital devices.
[0003] However, since only one UART interface is set on some MTK platforms, it is impossible to access peripheral devices with multiple UART interfaces. Therefore, there is an urgent need for a UART expansion application technology that can expand the UART interface of the MTK platform and automatically identify peripheral devices. Summary of the Invention
[0004] In view of the above problems, the purpose of the present invention is to provide a UART expansion application method, system and storage medium based on the MTK platform, which increases the connection number of communicable UART peripherals by expanding based on the MTK platform; in addition, after detecting the access of a peripheral, it will automatically identify the peripheral and configure the corresponding communication protocol for the peripheral; by setting the UART communication configuration, the communication between the MTK platform and the UART peripheral is ensured; thus increasing the number of UART peripherals accessed by the MTK platform, and automatically identifying the peripherals, avoiding the problem of inability to communicate due to the wrong channel of peripheral access, and improving the fault tolerance rate of production work.
[0005] The first aspect of the present invention provides a UART expansion application method based on the MTK platform, and the method includes:
[0006] Obtain the first level information;
[0007] Judge whether the first level information is switched to a preset level threshold;
[0008] If so, determine the first number information according to the first level information;
[0009] Send the first handshake command according to the first number information;
[0010] Judge whether the first handshake feedback command is received;
[0011] If so, determine the first peripheral coding information according to the first handshake feedback command;
[0012] Set the UART communication configuration according to the first number information and the first peripheral coding information.
[0013] In this solution, the judgment of whether the first handshake feedback instruction is received is specifically as follows:
[0014] Obtain and send the first handshake instruction in sequence according to the preset handshake instruction library;
[0015] Judge whether the feedback instruction information is received within the preset first time;
[0016] If so, the feedback instruction information is the first handshake feedback instruction;
[0017] If not, update the first timeout count information;
[0018] Judge whether to send the handshake instruction again according to the first timeout count information;
[0019] If not, the first handshake feedback instruction is not received.
[0020] In this solution, the judgment of whether to send the first handshake instruction again according to the first timeout count information is specifically as follows:
[0021] Judge whether the first timeout count information is lower than the preset count threshold;
[0022] If so, resend the first handshake instruction;
[0023] If not, judge whether the first handshake instruction is the last handshake instruction in the handshake instruction library;
[0024] If so, stop sending the handshake instruction;
[0025] If not, obtain and send the first handshake instruction in sequence according to the preset handshake instruction library.
[0026] In this solution, the determination of the first peripheral coding information according to the first handshake feedback instruction is specifically as follows:
[0027] Obtain the communication protocol information according to the first handshake feedback instruction;
[0028] Analyze the frame header information, frame tail information and check information of the communication protocol information to determine the peripheral communication device;
[0029] Obtain the first peripheral coding information according to the peripheral communication device.
[0030] This solution further includes:
[0031] The peripheral communication device includes at least a Beidou positioning module and an RFID module.
[0032] In this solution, it further includes:
[0033] The SPI interface is converted to a UART interface through the conversion chip CH432T.
[0034] The second aspect of the present invention provides a UART expansion application system based on the MTK platform, including a UART expansion application method program based on the MTK platform. When the UART expansion application method program based on the MTK platform is executed by the processor, the following steps are implemented:
[0035] Obtain the first level information;
[0036] Judge whether the first level information is switched to a preset level threshold;
[0037] If so, determine the first number information according to the first level information;
[0038] Send the first handshake command according to the first number information;
[0039] Judge whether the first handshake feedback command is received;
[0040] If so, determine the first peripheral coding information according to the first handshake feedback command;
[0041] Set the UART communication configuration according to the first number information and the first peripheral coding information.
[0042] In this solution, the judgment of whether the first handshake feedback command is received is specifically:
[0043] Obtain and send the first handshake command in sequence according to the preset handshake command library;
[0044] Judge whether feedback command information is received within a preset first time;
[0045] If so, the feedback command information is the first handshake feedback command;
[0046] If not, update the first timeout count information;
[0047] Judge whether to send the handshake command again according to the first timeout count information;
[0048] If not, the first handshake feedback command is not received.
[0049] In this solution, the determination of the first peripheral coding information according to the first handshake feedback command is specifically:
[0050] Obtain the communication protocol information according to the first handshake feedback command;
[0051] Analyze the frame header information, frame tail information, and check information of the communication protocol information to determine the peripheral communication device;
[0052] Obtain the first peripheral coding information according to the peripheral communication device.
[0053] The third aspect of the present invention provides a computer-readable storage medium, which includes a UART expansion application method program based on the MTK platform. When the UART expansion application method program based on the MTK platform is executed by a processor, the steps of the UART expansion application method based on the MTK platform as described in any one of the above are realized.
[0054] The present invention provides a UART expansion application method, system, and storage medium based on the MTK platform. First, determine whether a peripheral device is connected according to the first level information; when a peripheral device is connected, obtain the first number information of the connected UART interface, and then send a first handshake command according to the first number information; then, if a first handshake feedback command is received, determine the first peripheral coding information according to the first handshake feedback command; finally, configure the UART communication configuration of the MTK platform according to the first number information and the first peripheral coding information to establish a communication connection with the peripheral device; by automatically identifying and configuring the UART interface, while increasing the number of UART peripheral devices connected to the MTK platform, the problem of inability to communicate due to the peripheral device being connected to the wrong channel is avoided, and the error tolerance rate of production work is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention, and therefore should not be regarded as limiting the scope.
[0056] Figure 1 Shows a flowchart of a UART expansion application method based on the MTK platform of the present invention;
[0057] Figure 2 Shows a flowchart of receiving the first handshake feedback command provided by an embodiment of the present invention;
[0058] Figure 3 Shows a flowchart of confirming the first peripheral coding information provided by an embodiment of the present invention;
[0059] Figure 4 Shows a block diagram of a UART expansion application system based on the MTK platform of the present invention. DETAILED DESCRIPTION
[0060] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0061] Unless otherwise defined, all terms (including technical and scientific terms) used in the embodiments of the present invention have the same meaning as commonly understood by those of ordinary skill in the art to which the present invention belongs. It should also be understood that terms such as those defined in a common dictionary should be interpreted as having a meaning consistent with their meaning in the context of the relevant art, and should not be interpreted in an idealized or overly formal sense unless clearly defined in the embodiments of the present invention.
[0062] The "first", "second" and similar terms used in the embodiments of the present invention do not denote any order, quantity or importance, but are only used to distinguish different components. Terms such as "a", "an" or "the" do not denote a quantity limitation either, but mean that there is at least one. Similarly, words such as "comprising" or "including" mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. The terms "connected" or "coupled" and the like are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The steps before or after the methods of the embodiments of the present invention do not necessarily need to be carried out precisely in sequence. On the contrary, they can be carried out in reverse order or simultaneously. At the same time, other operations can also be added to these processes, or one or several steps can be removed from these processes.
[0063] In addition, in each embodiment of the present invention, the functional modules can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0064] Figure 1 The flowchart of a method for expanding the UART application based on the MTK platform of the present invention is shown.
[0065] As Figure 1 shown, in a first aspect of the present invention, a method for expanding the UART application based on the MTK platform is disclosed, and the method includes:
[0066] S102, obtaining first level information;
[0067] S104, determining whether the first level information is a preset level threshold;
[0068] S106, if so, determine the first number information according to the first level information;
[0069] S108, send a first handshake command according to the first number information;
[0070] S110, determine whether a first handshake feedback command is received;
[0071] S112, if so, determine the first peripheral device coding information according to the first handshake feedback command;
[0072] S114, set the UART communication configuration according to the first number information and the first peripheral device coding information.
[0073] It should be noted that the first level information is the interface level value used to detect the insertion of a peripheral device, including at least two level states, namely high level and low level; usually, a switching circuit or the like is used. When a peripheral device is connected, the output level of the switching circuit changes. The first number information is the number of the UART interface, which is used to configure the UART interface of the MTK platform. The first handshake command is a command for establishing a communication connection set according to the communication protocol of the preset peripheral device; the first handshake feedback command is a communication command fed back by the peripheral device to the MTK platform according to the correct first handshake command. The first peripheral device coding information is the coding set according to the peripheral device. For example, the coding of the Beidou positioning module is 0x01, and the coding of the RFID module is 0x02.
[0074] In this embodiment, if the first level information switches to a preset level threshold, indicating that a new peripheral device has been connected to the set UART interface, the number of the UART interface of the connected peripheral device is determined according to the first level information to obtain the first number information. A first handshake command is sent to the peripheral device through the UART interface pointed to by the first number information. If a communication command feedback by the peripheral device, that is, the first feedback command, is received, it means that a connection has been established between the UART interface pointed to by the first number information and the peripheral device; and the coding of the peripheral device is determined according to the first feedback command. Finally, the communication protocol is determined according to the coding of the peripheral device, and then the communication configuration parameters of the corresponding UART interface are set according to the first number information.
[0075] Figure 2 The flowchart of receiving the first handshake feedback command provided by the embodiment of the present invention is shown.
[0076] According to the embodiment of the present invention, as Figure 2 shown, the determination of whether the first handshake feedback command is received is specifically:
[0077] S202, sequentially obtain and send the first handshake command according to the preset handshake command library;
[0078] S204, within a preset first time period, determine whether a feedback instruction message is received;
[0079] S206, if so, then the feedback instruction message is a first handshake feedback instruction;
[0080] S208, if not, then update the first timeout count information;
[0081] S210, according to the first timeout count information, determine whether to send the handshake instruction again;
[0082] S212, if not, then the first handshake feedback instruction is not received.
[0083] It should be noted that, in this embodiment, the handshake instructions are sequentially sent according to the handshake instruction library, and by determining whether a feedback instruction message is received within a preset first time period, it is used to determine whether the first handshake feedback instruction is received. First, according to the preset handshake instruction library, the first handshake instruction is sequentially obtained and sent to the peripheral device; if a feedback instruction message returned by the peripheral device is received within the preset first time period, it indicates that the handshake with the peripheral device is successful, that is, the communication is established successfully, and the feedback instruction message of the peripheral device is the first handshake feedback instruction; if a feedback instruction message is not received within the preset first time period, it indicates that the handshake fails, and the first timeout count information of the current first handshake instruction is updated. Finally, according to the first timeout count information, determine whether to send the handshake instruction again. If not, it indicates that the handshake with the peripheral device fails and the communication connection cannot be established, that is, it is determined that the first handshake feedback instruction is not received.
[0084] According to the embodiment of the present invention, the determining whether to send the first handshake instruction again according to the first timeout count information is specifically:
[0085] Determine whether the first timeout count information is lower than a preset count threshold;
[0086] If so, resend the first handshake instruction;
[0087] If not, then determine whether the first handshake instruction is the last handshake instruction in the handshake instruction library;
[0088] If so, stop sending the handshake instruction;
[0089] If not, then according to the preset handshake instruction library, sequentially obtain and send the first handshake instruction.
[0090] It should be noted that in this embodiment, the handshake command in the handshake command library is switched according to the first timeout count information. When the first timeout count information is lower than the preset count threshold, the current first handshake command is resent. When the first timeout count information is not lower than the preset count threshold, the handshake command is switched from the handshake command library. When a handshake command switch is required, it is determined whether the current first handshake command is the last handshake command in the handshake command library; if so, it means that all handshake commands cannot successfully handshake with the peripheral device, and the handshake command sending is stopped; if not, the next handshake command in the handshake command library is selected and set as the first handshake command.
[0091] Figure 3 The flowchart shows the confirmation of the first peripheral device coding information provided by the embodiment of the present invention.
[0092] According to the embodiment of the present invention, as Figure 3 shown, determining the first peripheral device coding information according to the first handshake feedback command specifically includes:
[0093] S302, obtaining communication protocol information according to the first handshake feedback command;
[0094] S304, analyzing the frame header information, frame tail information and check information of the communication protocol information to determine the peripheral communication device;
[0095] S306, obtaining the first peripheral device coding information according to the peripheral communication device.
[0096] It should be noted that in this embodiment, the coding of the peripheral communication device is confirmed by analyzing the communication protocol in the handshake feedback command. First, communication protocol information is obtained according to the first handshake feedback command, including but not limited to the frame header, frame tail, check mode, etc. in the communication data frame. Then, according to the communication protocol information, the type of the peripheral device is determined by querying the communication protocols in the stored peripheral device list, so as to determine the coding of the peripheral device.
[0097] According to the embodiment of the present invention, it further includes:
[0098] The peripheral communication device at least includes a Beidou positioning module and an RFID module.
[0099] It should be noted that in this embodiment, the peripheral communication devices that need to be connected to the MTK platform at least include a Beidou positioning module and an RFID module. The Beidou positioning module refers to an electronic module integrated with Beidou satellite navigation system positioning technology. It can receive signals sent by Beidou satellites, calculate information such as the precise position, speed, and time of the receiver through internal processing algorithms, and then communicate with the MTK platform through the UART interface. The RFID module, that is, the radio frequency identification module, is a wireless electronic tag system. It can identify the tags on items through electromagnetic fields and then communicate with the MTK platform through the UART interface.
[0100] According to an embodiment of the present invention, it further includes:
[0101] Convert the SPI interface to a UART interface through the conversion chip CH432T.
[0102] It should be noted that as an implementation method, the UART interface of the MTK platform is expanded through the conversion chip. CH432T is a UART interface conversion chip. It can convert interfaces such as USB interfaces and SPI interfaces into independent UART interfaces to provide additional communication channels in the case of limited serial port resources.
[0103] It is worth mentioning that it further includes:
[0104] Obtain the first peripheral device coding information;
[0105] Judge whether the first peripheral device coding information is a preset peripheral device coding;
[0106] If so, judge whether the coding of the peripheral device in the UART communication connection state is the same as the first peripheral device coding information;
[0107] If so, generate an installation exception instruction according to the first peripheral device coding information.
[0108] It should be noted that in this embodiment, by automatically identifying peripheral devices, it is used to judge whether there are abnormal situations such as repeated installation of peripheral devices. In practical applications, only one of individual communication modules is used on the same MTK platform. For example, only one Beidou positioning module is installed. In this embodiment, after detecting a newly connected peripheral device, according to the first peripheral device coding information of the newly connected peripheral device and the coding of the peripheral device connected to the configured UART interface, it is judged whether there is a situation of repeated installation of the preset peripheral device. If so, an installation exception instruction is generated according to the first peripheral device coding information, which is used to indicate that the installation of the peripheral device corresponding to the first peripheral device coding information is abnormal.
[0109] It is worth mentioning that it further includes:
[0110] Obtain communication protocol information according to the first handshake feedback instruction;
[0111] Send a first verification instruction according to the communication protocol information in combination with preset verification data;
[0112] Obtain a first verification feedback instruction;
[0113] Adjust the UART communication configuration according to the first feedback instruction.
[0114] It should be noted that in this embodiment, after the handshake of the peripheral device is successful, a secondary verification will be performed to ensure the accuracy of device communication. First, obtain communication protocol information according to the first handshake feedback instruction. Then, send a first verification instruction in combination with preset verification data. If the first verification feedback instruction is received normally, the UART communication configuration will not be adjusted. If the first verification feedback instruction is received abnormally, the connection between the peripheral device and the MTK platform will be disconnected by adjusting the UART communication configuration, and the device identification and verification will be performed again.
[0115] Figure 4 The block diagram of a UART expansion application system based on the MTK platform according to the present invention is shown.
[0116] As Figure 4 shown, in the second aspect of the present invention, a UART expansion application system 4 based on the MTK platform is disclosed, including a memory 41 and a processor 42. The memory includes a UART expansion application method program based on the MTK platform. When the UART expansion application method program based on the MTK platform is executed by the processor, the following steps are implemented:
[0117] Obtain first level information;
[0118] Judge whether the first level information is a preset level threshold;
[0119] If so, determine first number information according to the first level information;
[0120] Send a first handshake instruction according to the first number information;
[0121] Judge whether a first handshake feedback instruction is received;
[0122] If so, determine first peripheral coding information according to the first handshake feedback instruction;
[0123] Set the UART communication configuration according to the first number information and the first peripheral coding information.
[0124] It should be noted that the first level information is the interface level value used to detect the insertion of a peripheral device, including at least two level states, namely high level and low level; usually, a switching circuit or the like is used, and when the peripheral device is connected, the output level of the switching circuit changes. The first number information is the number of the UART interface, which is used to configure the UART interface of the MTK platform. The first handshake command is a command for establishing a communication connection set according to the communication protocol of the preset peripheral device; the first handshake feedback command is a communication command fed back by the peripheral device to the MTK platform according to the correct first handshake command. The first peripheral coding information is the coding set according to the peripheral device. For example, the coding of the Beidou positioning module is 0x01, and the coding of the RFID module is 0x02.
[0125] In this embodiment, if the first level information switches to a preset level threshold, indicating that a new peripheral device has been connected to the set UART interface, the number of the UART interface to which the peripheral device is connected is determined according to the first level information to obtain the first number information. The first handshake command is sent to the peripheral device through the UART interface pointed to by the first number information. If a communication command fed back by the peripheral device, that is, the first feedback command, is received, it means that a connection has been established between the UART interface pointed to by the first number information and the peripheral device; and the coding of the peripheral device is determined according to the first feedback command. Finally, the communication protocol is determined according to the coding of the peripheral device, and the communication configuration parameters of the corresponding UART interface are set according to the first number information.
[0126] According to the embodiment of the present invention, the judgment of whether the first handshake feedback command is received is specifically as follows:
[0127] According to the preset handshake command library, the first handshake commands are sequentially obtained and sent;
[0128] Within a preset first time, it is judged whether feedback command information is received;
[0129] If so, the feedback command information is the first handshake feedback command;
[0130] If not, the first timeout count information is updated;
[0131] According to the first timeout count information, it is judged whether to send the handshake command again;
[0132] If not, the first handshake feedback command is not received.
[0133] It should be noted that in this embodiment, the handshake commands are sequentially sent according to the handshake command library, and by determining whether the feedback command information is received within a preset first time, it is used to determine whether the first handshake feedback command is received. First, according to the preset handshake command library, the first handshake command is sequentially obtained and sent to the peripheral device; if the feedback command information returned by the peripheral device is received within the preset first time, it means that the handshake with the peripheral device is successful, that is, the communication is successfully established, and the feedback command information of the peripheral device is the first handshake feedback command; if the feedback command information is not received within the preset first time, it means that the handshake fails, and the first timeout count information of the current first handshake command is updated. Finally, according to the first timeout count information, it is judged whether it is necessary to send the handshake command again. If not, it means that the handshake with the peripheral device fails and the communication connection cannot be established, that is, it is determined that the first handshake feedback command is not received.
[0134] According to an embodiment of the present invention, the determining whether to send the first handshake command again according to the first timeout count information is specifically:
[0135] Judge whether the first timeout count information is lower than a preset count threshold;
[0136] If so, resend the first handshake command;
[0137] If not, then judge whether the first handshake command is the last handshake command in the handshake command library;
[0138] If so, stop sending the handshake command;
[0139] If not, then according to the preset handshake command library, the first handshake command is sequentially obtained and sent.
[0140] It should be noted that in this embodiment, the handshake commands in the handshake command library are switched according to the first timeout count information. When the first timeout count information is lower than the preset count threshold, the current first handshake command is resent. When the first timeout count information is not lower than the preset count threshold, the handshake command is switched from the handshake command library. When the handshake command needs to be switched, it is judged whether the current first handshake command is the last handshake command in the handshake command library; if so, it means that all handshake commands cannot handshake successfully with the peripheral device, and the handshake command is stopped from being sent; if not, the next handshake command in the handshake command library is selected and set as the first handshake command.
[0141] According to an embodiment of the present invention, the determining the first peripheral coding information according to the first handshake feedback command is specifically:
[0142] Obtain the communication protocol information according to the first handshake feedback command;
[0143] Analyze the frame header information, frame tail information, and check information of the communication protocol information to determine the peripheral communication device;
[0144] Obtain the first peripheral coding information according to the peripheral communication device.
[0145] It should be noted that in this embodiment, by analyzing the communication protocol in the handshake feedback instruction, the coding of the peripheral communication device is confirmed. First, according to the first handshake feedback instruction, obtain the communication protocol information, which includes but is not limited to the frame header, frame tail, check mode, etc. in the communication data frame. Then, according to the communication protocol information, determine the type of the peripheral device by querying the communication protocols in the stored peripheral device list, so as to determine the coding of the peripheral device.
[0146] According to an embodiment of the present invention, it further includes:
[0147] The peripheral communication device at least includes a Beidou positioning module and an RFID module.
[0148] It should be noted that in this embodiment, the peripheral communication devices that need to be connected to the MTK platform at least include a Beidou positioning module and an RFID module. The Beidou positioning module refers to an electronic module integrated with Beidou satellite navigation system positioning technology. It can receive the signals sent by Beidou satellites, calculate the accurate position, speed, time, etc. of the receiver through the internal processing algorithm, and then communicate with the MTK platform through the UART interface. The RFID module, that is, the radio frequency identification module, is a wireless electronic tag system. It can identify the tags on items through the electromagnetic field and then communicate with the MTK platform through the UART interface.
[0149] According to an embodiment of the present invention, it further includes:
[0150] Convert the SPI interface to a UART interface through the conversion chip CH432T.
[0151] It should be noted that as an implementation method, the UART interface of the MTK platform is expanded through the conversion chip. CH432T is a UART interface conversion chip. It can convert interfaces such as USB interfaces and SPI interfaces into independent UART interfaces to provide additional communication channels in the case of limited serial port resources.
[0152] It is worth mentioning that it further includes:
[0153] Obtain the first peripheral coding information;
[0154] Judge whether the first peripheral coding information is a preset peripheral coding;
[0155] If so, judge whether the coding of the peripheral in the UART communication connection state is the same as the first peripheral coding information;
[0156] If so, an installation exception instruction is generated according to the first peripheral coding information.
[0157] It should be noted that in this embodiment, by automatically identifying peripheral devices, it is used to determine whether there are abnormal situations such as repeated installation of peripheral devices. In actual applications, only one individual communication module will be used on the same MTK platform. For example, only one Beidou positioning module is installed. In this embodiment, after detecting a newly connected peripheral device, according to the first peripheral coding information of the newly connected peripheral device and the coding of the peripheral device connected to the configured UART interface, it is determined whether there is a situation of repeated installation of the set peripheral device. If so, an installation exception instruction is generated according to the first peripheral coding information, which is used to indicate that the peripheral device corresponding to the first peripheral coding information is installed abnormally.
[0158] It is worth mentioning that it further includes:
[0159] Obtain communication protocol information according to the first handshake feedback instruction;
[0160] According to the communication protocol information, combined with preset verification data, send a first verification instruction;
[0161] Obtain a first verification feedback instruction;
[0162] Adjust the UART communication configuration according to the first feedback instruction.
[0163] It should be noted that in this embodiment, after the handshake of the peripheral device is successful, a secondary verification will be performed to ensure the accuracy of device communication. First, obtain communication protocol information according to the first handshake feedback instruction. Then, combined with preset verification data, send a first verification instruction. If the first verification feedback instruction is received normally, the UART communication configuration is not adjusted. If the first verification feedback instruction is received abnormally, the connection between the peripheral device and the MTK platform is disconnected by adjusting the UART communication configuration, and the device identification and verification are performed again.
[0164] The third aspect of the present invention provides a computer-readable storage medium, which includes a UART expansion application method program based on the MTK platform. When the UART expansion application method program based on the MTK platform is executed by a processor, the steps of the UART expansion application method based on the MTK platform as described in any one of the above are realized.
[0165] In summary, the present invention provides a method, system, and storage medium for expanding the application of UART based on the MTK platform. First, it is determined whether there is a peripheral device connected according to the first level information; when there is a peripheral device connected, the first number information of the connected UART interface is obtained, and then the first handshake command is sent according to the first number information; then, if the first handshake feedback command is received, the first peripheral coding information is determined according to the first handshake feedback command; finally, according to the first number information and the first peripheral coding information, the UART communication configuration of the MTK platform is configured to establish a communication connection with the peripheral device; by automatically identifying and configuring the UART interface, while increasing the number of UART peripherals connected to the MTK platform, the problem of unable to communicate due to the peripheral device being connected to the wrong channel is avoided, and the fault tolerance rate of production work is improved.
[0166] If the above-mentioned function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0167] The foregoing are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A UART expansion application method based on MTK platform, characterized in that: The method comprises: Acquiring first level information; Determining whether the first level information is switched to a preset level threshold; If yes, determining first number information according to the first level information; Sending a first handshake instruction according to the first number information; Determining whether a first handshake feedback instruction is received; If yes, determining the first peripheral device encoding information according to the first handshake feedback instruction; According to the first numbering information and the first peripheral encoding information, setting UART communication configuration; The determining whether the first handshake feedback instruction is received is specifically: According to the preset handshake instruction library, the first handshake instruction is obtained and sent in sequence; Within a preset first time, determining whether feedback instruction information is received; If yes, the feedback instruction information is a first handshake feedback instruction; If not, update the first timeout number information; Determining whether to send a handshake instruction again according to the first timeout number information; If not, the first handshake feedback instruction is not received; The determining, according to the first timeout number information, whether to send the first handshake instruction again is specifically: Determine whether the first timeout number information is lower than a preset number threshold; If yes, resend the first handshake instruction; If not, determining whether the first handshake instruction is the last handshake instruction in the handshake instruction library; If yes, stop sending handshake instructions; If not, then according to the preset handshake instruction library, the first handshake instruction is obtained and sent in sequence; The determining the first peripheral encoding information according to the first handshake feedback instruction is specifically: Obtaining communication protocol information according to the first handshake feedback instruction; Analyze the frame header information, frame tail information and check information of the communication protocol information to determine the peripheral communication device; According to the peripheral communication device, obtaining first peripheral coding information; Also includes: Obtaining first peripheral encoding information; Determining whether the first peripheral device coding information is a preset peripheral device coding; If yes, determine whether the encoding of the peripheral device in the UART communication connection state is the same as the first peripheral device encoding information; If so, an installation exception instruction is generated according to the first peripheral encoding information.
2. The UART expansion application method based on the MTK platform according to claim 1, characterized in that: Also includes: The peripheral communication device includes at least a Beidou positioning module and an RFID module.
3. The UART expansion application method based on the MTK platform according to claim 1, characterized in that: Also includes: The SPI interface is converted to UART interface through the conversion chip CH432T.
4. A UART expansion application system based on MTK platform, characterized in that: The system includes a memory and a processor, wherein the memory includes a UART expansion application method program based on the MTK platform, and the UART expansion application method program based on the MTK platform implements the following steps when executed by the processor: Acquiring first level information; Determining whether the first level information is switched to a preset level threshold; If yes, determining first number information according to the first level information; Sending a first handshake instruction according to the first number information; Determining whether a first handshake feedback instruction is received; If yes, determining the first peripheral device encoding information according to the first handshake feedback instruction; According to the first numbering information and the first peripheral encoding information, setting UART communication configuration; The determining whether the first handshake feedback instruction is received is specifically: According to the preset handshake instruction library, the first handshake instruction is obtained and sent in sequence; Within a preset first time, determining whether feedback instruction information is received; If yes, the feedback instruction information is a first handshake feedback instruction; If not, update the first timeout number information; Determining whether to send a handshake instruction again according to the first timeout number information; If not, the first handshake feedback instruction is not received; The determining, according to the first timeout number information, whether to send the first handshake instruction again is specifically: Determine whether the first timeout number information is lower than a preset number threshold; If yes, resend the first handshake instruction; If not, determining whether the first handshake instruction is the last handshake instruction in the handshake instruction library; If yes, stop sending handshake instructions; If not, then according to the preset handshake instruction library, the first handshake instruction is obtained and sent in sequence; The determining the first peripheral encoding information according to the first handshake feedback instruction is specifically: Obtaining communication protocol information according to the first handshake feedback instruction; Analyze the frame header information, frame tail information and check information of the communication protocol information to determine the peripheral communication device; According to the peripheral communication device, obtaining first peripheral coding information; Also includes: Obtaining first peripheral encoding information; Determining whether the first peripheral device coding information is a preset peripheral device coding; If yes, determine whether the encoding of the peripheral device in the UART communication connection state is the same as the first peripheral device encoding information; If so, an installation exception instruction is generated according to the first peripheral encoding information.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer-readable storage medium includes a UART expansion application method program based on the MTK platform. When the UART expansion application method program based on the MTK platform is executed by the processor, the steps of the UART expansion application method based on the MTK platform as described in any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
A chip-based communication method and device
CN109828938A
Low-power-consumption serial port expansion method and system based on mobile equipment and storage medium
CN116991223A