A method, system and medium for implementing serial port keyboard based on serio protocol
Through the uart keyboard technology based on the serio protocol, the problem of conflict between the keyboard and the computer at the same time when there is only one USB channel is solved, and the efficient response and compatibility of the uart keyboard is achieved, allowing end users to use the keyboard and computer without conflict.
Patent Information
- Application Number
- CN202411060971.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2044-08-05
AI Technical Summary
When there is only one USB, the master-slave switch causes the keyboard and computer to be unable to be connected at the same time, which has a conflict problem.
Using the method based on the serio protocol, the function of connecting the computer and the keyboard at the same time is realized through the uart keyboard, and the uart baud rate can be freely selected. By setting the communication level, starting the uart protocol, analyzing the data reception status information, analyzing and setting the uart The keyboard serial port switching rules realize communication switching and ensure normal connection between the keyboard and the computer.
It solves the conflict problem when the USB keyboard is connected to the computer at the same time, improves the keyboard's response speed and compatibility, and allows end users to use the keyboard without conflict while connecting to the computer.
Smart Images

Figure CN118567503B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of serial keyboard data transmission, and in particular to a method, system and medium for implementing a serial keyboard based on a serio protocol. Background Art
[0002] Currently, many platforms need to realize the function of connecting keyboard and computer at the same time, but most Android manufacturers' platforms only have one USB. Therefore, there will be great limitations in choosing a USB keyboard at this time. For example, when there is only one USB, there will be conflicts in the master-slave switching, making it impossible to connect to the computer while connecting the keyboard. In response to the above problems, effective technical solutions are urgently needed. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a method, system and medium for implementing a serial port keyboard based on the serio protocol, by using the serio protocol to implement a software method that can simultaneously connect a computer and a keyboard through a uart keyboard, so that the terminal user can connect a computer and a keyboard at the same time without conflict, and can freely select the uart baud rate, thereby improving the keyboard response speed.
[0004] The embodiment of the present application also provides a method for implementing a serial port keyboard based on the serio protocol, including:
[0005] Set the communication level, start the uart protocol on the cpu platform based on the communication level, and get the commissioning result;
[0006] Analyze the data receiving status information based on the adjustment result, and set the parameter information of the UART protocol based on the receiving status information;
[0007] Parse the UART data based on the parameter information of the UART protocol to obtain parsed information;
[0008] Based on the parsed information, connect to the external keyboard to analyze the HID key value receiving information, and set the uart keyboard serial port switching rules according to the HID key value receiving information;
[0009] Based on the uart keyboard serial port switching rule, the uart keyboard is communicated and switched, switching information is generated, the uart keyboard serial port connection mode is controlled based on the switching information, and the keyboard or computer is connected according to the uart keyboard serial port connection mode.
[0010] Optionally, in the method for implementing a serial keyboard based on the serio protocol described in the embodiment of the present application, setting a communication level, starting the uart protocol on the cpu platform side based on the communication level, and obtaining a tuning result specifically includes:
[0011] Set the communication level interval, obtain the current communication level value, and determine whether the current communication level value is within the set communication level interval;
[0012] If it is in the set communication level range, the uart protocol of the cpu platform is started based on the communication level to obtain the startup status information;
[0013] Determine whether the startup status information meets the set startup condition information;
[0014] If the set startup condition information is met, the adjustment result is obtained; if the set startup condition information is not met, the startup is determined to have failed, optimization information is generated, and the startup mode is adjusted based on the optimization information;
[0015] If it is not in the set communication level interval, correction information is generated, and the current communication level value is adjusted based on the correction information.
[0016] Optionally, in the method for implementing a serial port keyboard based on the serio protocol described in an embodiment of the present application, analyzing data receiving status information based on the adjustment result, and setting parameter information of the uart protocol based on the receiving status information, specifically includes:
[0017] Get the adjustment result and determine whether the adjustment result is successful;
[0018] If successful, the data receiving state information is obtained, and the data receiving state information is compared with the set receiving state information to obtain the state deviation rate;
[0019] Determining whether the state deviation rate is greater than or equal to a set state deviation rate threshold;
[0020] If it is greater than the set state deviation rate threshold, the data receiving parameters are adjusted; if it is less than the set state deviation rate threshold, the parameter information of the uart protocol is set;
[0021] If it fails, adjust the uart protocol and trigger the adjustment result again.
[0022] Optionally, in the method for implementing a serial keyboard based on the serio protocol described in an embodiment of the present application, the uart data is parsed based on the parameter information of the uart protocol to obtain parsed information, and then the method further includes:
[0023] Obtain the parameter information of the uart protocol, encrypt the transmission data based on the parameter information of the uart protocol, and obtain the encryption key;
[0024] Encrypt the UART data for transmission based on the encryption information to obtain the transmission data, and generate a decryption key matching the encryption key based on the transmission data;
[0025] Receive a decryption instruction, call a matching decryption key based on the decryption instruction, decrypt the transmitted data based on the decryption key, and obtain plaintext data;
[0026] Redundant data is analyzed based on plaintext data, and the redundant data is removed to obtain parsed information.
[0027] Optionally, in the method for implementing a serial keyboard based on the serio protocol described in an embodiment of the present application, linking an external keyboard to analyze HID key value reception information based on parsing information, and setting a UART keyboard serial port switching rule according to the HID key value reception information specifically includes:
[0028] Obtain parsing information, link the external keyboard based on the parsing information, analyze the operating status of the external keyboard, and obtain HID key value receiving information based on the operating status of the external keyboard;
[0029] Compare the HID key value receiving information with the standard receiving information to obtain the receiving deviation rate;
[0030] If the receiving deviation rate is greater than the first receiving deviation rate threshold and less than the second receiving deviation rate threshold, generating a first receiving rule;
[0031] If the receiving deviation rate is greater than or equal to the second receiving deviation rate threshold, generating a second receiving rule;
[0032] The first receiving rule and the second receiving rule are dynamically switched based on the HID key value receiving information to obtain the uart keyboard serial port switching rule.
[0033] Optionally, in the method for implementing a serial keyboard based on the serio protocol described in an embodiment of the present application, communication switching of the uart keyboard is performed based on a uart keyboard serial port switching rule, switching information is generated, a uart keyboard serial port connection mode is controlled based on the switching information, and a keyboard or a computer is connected according to the uart keyboard serial port connection mode, specifically including:
[0034] Get the uart keyboard serial port switching rules, match the corresponding HID key value based on the uart keyboard serial port switching rules to receive information, and get the baud rate of the uart keyboard;
[0035] Analyze data transmission rate based on the baud rate of the uart keyboard;
[0036] Analyze whether the UART keyboard serial port switching rules match based on data transmission rate;
[0037] If they match, the switching information is generated, and the UART keyboard serial port is controlled to connect to the keyboard or computer based on the switching information;
[0038] If they do not match, adjust the HID key value to receive information.
[0039] In a second aspect, an embodiment of the present application provides a system for implementing a serial port keyboard based on the serio protocol, the system comprising: a memory and a processor, the memory comprising a program for implementing a method for a serial port keyboard based on the serio protocol, and the program for implementing a method for a serial port keyboard based on the serio protocol when executed by the processor implements the following steps:
[0040] Set the communication level, start the uart protocol on the cpu platform based on the communication level, and get the commissioning result;
[0041] Analyze the data receiving status information based on the adjustment result, and set the parameter information of the UART protocol based on the receiving status information;
[0042] Parse the UART data based on the parameter information of the UART protocol to obtain parsed information;
[0043] Based on the parsed information, connect to the external keyboard to analyze the HID key value receiving information, and set the uart keyboard serial port switching rules according to the HID key value receiving information;
[0044] Based on the uart keyboard serial port switching rule, the uart keyboard is communicated and switched, switching information is generated, the uart keyboard serial port connection mode is controlled based on the switching information, and the keyboard or computer is connected according to the uart keyboard serial port connection mode.
[0045] Optionally, in the system for implementing a serial keyboard based on the serio protocol described in the embodiment of the present application, setting a communication level, starting the uart protocol on the cpu platform side based on the communication level, and obtaining a tuning result specifically includes:
[0046] Set the communication level interval, obtain the current communication level value, and determine whether the current communication level value is within the set communication level interval;
[0047] If it is in the set communication level range, the uart protocol of the cpu platform is started based on the communication level to obtain the startup status information;
[0048] Determine whether the startup status information meets the set startup condition information;
[0049] If the set startup condition information is met, the adjustment result is obtained; if the set startup condition information is not met, the startup is determined to have failed, optimization information is generated, and the startup mode is adjusted based on the optimization information;
[0050] If it is not in the set communication level interval, correction information is generated, and the current communication level value is adjusted based on the correction information.
[0051] Optionally, in the system for implementing a serial keyboard based on the serio protocol described in the embodiment of the present application, analyzing data receiving status information based on the adjustment result, and setting parameter information of the uart protocol based on the receiving status information, specifically including:
[0052] Get the adjustment result and determine whether the adjustment result is successful;
[0053] If successful, the data receiving state information is obtained, and the data receiving state information is compared with the set receiving state information to obtain the state deviation rate;
[0054] Determining whether the state deviation rate is greater than or equal to a set state deviation rate threshold;
[0055] If it is greater than the set state deviation rate threshold, the data receiving parameters are adjusted; if it is less than the set state deviation rate threshold, the parameter information of the uart protocol is set;
[0056] If it fails, adjust the uart protocol and trigger the adjustment result again.
[0057] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a method program for implementing a serial port keyboard based on the serio protocol. When the method program for implementing a serial port keyboard based on the serio protocol is executed by a processor, the steps of the method for implementing a serial port keyboard based on the serio protocol as described in any one of the above items are implemented.
[0058] As can be seen from the above, the embodiment of the present application provides a method, system and medium for realizing a serial port keyboard based on the serio protocol, by setting the communication level, starting the uart protocol on the cpu platform side based on the communication level, and obtaining the adjustment result; analyzing the data receiving status information based on the adjustment result, and setting the parameter information of the uart protocol based on the receiving status information; parsing the uart data based on the parameter information of the uart protocol to obtain the analysis information; linking the external keyboard based on the analysis information to analyze the HID key value receiving information, and setting the uart keyboard serial port switching rule according to the HID key value receiving information; switching the uart keyboard communication based on the uart keyboard serial port switching rule to generate the switching information, controlling the uart keyboard serial port connection mode based on the switching information, and connecting the keyboard or computer according to the uart keyboard serial port connection mode; using the serio protocol to realize a software method capable of simultaneously connecting the computer and the keyboard through the uart keyboard, so that the terminal user can connect the computer and the keyboard at the same time without conflict, and can freely select the uart baud rate, thereby improving the keyboard response speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0060] Figure 1 A flowchart of a method for implementing a serial port keyboard based on the serio protocol provided in an embodiment of the present application;
[0061] Figure 2 A flow chart of a method for obtaining a tuning result of a method for implementing a serial port keyboard based on the serio protocol provided in an embodiment of the present application;
[0062] Figure 3 A flow chart of a method for setting parameter information of the UART protocol for a method for implementing a serial port keyboard based on the serio protocol provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0064] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0065] Please refer to Figure 1 , Figure 1 This is a flow chart of a method for implementing a serial port keyboard based on the serio protocol in some embodiments of the present application. The method for implementing a serial port keyboard based on the serio protocol is used in a terminal device, and the method for implementing a serial port keyboard based on the serio protocol includes the following steps:
[0066] S101, setting the communication level, starting the uart protocol on the cpu platform side based on the communication level, and obtaining the adjustment result;
[0067] S102, analyzing data receiving status information based on the adjustment result, and setting parameter information of the uart protocol based on the receiving status information;
[0068] S103, parsing the UART data based on the parameter information of the UART protocol to obtain parsing information;
[0069] S104, linking the external keyboard based on the parsed information to analyze the HID key value receiving information, and setting the UART keyboard serial port switching rule according to the HID key value receiving information;
[0070] S105, switching the communication of the uart keyboard based on the uart keyboard serial port switching rule, generating switching information, controlling the uart keyboard serial port connection mode based on the switching information, and connecting the keyboard or computer according to the uart keyboard serial port connection mode.
[0071] It should be noted that the 3.3v txrx communication level is used to adjust the uart protocol on the cpu platform side, for example, self-transmission and self-reception can correctly receive data, and custom uart protocol key-value codes, special data packets, baud rates (uart transmission rate, which can be high or low), encryption formats, such as special data headers + data bytes, etc. are written. The kernel layer driver code is written to implement the parsing of the uart data module, encapsulate it into a serio protocol module, and use system-level interrupts for more timely response. The software module of the serio protocol is linked to the external keyboard. After the link is successful, it can correctly receive and convert the HID key value and then report it to the system layer, which can be perfectly compatible with the current uart keyboard.
[0072] Please refer to Figure 2 , Figure 2 The present invention is a flowchart of a method for obtaining the adjustment result of a method for implementing a serial keyboard based on the serio protocol in some embodiments of the present invention. According to an embodiment of the present invention, a communication level is set, and the uart protocol of the cpu platform is started based on the communication level to obtain the adjustment result, which specifically includes:
[0073] S201, setting a communication level interval, obtaining a current communication level value, and determining whether the current communication level value is within the set communication level interval;
[0074] S202, if it is in the set communication level range, then start the uart protocol of the cpu platform side based on the communication level to obtain the startup status information;
[0075] S203, determining whether the startup status information satisfies the set startup condition information;
[0076] S204, if the set startup condition information is met, a commissioning result is obtained; if the set startup condition information is not met, it is determined that the startup fails, optimization information is generated, and the startup mode is adjusted based on the optimization information;
[0077] S205: If the communication level is not in the set communication level interval, generate correction information, and adjust the current communication level value based on the correction information.
[0078] It should be noted that by analyzing whether the current communication level value meets the requirements, it is determined whether the startup conditions are met, thereby optimizing and adjusting the startup mode, and dynamically adjusting the communication level value to ensure normal communication.
[0079] Please refer to Figure 3 , Figure 3 The present invention is a flowchart of a method for setting parameter information of the UART protocol in a method for implementing a serial port keyboard based on the serio protocol in some embodiments of the present invention. According to an embodiment of the present invention, based on the adjustment result analysis data reception status information, based on the reception status information, setting the parameter information of the UART protocol specifically includes:
[0080] S301, obtaining the adjustment result, and determining whether the adjustment result is successful;
[0081] S302, if successful, obtaining data receiving state information, comparing the data receiving state information with the set receiving state information, and obtaining a state deviation rate;
[0082] S303, determining whether the state deviation rate is greater than or equal to a set state deviation rate threshold;
[0083] S304, if it is greater than the set state deviation rate threshold, adjust the data receiving parameters; if it is less than the set state deviation rate threshold, set the parameter information of the UART protocol;
[0084] S305, if it fails, adjust the uart protocol and trigger the adjustment result again.
[0085] It should be noted that by analyzing the data reception status information, it is determined whether the data reception parameters are normal, thereby ensuring that the parameter information for setting the uart protocol has a high degree of accuracy.
[0086] According to an embodiment of the present invention, the UART data is parsed based on the parameter information of the UART protocol to obtain parsed information, and then the following is further included:
[0087] Obtain the parameter information of the uart protocol, encrypt the transmission data based on the parameter information of the uart protocol, and obtain the encryption key;
[0088] Encrypt the UART data for transmission based on the encryption information to obtain the transmission data, and generate a decryption key matching the encryption key based on the transmission data;
[0089] Receive a decryption instruction, call a matching decryption key based on the decryption instruction, decrypt the transmitted data based on the decryption key, and obtain plaintext data;
[0090] Redundant data is analyzed based on plaintext data, and the redundant data is removed to obtain parsed information.
[0091] It should be noted that the security of data transmission is guaranteed by encrypting the transmitted data. When decrypting the transmitted data, the accurate decryption of the transmitted data is achieved through the matching decryption key, which reduces the abnormal deviation in the data decryption process. The keyboard can be fully customized according to the special customization needs of different customers. For example, fully encrypted UART data and data packets sent with different key values can be specified for encryption. Only by parsing the correct data header + data packet can the correct keyboard key value be obtained. It can be applied to some operating systems with strong encryption that are not suitable for the general public.
[0092] According to an embodiment of the present invention, based on the parsing information, linking the external keyboard to analyze the HID key value receiving information, and setting the UART keyboard serial port switching rule according to the HID key value receiving information, specifically includes:
[0093] Obtain parsing information, link the external keyboard based on the parsing information, analyze the operating status of the external keyboard, and obtain HID key value receiving information based on the operating status of the external keyboard;
[0094] Compare the HID key value receiving information with the standard receiving information to obtain the receiving deviation rate;
[0095] If the receiving deviation rate is greater than the first receiving deviation rate threshold and less than the second receiving deviation rate threshold, generating a first receiving rule;
[0096] If the receiving deviation rate is greater than or equal to the second receiving deviation rate threshold, generating a second receiving rule;
[0097] The first receiving rule and the second receiving rule are dynamically switched based on the HID key value receiving information to obtain the uart keyboard serial port switching rule.
[0098] It should be noted that by analyzing the HID key value receiving information, the keyboard serial port switching rules are dynamically adjusted to ensure that the uart keyboards of different manufacturers can be compatible with the current motherboard and platform. On the platform and motherboard with only one USB port, there is no longer a master-slave conflict between device and host modes, so that the terminal user can use the keyboard while connecting to the computer.
[0099] According to an embodiment of the present invention, the communication of the UART keyboard is switched based on the UART keyboard serial port switching rule, switching information is generated, the UART keyboard serial port connection mode is controlled based on the switching information, and the keyboard or computer is connected according to the UART keyboard serial port connection mode, specifically including:
[0100] Get the uart keyboard serial port switching rules, match the corresponding HID key value based on the uart keyboard serial port switching rules to receive information, and get the baud rate of the uart keyboard;
[0101] Analyze data transmission rate based on the baud rate of the uart keyboard;
[0102] Analyze whether the UART keyboard serial port switching rules match based on data transmission rate;
[0103] If they match, the switching information is generated, and the UART keyboard serial port is controlled to connect to the keyboard or computer based on the switching information;
[0104] If they do not match, adjust the HID key value to receive information.
[0105] It should be noted that by analyzing whether the data transmission rate under different serial port switching rules matches the current serial port transmission rule, the HID key value receiving information is dynamically adjusted to improve the data transmission efficiency.
[0106] According to an embodiment of the present invention, the method further includes: obtaining a current keyboard serial port transmission rule, and analyzing a uart keyboard response speed based on the current keyboard serial port transmission rule;
[0107] Determine whether the uart keyboard response speed reaches the set response speed;
[0108] If the set response speed is not reached, adjust the baud rate of the uart keyboard;
[0109] If the set response speed is reached, it is determined that the current keyboard serial port transmission rule meets the requirements.
[0110] It should be noted that by judging the response speed of the uart keyboard, the accuracy of the keyboard serial port transmission rule is reversely verified, thereby dynamically adjusting the baud rate of the uart keyboard and reducing data transmission delay.
[0111] In a second aspect, an embodiment of the present application provides a system for implementing a serial port keyboard based on the serio protocol, the system comprising: a memory and a processor, the memory comprising a program for implementing a method for implementing a serial port keyboard based on the serio protocol, and when the program for implementing a method for implementing a serial port keyboard based on the serio protocol is executed by the processor, the following steps are implemented:
[0112] Set the communication level, start the uart protocol on the cpu platform based on the communication level, and get the commissioning result;
[0113] Analyze the data receiving status information based on the adjustment result, and set the parameter information of the UART protocol based on the receiving status information;
[0114] Parse the UART data based on the parameter information of the UART protocol to obtain parsed information;
[0115] Based on the parsed information, connect to the external keyboard to analyze the HID key value receiving information, and set the uart keyboard serial port switching rules according to the HID key value receiving information;
[0116] Based on the uart keyboard serial port switching rule, the uart keyboard is communicated and switched, switching information is generated, the uart keyboard serial port connection mode is controlled based on the switching information, and the keyboard or computer is connected according to the uart keyboard serial port connection mode.
[0117] It should be noted that the 3.3v txrx communication level is used to adjust the uart protocol on the cpu platform side, for example, self-transmission and self-reception can correctly receive data, and custom uart protocol key-value codes, special data packets, baud rates (uart transmission rate, which can be high or low), encryption formats, such as special data headers + data bytes, etc. are written. The kernel layer driver code is written to implement the parsing of the uart data module, encapsulate it into a serio protocol module, and use system-level interrupts for more timely response. The software module of the serio protocol is linked to the external keyboard. After the link is successful, it can correctly receive and convert the HID key value and then report it to the system layer, which can be perfectly compatible with the current uart keyboard.
[0118] According to an embodiment of the present invention, a communication level is set, and the uart protocol of the cpu platform is started based on the communication level to obtain a tuning result, which specifically includes:
[0119] Set the communication level interval, obtain the current communication level value, and determine whether the current communication level value is within the set communication level interval;
[0120] If it is in the set communication level range, the uart protocol of the cpu platform is started based on the communication level to obtain the startup status information;
[0121] Determine whether the startup status information meets the set startup condition information;
[0122] If the set startup condition information is met, the adjustment result is obtained; if the set startup condition information is not met, the startup is determined to have failed, optimization information is generated, and the startup mode is adjusted based on the optimization information;
[0123] If it is not in the set communication level interval, correction information is generated, and the current communication level value is adjusted based on the correction information.
[0124] It should be noted that by analyzing whether the current communication level value meets the requirements, it is determined whether the startup conditions are met, thereby optimizing and adjusting the startup mode, and dynamically adjusting the communication level value to ensure normal communication.
[0125] According to an embodiment of the present invention, the data receiving status information is analyzed based on the adjustment result, and the parameter information of the uart protocol is set based on the receiving status information, which specifically includes:
[0126] Get the adjustment result and determine whether the adjustment result is successful;
[0127] If successful, the data receiving state information is obtained, and the data receiving state information is compared with the set receiving state information to obtain the state deviation rate;
[0128] Determine whether the state deviation rate is greater than or equal to a set state deviation rate threshold;
[0129] If it is greater than the set state deviation rate threshold, the data receiving parameters are adjusted; if it is less than the set state deviation rate threshold, the parameter information of the uart protocol is set;
[0130] If it fails, adjust the uart protocol and trigger the adjustment result again.
[0131] It should be noted that by analyzing the data reception status information, it is determined whether the data reception parameters are normal, thereby ensuring that the parameter information for setting the uart protocol has a high degree of accuracy.
[0132] According to an embodiment of the present invention, the UART data is parsed based on the parameter information of the UART protocol to obtain parsed information, and then the following is further included:
[0133] Obtain the parameter information of the uart protocol, encrypt the transmission data based on the parameter information of the uart protocol, and obtain the encryption key;
[0134] Encrypt the UART data for transmission based on the encryption information to obtain the transmission data, and generate a decryption key matching the encryption key based on the transmission data;
[0135] Receive a decryption instruction, call a matching decryption key based on the decryption instruction, decrypt the transmitted data based on the decryption key, and obtain plaintext data;
[0136] Redundant data is analyzed based on plaintext data, and the redundant data is removed to obtain parsed information.
[0137] It should be noted that the security of data transmission is guaranteed by encrypting the transmitted data. When decrypting the transmitted data, the accurate decryption of the transmitted data is achieved through the matching decryption key, which reduces the abnormal deviation in the data decryption process. The keyboard can be fully customized according to the special customization needs of different customers. For example, fully encrypted UART data and data packets sent with different key values can be specified for encryption. Only by parsing the correct data header + data packet can the correct keyboard key value be obtained. It can be applied to some operating systems with strong encryption that are not suitable for the general public.
[0138] According to an embodiment of the present invention, based on the parsing information, linking the external keyboard to analyze the HID key value receiving information, and setting the UART keyboard serial port switching rule according to the HID key value receiving information, specifically includes:
[0139] Obtain parsing information, link the external keyboard based on the parsing information, analyze the operating status of the external keyboard, and obtain HID key value receiving information based on the operating status of the external keyboard;
[0140] Compare the HID key value receiving information with the standard receiving information to obtain the receiving deviation rate;
[0141] If the receiving deviation rate is greater than the first receiving deviation rate threshold and less than the second receiving deviation rate threshold, generating a first receiving rule;
[0142] If the receiving deviation rate is greater than or equal to the second receiving deviation rate threshold, generating a second receiving rule;
[0143] The first receiving rule and the second receiving rule are dynamically switched based on the HID key value receiving information to obtain the uart keyboard serial port switching rule.
[0144] It should be noted that by analyzing the HID key value receiving information, the keyboard serial port switching rules are dynamically adjusted to ensure that the uart keyboards of different manufacturers can be compatible with the current motherboard and platform. On the platform and motherboard with only one USB port, there is no longer a master-slave conflict between device and host modes, so that the terminal user can use the keyboard while connecting to the computer.
[0145] According to an embodiment of the present invention, the communication of the UART keyboard is switched based on the UART keyboard serial port switching rule, switching information is generated, the UART keyboard serial port connection mode is controlled based on the switching information, and the keyboard or computer is connected according to the UART keyboard serial port connection mode, specifically including:
[0146] Get the uart keyboard serial port switching rules, match the corresponding HID key value based on the uart keyboard serial port switching rules to receive information, and get the baud rate of the uart keyboard;
[0147] Analyze data transmission rate based on the baud rate of the uart keyboard;
[0148] Analyze whether the UART keyboard serial port switching rules match based on data transmission rate;
[0149] If they match, the switching information is generated, and the UART keyboard serial port is controlled to connect to the keyboard or computer based on the switching information;
[0150] If they do not match, adjust the HID key value to receive information.
[0151] It should be noted that by analyzing whether the data transmission rate under different serial port switching rules matches the current serial port transmission rule, the HID key value receiving information is dynamically adjusted to improve the data transmission efficiency.
[0152] According to an embodiment of the present invention, the method further includes: obtaining a current keyboard serial port transmission rule, and analyzing a uart keyboard response speed based on the current keyboard serial port transmission rule;
[0153] Determine whether the uart keyboard response speed reaches the set response speed;
[0154] If the set response speed is not reached, adjust the baud rate of the uart keyboard;
[0155] If the set response speed is reached, it is determined that the current keyboard serial port transmission rule meets the requirements.
[0156] It should be noted that by judging the response speed of the uart keyboard, the accuracy of the keyboard serial port transmission rule is reversely verified, thereby dynamically adjusting the baud rate of the uart keyboard and reducing data transmission delay.
[0157] A third aspect of the present invention provides a computer-readable storage medium, which includes a method program for implementing a serial port keyboard based on the serio protocol. When the method program for implementing a serial port keyboard based on the serio protocol is executed by a processor, the steps of any of the above-mentioned methods for implementing a serial port keyboard based on the serio protocol are implemented.
[0158] The invention discloses a method, system and medium for realizing serial port keyboard based on serio protocol. The method comprises the following steps: setting a communication level, starting a uart protocol of a cpu platform end based on the communication level, and obtaining a tuning result; analyzing data receiving state information based on the tuning result, and setting parameter information of a uart protocol based on the receiving state information; parsing uart data based on the parameter information of the uart protocol to obtain parsing information; linking an external keyboard to analyze HID key value receiving information based on the parsing information, and setting a uart keyboard serial port switching rule according to the HID key value receiving information; performing communication switching on the uart keyboard based on the uart keyboard serial port switching rule to generate switching information, controlling a uart keyboard serial port connection mode based on the switching information, and connecting a keyboard or a computer according to the uart keyboard serial port connection mode; and realizing a software method capable of simultaneously connecting a computer and a keyboard through a uart keyboard using the serio protocol, so that a terminal user can connect a computer and a keyboard at the same time without conflict, and can freely select a uart baud rate, thereby improving a keyboard response speed.
[0159] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0160] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0161] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0162] Those skilled in the art can understand that: all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, the aforementioned program can be stored in a readable storage medium, and when the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, and other media that can store program codes.
[0163] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
Claims
1. A method for implementing a serial port keyboard based on the serio protocol, characterized in that: include: Set the communication level, start the uart protocol on the cpu platform based on the communication level, and get the commissioning result; Analyze the data receiving status information based on the adjustment result, and set the parameter information of the UART protocol based on the receiving status information; Parse the UART data based on the parameter information of the UART protocol to obtain parsed information; Based on the parsed information, connect to the external keyboard to analyze the HID key value receiving information, and set the uart keyboard serial port switching rules according to the HID key value receiving information; Based on the uart keyboard serial port switching rule, the uart keyboard is switched for communication, the switching information is generated, the uart keyboard serial port connection mode is controlled based on the switching information, and the keyboard or computer is connected according to the uart keyboard serial port connection mode; Set the communication level, start the uart protocol on the cpu platform based on the communication level, and get the commissioning results, including: Set the communication level interval, obtain the current communication level value, and determine whether the current communication level value is within the set communication level interval; If it is in the set communication level range, the uart protocol of the cpu platform is started based on the communication level to obtain the startup status information; Determine whether the startup status information meets the set startup condition information; If the set startup condition information is met, the adjustment result is obtained; if the set startup condition information is not met, the startup is determined to have failed, optimization information is generated, and the startup mode is adjusted based on the optimization information; If it is not in the set communication level interval, correction information is generated, and the current communication level value is adjusted based on the correction information.
2. The method for implementing a serial port keyboard based on the serio protocol according to claim 1, characterized in that: Analyze the data receiving status information based on the adjustment result, and set the parameter information of the uart protocol based on the receiving status information, including: Get the adjustment result and determine whether the adjustment result is successful; If successful, the data receiving state information is obtained, and the data receiving state information is compared with the set receiving state information to obtain the state deviation rate; Determining whether the state deviation rate is greater than or equal to a set state deviation rate threshold; If it is greater than the set state deviation rate threshold, the data receiving parameters are adjusted; if it is less than the set state deviation rate threshold, the parameter information of the uart protocol is set; If it fails, adjust the uart protocol and trigger the adjustment result again.
3. The method for implementing a serial port keyboard based on the serio protocol according to claim 2, characterized in that: Parse the uart data based on the parameter information of the uart protocol to obtain the parsed information, and then include: Obtain the parameter information of the uart protocol, encrypt the transmission data based on the parameter information of the uart protocol, and obtain the encryption key; Encrypt the UART data for transmission based on the encryption information to obtain the transmission data, and generate a decryption key matching the encryption key based on the transmission data; Receive a decryption instruction, call a matching decryption key based on the decryption instruction, decrypt the transmitted data based on the decryption key, and obtain plaintext data; Redundant data is analyzed based on plaintext data, and the redundant data is removed to obtain parsed information.
4. The method for implementing a serial keyboard based on the serio protocol according to claim 3, characterized in that: Based on the parsed information, the external keyboard is linked to analyze the HID key value receiving information, and the uart keyboard serial port switching rules are set according to the HID key value receiving information, including: Obtain parsing information, link the external keyboard based on the parsing information, analyze the operating status of the external keyboard, and obtain HID key value receiving information based on the operating status of the external keyboard; Compare the HID key value receiving information with the standard receiving information to obtain the receiving deviation rate; If the receiving deviation rate is greater than the first receiving deviation rate threshold and less than the second receiving deviation rate threshold, generating a first receiving rule; If the receiving deviation rate is greater than or equal to the second receiving deviation rate threshold, generating a second receiving rule; The first receiving rule and the second receiving rule are dynamically switched based on the HID key value receiving information to obtain the uart keyboard serial port switching rule.
5. The method for implementing a serial keyboard based on the serio protocol according to claim 4, characterized in that: Based on the uart keyboard serial port switching rule, the uart keyboard is switched for communication, the switching information is generated, the uart keyboard serial port connection mode is controlled based on the switching information, and the keyboard or computer is connected according to the uart keyboard serial port connection mode, specifically including: Get the uart keyboard serial port switching rules, match the corresponding HID key value based on the uart keyboard serial port switching rules to receive information, and get the baud rate of the uart keyboard; Analyze data transmission rate based on the baud rate of the uart keyboard; Analyze whether the UART keyboard serial port switching rules match based on data transmission rate; If they match, the switching information is generated, and the UART keyboard serial port is controlled to connect to the keyboard or computer based on the switching information; If they do not match, adjust the HID key value to receive information.
6. A system for implementing a serial keyboard based on the serio protocol, characterized in that: The system includes: a memory and a processor, wherein the memory includes a program for implementing a method for a serial port keyboard based on a serio protocol, and when the program for implementing a method for a serial port keyboard based on a serio protocol is executed by the processor, the following steps are implemented: Set the communication level, start the uart protocol on the cpu platform based on the communication level, and get the commissioning result; Analyze the data receiving status information based on the adjustment result, and set the parameter information of the UART protocol based on the receiving status information; Parse the UART data based on the parameter information of the UART protocol to obtain parsed information; Based on the parsed information, connect to the external keyboard to analyze the HID key value receiving information, and set the uart keyboard serial port switching rules according to the HID key value receiving information; Based on the uart keyboard serial port switching rule, the uart keyboard is switched for communication, the switching information is generated, the uart keyboard serial port connection mode is controlled based on the switching information, and the keyboard or computer is connected according to the uart keyboard serial port connection mode; Set the communication level, start the uart protocol on the cpu platform based on the communication level, and get the commissioning results, including: Set the communication level interval, obtain the current communication level value, and determine whether the current communication level value is within the set communication level interval; If it is in the set communication level range, the uart protocol of the cpu platform is started based on the communication level to obtain the startup status information; Determine whether the startup status information meets the set startup condition information; If the set startup condition information is met, the adjustment result is obtained; if the set startup condition information is not met, the startup is determined to have failed, optimization information is generated, and the startup mode is adjusted based on the optimization information; If it is not in the set communication level interval, correction information is generated, and the current communication level value is adjusted based on the correction information.
7. The system for implementing a serial keyboard based on the serio protocol according to claim 6, characterized in that: Analyze the data receiving status information based on the adjustment result, and set the parameter information of the uart protocol based on the receiving status information, including: Get the adjustment result and determine whether the adjustment result is successful; If successful, the data receiving state information is obtained, and the data receiving state information is compared with the set receiving state information to obtain the state deviation rate; Determining whether the state deviation rate is greater than or equal to a set state deviation rate threshold; If it is greater than the set state deviation rate threshold, the data receiving parameters are adjusted; if it is less than the set state deviation rate threshold, the parameter information of the uart protocol is set; If it fails, adjust the uart protocol and trigger the adjustment result again.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a method program for implementing a serial port keyboard based on the serio protocol. When the method program for implementing a serial port keyboard based on the serio protocol is executed by a processor, the steps of the method for implementing a serial port keyboard based on the serio protocol as described in any one of claims 1 to 5 are implemented.
