A method and system for configuring peripheral parameters through a serial port
By setting up a bypass detection circuit in the peripheral device to connect the IO port to monitor the leading signal, the problem of serial communication parameter configuration depend on factory settings is solved, and a safe, reliable, convenient and efficient parameter configuration is achieved to ensure communication stability and data security.
Patent Information
- Application Number
- CN202211138525.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-19
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-09-19
AI Technical Summary
In the prior art, the serial port communication parameter configuration depends on factory settings, which is easy to be lost or forgotten, resulting in unreliable communication and cumbersome operation, and historical data will be lost when the factory settings are restored.
By setting a bypass detection circuit in the peripheral device, using the IO port to connect the serial port Tx and Rx pins in parallel, monitor the leading signals sent by the upper computer, and send the leading signals with the baud rate multiple times to configure peripheral parameters to avoid relying on factory settings and mechanical key recovery.
It realizes a safe, reliable, convenient and efficient serial port parameter configuration, reduces the rate of error judgment, ensures that normal communication is not affected and device data is not lost.
Smart Images

Figure CN115421801B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and particularly to a method and system for configuring peripheral parameters through a serial port. Background Art
[0002] A serial interface (serial port) is a device that can convert parallel data characters received from a CPU into a continuous serial data stream for transmission, and at the same time convert the received serial data stream into parallel data characters for supply to the CPU. The concept of serial communication is very simple. The serial port sends and receives bytes bit by bit. Although slower than parallel communication by byte, the serial port can send data on one wire while receiving data on another wire. The serial port is a very common device communication protocol on a computer, referring to a communication method in which data is transmitted bit by bit between a peripheral and a computer through data signal lines, ground wires, control lines, etc.
[0003] Most computers (excluding laptops) contain two RS-232-based serial ports. The serial port is also a common communication protocol for instrument and meter devices.
[0004] The most important parameters for serial communication are baud rate, data bits, stop bits, and parity check. For two ports communicating with each other, these parameters must match.
[0005] For two new ports that need to communicate, their parameters need to be configured first so that the parameters of the two ports match to achieve normal communication.
[0006] The traditional parameter configuration method is as follows: A DIP switch is required to configure the port address. For the setting of the baud rate, it depends on the factory-set baud rate. Once the factory-set baud rate is lost or forgotten, the factory settings can only be restored by mechanical keys, such as restoring the factory settings by long-pressing a certain key.
[0007] Regarding the factory-set baud rate, people are very likely to forget it. Even if it is recorded in the user manual, the user manual is easy to lose. Therefore, relying on the factory-set baud rate to configure the communication between two ports between the host computer and the peripheral is unreliable. In addition, even if the factory settings can be restored through the operation of mechanical keys, however, the method of restoring the factory settings through mechanical keys is cumbersome to operate. Moreover, once the factory settings are restored, the useful historical usage data of the peripheral or the host computer will be lost, causing great losses.
[0008] Therefore, a safe, reliable, convenient, and efficient communication port configuration method is needed by people. Summary of the Invention
[0009] The object of the present invention is to provide a method and system for configuring peripheral parameters through a serial port to solve the above problems existing in the prior art.
[0010] In a first aspect, an embodiment of the present invention provides a method for configuring peripheral parameters through a serial port, which is applied to a parameter configuration system. The parameter configuration system includes a peripheral device and a host computer. A bypass detection circuit is provided in the peripheral device; the peripheral device and the host computer are connected through a serial port module. The serial port module includes a first serial port and a second serial port. The first serial port includes a first serial port Rx pin and a first serial port Tx pin. The second serial port includes a second serial port Rx pin and a second serial port Tx pin. The first serial port module is provided in the host computer, and the second serial port module is provided in the peripheral device. The first serial port Rx pin is connected to the second serial port Tx pin; the first serial port Tx pin is connected to the second serial port Rx pin; the peripheral device sends information to the host computer through the second serial port Tx pin, and the host computer receives the information sent by the peripheral device through the first serial port Rx pin; the host computer sends information to the peripheral device through the first serial port Tx pin, and the peripheral device receives the information sent by the host computer through the second serial port Rx pin;
[0011] The bypass detection circuit is connected to the host computer through the IO port of the peripheral device itself. The IO port is set as an input IO, and the IO port is connected to the first serial port Tx pin and is in parallel with the second serial port Rx pin; a parameter configuration module is configured in the bypass detection circuit, and the parameter configuration module is used to monitor the information sent by the host computer to the peripheral device through the IO port;
[0012] The method includes:
[0013] The host computer sets the serial port parameters of the local side to default parameters;
[0014] The host computer sends a preamble signal to the bypass detection module continuously for multiple times through the first serial port Tx pin based on the set baud rate through the IO port;
[0015] If the parameter configuration module in the bypass detection circuit receives the preamble signal continuously for N times, it is determined that the parameters of the peripheral interface need to be configured. The peripheral device stops the operation of the second serial port of the serial port module, parses the preamble signal through the IO port, sets the serial port parameters of the second serial port to default parameters, and sends response protocol data to the host computer through the second serial port Tx pin;
[0016] Wherein, the N is a positive integer.
[0017] Optionally, the method further includes:
[0018] If the bypass detection module does not receive the preamble signal continuously for N times, the number of received preamble signals is recounted.
[0019] Optionally, the default parameters include the baud rate.
[0020] Optionally, the host computer includes a PC.
[0021] Optionally, setting the serial port parameters of the serial port module includes configuring the baud rate of the serial port module.
[0022] Optionally, the baud rate is set to 110 bps or 300 bps.
[0023] Optionally, the pulse width of the preamble signal is TP, and TP = 10 / baud rate. For example, TP = 10 / set baud rate.
[0024] Optionally, the preamble signal includes 8 data bits, one stop bit, and one start bit.
[0025] Optionally, the preamble signal is 0x00.
[0026] In a second aspect, an embodiment of the present invention provides a parameter configuration system.
[0027] The parameter configuration system includes a peripheral device and a host computer. A bypass detection circuit is provided in the peripheral device. The peripheral device is connected to the host computer through a serial port module. The serial port module includes a first serial port and a second serial port. The first serial port includes a first serial port Rx pin and a first serial port Tx pin. The second serial port includes a second serial port Rx pin and a second serial port Tx pin. The first serial port module is provided in the host computer, and the second serial port module is provided in the peripheral device. The first serial port Rx pin is connected to the second serial port Tx pin; the first serial port Tx pin is connected to the second serial port Rx pin; the peripheral device sends information to the host computer through the second serial port Tx pin, and the host computer receives the information sent by the peripheral device through the first serial port Rx pin; the host computer sends information to the peripheral device through the first serial port Tx pin, and the peripheral device receives the information sent by the host computer through the second serial port Rx pin.
[0028] The bypass detection circuit is connected to the host computer through the IO port of the peripheral device itself. The IO port is set as an input IO, and the IO port is connected to the first serial port Tx pin and is in parallel with the second serial port Rx pin. A parameter configuration module is configured in the bypass detection circuit. The parameter configuration module is used to monitor the information sent by the host computer to the peripheral device through the IO port.
[0029] The parameter setting unit provided in the host computer is used to set the serial port parameters of the host computer locally as default parameters. The communication unit provided in the host computer is used to continuously send a preamble signal to the bypass detection module multiple times through the first serial port Tx pin based on the set baud rate through the IO port.
[0030] The parameter configuration module is further used for
[0031] If the parameter configuration module in the bypass detection circuit receives the preamble signal continuously for N times, it is determined that the parameters of the peripheral interface need to be configured. The peripheral device stops the operation of the second serial port Rx pin of the serial port module, parses the preamble signal through the IO port, sets the serial port parameters of the second serial port to the default parameters by the peripheral device, and sends the response protocol data to the host computer through the second serial port Tx pin;
[0032] Wherein, the N is a positive integer.
[0033] Compared with the prior art, the embodiments of the present invention achieve the following beneficial effects:
[0034] The embodiments of the present invention provide a method and a system for configuring peripheral parameters through a serial port. The system includes a peripheral device and a host computer. A bypass detection circuit is provided in the peripheral device; the peripheral device is connected to the host computer through a serial port module. The serial port module includes a first serial port and a second serial port. The first serial port includes a first serial port Rx pin and a first serial port Tx pin, and the second serial port includes a second serial port Rx pin and a second serial port Tx pin. The first serial port module is provided in the host computer, and the second serial port module is provided in the peripheral device. The first serial port Rx pin is connected to the second serial port Tx pin. The first serial port Tx pin is connected to the second serial port Rx pin. The peripheral device sends information to the host computer through the second serial port Tx pin, and the host computer receives the information sent by the peripheral device through the first serial port Rx pin. The host computer sends information to the peripheral device through the first serial port Tx pin, and the peripheral device receives the information sent by the host computer through the second serial port Rx pin. The bypass detection circuit is connected to the host computer through the IO port of the peripheral device itself. The IO port is set as an input IO, and the IO port is connected to the first serial port Tx pin and is connected in parallel with the second serial port Rx pin; a parameter configuration module is configured in the bypass detection circuit. The parameter configuration module is used to monitor the information sent by the host computer to the peripheral device through the IO port. Set the local serial port parameters to the default parameters by the host computer.. The host computer sends a preamble signal to the bypass detection module continuously for multiple times through the IO port based on the set baud rate through the first serial port Tx pin. If the parameter configuration module in the bypass detection circuit receives the preamble signal continuously for N times, it is determined that the parameters of the peripheral interface need to be configured. The peripheral device stops the operation of the second serial port of the serial port module, parses the preamble signal through the IO port, sets the serial port parameters of the second serial port to the default parameters by the peripheral device, and sends the response protocol data to the host computer through the second serial port Tx pin, where N is a positive integer.
[0035] Through the above solution, on the one hand, by connecting an IO port to the Tx pin of the first serial port for the host computer to send information to the peripheral device and paralleling it with the Rx pin of the second serial port, the parameter configuration module set in the peripheral device can monitor the information sent by the host computer to the peripheral device through this IO port. On the one hand, it does not occupy the serial port module for normal communication, saving resources. On the other hand, the port for monitoring whether parameter configuration is required can be distinguished from normal communication, improving the accuracy of monitoring, reducing the error rate, and not affecting normal communication.
[0036] On the other hand, the peripheral device needs to continuously obtain enough (the value of N) leading signal pulses to determine that the host computer needs to perform parameter setting on the peripheral device, preventing the detection program from misjudging the activation of the parameter setting function under normal communication conditions. Therefore, based on the paralleled and additional peripheral IO port, a misjudgment prevention for parameter configuration is carried out once. On this basis, further parameter configuration judgment is carried out based on the number of consecutive check-in information pulses, which can improve the accuracy of determining whether parameter configuration is required, reduce the false alarm rate, reduce the impact on normal communication caused by false alarms, and improve the communication efficiency and performance of the system.
[0037] On yet another hand, it does not depend on the baud rate set during production or any parameters, nor does it perform the restoration of the cumbersome and unsafe mechanical button factory settings. When parameter configuration is required, it listens and configures the address and baud rate of the port of the peripheral device according to the baud rate sent by the host computer, realizing the parameter configuration of the communication port between the two host computers and the peripheral device, and then realizing the normal communication between the two ports. The operation is simple, the accuracy is high, and the data of the host computer or the peripheral device will not be lost, with high security. Therefore, the parameter setting method of the above method has high security, high reliability, convenience, high practicality, and high efficiency.
[0038] Therefore, according to the above method, the communication port can be configured safely, reliably, conveniently, and efficiently, that is, the host computer can safely, reliably, conveniently, and efficiently perform parameter configuration on the peripheral device to communicate with it, so as to realize the normal, smooth, and stable communication between the peripheral device and the host computer. Description of the Drawings
[0039] By reading the detailed description of the non-restrictive embodiments with reference to the following drawings, other features, objectives, and advantages of the present invention will become more obvious:
[0040] Figure 1 Shows a schematic block diagram of a parameter configuration system provided by an embodiment of the present invention.
[0041] Figure 2 Shows a schematic block diagram of a parameter configuration system for a temperature sensing module based on a 485 bus provided by an embodiment of the present invention.
[0042] Figure 3 The flowchart of a method for configuring peripheral parameters through a serial port provided by an embodiment of the present invention is shown.
[0043] Figure 4 The schematic diagram of a preamble signal provided by an embodiment of the present invention is shown.
[0044] Figure 5 The flowchart of signal interaction between a host computer and a peripheral device in a parameter configuration system provided by an embodiment of the present invention is shown. Detailed implementation manners
[0045] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings.
[0046] Before elaborating on the technical solution provided by the embodiment of the present invention, first, taking a temperature sensing module based on the 485 bus as an example of the host computer, a basic elaboration is made:
[0047] A temperature sensing module based on the 485 bus has only the 485 bus externally. Before use, the baud rate of this module needs to be configured and the address of the 485 bus needs to be set. In the traditional method, a DIP switch is required to configure the 485 address, and the baud rate needs to be preset at the factory and noted in the user manual. If the baud rate is forgotten, the factory settings need to be restored by pressing a certain button for a long time.
[0048] In this way, the baud rate set at the factory is easily lost or forgotten, the operation is cumbersome, and other useful data is easily lost when restoring the factory settings.
[0049] Therefore, the embodiment of the present invention provides a method and system for configuring peripheral parameters through a serial port, which can make the parameter setting of the peripheral more simple and fast. Especially in the case where only one serial port is exposed externally and this serial port is also the only service communication channel, the peripheral device connected to the serial port can be configured safely, reliably, conveniently, quickly, and efficiently, so as to realize normal, stable, and efficient communication between the host computer and the peripheral device.
[0050] Hereinafter, the technical solution provided by the embodiment of the present invention will be further elaborated through embodiments.
[0051] Embodiment 1
[0052] The embodiment of the present invention provides a parameter configuration system. Please refer to Figure 1, the parameter configuration system includes a peripheral device and a host computer. The peripheral device is connected to the host computer through a serial port module. In an embodiment of the present invention, the host computer may be a personal computer (PC). In an embodiment of the present invention, a bypass detection circuit is provided in the peripheral device. The serial port module includes a first serial port and a second serial port. The first serial port includes a first serial port Rx pin (PC_Rx) and a first serial port Tx pin (PC_Tx). The second serial port includes a second serial port Rx pin and a second serial port Tx pin. The first serial port module is provided in the host computer, and the second serial port module is provided in the peripheral device. The first serial port Rx pin is connected to the second serial port Tx pin; the first serial port Tx pin is connected to the second serial port Rx pin. The peripheral device sends information to the host computer through the second serial port Tx pin, and the host computer receives the information sent by the peripheral device through the first serial port Rx pin. The host computer sends information to the peripheral device through the first serial port Tx pin, and the peripheral device receives the information sent by the host computer through the second serial port Rx pin. The bypass detection circuit is connected to the host computer through the I / O port (UIO, Userspace I / O) of the peripheral device itself. The I / O port is set as an input I / O (Input / Output, I / O), and the I / O port is connected to the first serial port Tx pin and is in parallel with the second serial port Rx pin. A parameter configuration module is configured in the bypass detection circuit. The parameter configuration module is used to monitor the information sent by the host computer to the peripheral device through the I / O port to determine whether the peripheral device needs to configure parameters.
[0053] A signal is paralleled to the Rx pin (PC_Tx) of the serial port of the peripheral device to its own I / O (defined as signal UIO) port. This I / O is configured as an input I / O. UIO is used as a trigger signal for the PC and the host computer to set or obtain parameters of the peripheral device. Usually, the pulse width of the UIO port is detected at all times without causing any impact on the communication between the PC, the host computer, and the peripheral device.
[0054] The program of the peripheral device should at least include: 2 basic modules, namely, a serial port communication (service) module and a parameter configuration module. In the normal state, the parameter configuration module will always detect the signal of UIO. Once N consecutive leading signals sent by the host computer are detected, it is determined that the parameters of the peripheral device interface need to be configured, and the operation of configuring the parameters of the peripheral device interface is started. It does not cause any impact on the communication between the PC, the host computer, and the peripheral device.
[0055] Taking the temperature sensing module based on the 485 bus as an example, as Figure 2As shown, the host computer is an RS485 interface chip, and the peripheral is a microcontroller unit (MCU) connected with a temperature sensor. A bypass detection circuit is set in the MCU, and a parameter configuration module is configured in the bypass detection circuit. The MCU and the RS485 interface chip are connected through the PC_Tx (serial port Tx pin) and PC_Rx (serial port Rx pin) of the serial port module (serial port).
[0056] The parameter setting unit set in the host computer is used to set the serial port parameters of the host computer itself to default parameters; the communication unit set in the host computer is used to send a preamble signal to the bypass detection module continuously for multiple times through the first serial port Tx pin based on the set baud rate via the IO port;
[0057] In the embodiment of the present invention, the parameter configuration module is further used to, if the parameter configuration module in the bypass detection circuit receives the preamble signal continuously for N times, determine that the parameters of the peripheral interface need to be configured. The peripheral device stops the operation of the second serial port, parses the preamble signal through the IO port, sets the serial port parameters of the second serial port to default parameters, and sends response protocol data to the host computer through the second serial port Tx pin.
[0058] Wherein, N is a positive integer.
[0059] In the embodiment of the present invention, the parameter configuration system is used to configure the parameters of the peripheral device, and the specific configuration method is the method for configuring the peripheral parameters through the serial port as described below.
[0060] The embodiment of the present invention provides a method for configuring peripheral parameters through the serial port, which is applied to the parameter configuration system, that is, the parameter configuration system is used to execute the method for configuring peripheral parameters through the serial port. As Figure 3 shown, the method for configuring peripheral parameters through the serial port includes:
[0061] S101: The host computer sets the local serial port parameters to default parameters. In the embodiment of the present invention, the default parameters include a set address and / or a set baud rate. The serial port parameters are used to agree that the peripheral device establishes communication with the host computer based on the set address and the set baud rate. The address can be set according to the address of the host computer itself or the agreed address. The host computer setting the local serial port parameters to default parameters is specifically to set the serial port parameters of the first serial port to default parameters.
[0062] S102: The host computer sends a preamble signal to the bypass detection module continuously for multiple times through the first serial port Tx pin based on the set baud rate via the IO port.
[0063] Set the baud rate to a relatively low baud rate, a baud rate that is not commonly used in actual use, such as 110 bps, 300 bps, 600 bps, etc. In the embodiments of the present invention, the preamble signal includes 8 data bits, a stop bit, and a start bit, as Figure 4 shown. Optionally, the preamble signal is 0x00.
[0064] In the embodiments of the present invention, the data of this preamble signal can be arbitrary, and it is required to be 0x00. There are generally two ways to express hexadecimal numbers, for example: 0x11 or 11H. Is there any common convention in patent documents?
[0065] Optionally, the preamble signal carries a setting address set by the host computer.
[0066] S103: If the parameter configuration module in the bypass detection circuit receives the preamble signal continuously for N times, it is determined that the parameters of the peripheral interface need to be configured. The peripheral device stops the operation of the second serial port of the serial port module, parses the preamble signal through the IO port, sets the serial port parameters of the second serial port of the peripheral device to the default parameters, and sends the response protocol data to the host computer through the Tx pin of the second serial port.
[0067] In the embodiments of the present invention, the response protocol data is information indicating that the peripheral device agrees to communicate according to the address and baud rate set by the host computer. After the peripheral device receives the preamble signal sent by the host computer continuously for N times, it parses the received preamble signal through the IO port to parse out the setting address set by the host computer and the setting baud rate of the sent preamble signal. Set the address and baud rate of the peripheral device port, set the baud rate to the setting baud rate of the preamble signal sent by the host computer, and then send the response protocol data to the host computer through the Rx pin of the serial port according to the setting baud rate to inform the host computer that the peripheral device accepts the protocol of communicating with the host computer according to the setting address and setting baud rate. N is a positive integer. Thus, the configuration of the peripheral device port parameters is completed.
[0068] In the embodiments of the present invention, the configuration of the peripheral device port parameters is completed according to the method of the above steps S101 to S103, and the peripheral device and the host computer can communicate at the set baud rate. However, since the set baud rate is an uncommon baud rate, after the peripheral device and the host computer successfully establish a communication channel, they can freely agree to use other baud rates for normal communication.
[0069] As an alternative embodiment, the method includes:
[0070] That is, a signal line is connected in parallel to the Rx line of the device to the GPIO port of the device, and the device has a program to monitor this GPIO port in real time. When the PC does not know the baud rate of the device's serial port, it sends a fixed number of bytes as a preamble signal through the default baud rate, and the real-time monitoring program of the GPIO determines whether the PC has sent the preamble signal, so as to decide whether the device resets the serial port baud rate to the default baud rate to communicate with the PC. The specific operation is as follows: The host computer sets the local serial port baud rate to the default baud rate, and then sends a preamble data of a fixed number of bytes (for example: 10 55H or AAH) to the peripheral device through the serial port. At this time, since the baud rate of the peripheral device may not be the default baud rate, the correct serial port data cannot be parsed, but the UIO port can parse this preamble data (preamble signal) according to the serial port protocol. After the UIO port parses the check-in data, it resets the serial port baud rate of the device to the default baud rate and immediately sends response data to the host computer through the serial port. After the UIO port parses the check-in data, it resets the serial port baud rate of the device to the default baud rate and immediately sends response data to the host computer through the serial port.
[0071] Optionally, the method further includes: if the bypass detection module does not receive the preamble signal continuously for N times, the number of received preamble signals is counted again.
[0072] The serial port parameters of the serial port module include configuring the baud rate and address of the serial port module. The baud rate of the preamble signal sent by the host computer to the bypass detection module through the IO port is 110bps or 300bps. The pulse width of the preamble signal is TP, and TP = 10 / baud rate. Optionally, TP = 10 / 110 or TP = 10 / 300.
[0073] By adopting the above solution, the parameter setting of the peripheral device can be made simpler and faster, especially for the case where only one serial port is exposed externally and this serial port is also the only service communication channel.
[0074] In order to more clearly illustrate the technical solution provided by the present application, please refer to Figure 5 .
[0075] For the host computer, first set the serial port parameters to the default parameters (Ps), and then send the leading signal 0x00 according to the set baud rate. If the peripheral device receives the leading signal, stop the operation of the serial port module and reset the serial port parameters of the peripheral device to the default parameters (Ps). Then send the response protocol data to the host computer according to the set baud rate of the leading signal. If the host computer receives the response protocol data, it can selectively set the serial port parameters (address and communication baud rate), and then send the information of the negotiated baud rate and address to the peripheral device. The peripheral device resets its own address and communication baud rate according to the received address and communication baud rate, and returns the response protocol data to the host computer to inform the host computer that it can communicate according to the address and baud rate set by the host computer. The host computer can also reset the serial port parameters according to the parameters (address and baud rate) sent by the peripheral device, and then return the response protocol data to the peripheral device to inform the peripheral device that it can communicate according to the address and baud rate set by the peripheral device.
[0076] After configuring the parameters of the peripheral device, exit the parameter setting program, that is, stop the operation of the parameter configuration module. At this time, the serial port module can be started with the new serial port and peripheral parameters to achieve normal communication of the serial port module.
[0077] If the peripheral device does not receive the leading signal, the parameter configuration module (parameter module) is used to continuously judge the signal received by the IO port (UIO).
[0078] If the host computer does not receive the response protocol data, continue to send the leading signal 0x00 in a loop.
[0079] In summary, the method and system for configuring peripheral parameters through the serial port provided by the embodiments of the present invention re-set the serial port parameters and obtain the peripheral parameters for a peripheral device whose serial port parameters are unknown. This method mainly adds an additional bypass detection circuit (implemented by using the IO ports of the peripheral device itself) and detection code to the peripheral device. The PC and the host computer need to give a predefined leading signal to the bypass detection module through the serial port, and use this signal to make the detection code reset the serial port communication parameters to the predefined parameter Ps; the PC and the host computer add specific setting programs without any modification to the circuits of the PC and the host computer. The peripheral device continuously detects the PC_Tx signal. When it receives N pulses with a pulse width of Tp (leading signal), it is considered that the PC and the host computer need to set the parameters of the peripheral device at this time. The peripheral device resets the serial port connected to the PC to the predefined serial port parameter Ps and communicates with the PC and the host computer.
[0080] A signal is paralleled to the Rx pin (PC_Tx) of the serial port of the peripheral and connected to its own IO (defined as signal UIO). This IO is configured as an input IO. UIO is used as a trigger signal for the PC and the host computer to set or obtain parameters of the peripheral. Usually, the pulse width of the UIO port is detected and it has no impact on the communication between the PC, the host computer and the peripheral.
[0081] The program of the peripheral should at least include two basic modules: the serial port communication (service) module and the parameter configuration module. Under normal conditions, the parameter configuration module will continuously detect the signal of UIO.
[0082] When the PC and the host computer need to set parameters, they use the agreed serial port parameters Ps. The baud rate adopts a relatively low baud rate, such as 110 or 300, etc., which are not commonly used in actual use. The data bits are 8 bits, one stop bit, and one start bit. When the PC and the host computer set the parameters of the peripheral, they set the serial port parameters of their own machines to Ps, and then continuously send 0x00 through the serial port in a loop.
[0083] The calculation formula for the Tp width is: 10 / baud rate. In order to distinguish normal communication, the detection program of the peripheral needs to continuously obtain enough pulses (the value of N) to determine that the PC and the host computer need to set parameters for the peripheral, so as to prevent the detection program from misjudging the start of the parameter setting function during normal communication. Therefore, the PC and the host computer need to continuously send 0x00 for more than 1 second. If the width of N - x pulses is not Tp, where x is a positive integer less than N, then the counting of the number of pulses of UIO starts again until N consecutive pulses with a width of Tp are received, which is considered as the leading information. When the peripheral receives the leading information and determines that the parameter setting function is started, it sets the serial port communication parameters to the agreed parameters Ps and returns protocol data to the PC and the host computer. At this time, the two parties start communication according to the agreed protocol.
[0084] The main principle of this method is that after the serial port baud rate of the PC is set to the default baud rate of the device, a fixed number of leading data bytes (for example: 10 55H or AAH) are continuously sent through the serial port. The device will continuously monitor the UIO port after power-on. According to the serial port protocol, UIO (GPIO port) can determine whether there is corresponding leading data on this port. If there is leading data, the serial port baud rate of the device is reset to the default baud rate, and corresponding data is sent to the PC through the default baud rate. At this time, communication is established between the PC and the device (peripheral device), which can provide a channel for subsequent parameter setting.
[0085] In summary, the method and system for configuring peripheral parameters through a serial port, by connecting an IO port of a peripheral device in parallel to the serial port Tx pin of the host computer to send information to the peripheral device, so that the parameter configuration module set in the peripheral device can monitor the information sent by the host computer to the peripheral device through the IO port, on the one hand, it does not occupy the serial port Tx pin of normal communication, saving resources, on the other hand, the port that monitors whether the parameters need to be configured can be distinguished from the normal communication, improving the accuracy of monitoring, reducing the error rate, and not affecting normal traffic. In addition, the peripheral device needs to continuously obtain enough (the value of N) pulses of the leading signal before determining that the host computer needs to set the parameters of the peripheral device, preventing the detection program from misjudging the startup parameter setting function under normal communication. Therefore, based on the parallel, other peripheral IO ports, a parameter configuration misjudgment prevention is performed, and on this basis, the parameter configuration judgment is further performed based on the number of continuous sign-in information pulses, which can improve the accuracy of determining whether the parameters need to be configured, reduce the false alarm rate, reduce the impact of false alarms on normal communication, and improve the communication efficiency and communication performance of the system. More importantly, it does not rely on the baud rate or any parameters set at the factory, nor does it perform cumbersome and unsafe factory settings of mechanical buttons. When parameters need to be configured, it listens and configures the address and baud rate of the port of the peripheral device according to the baud rate sent by the host computer, realizes the parameter configuration of the communication port between the two host computers and the peripheral device, and then realizes the normal communication between the two ports. It is simple to operate, highly accurate, and will not lose the data of the host computer or the peripheral device, and has high security. For this reason, the parameter setting method in the above method is highly secure, reliable, convenient, fast, practical, and efficient.
[0086] Therefore, according to the above method, the communication port can be configured safely, reliably, conveniently and efficiently, that is, the host computer can safely, reliably, conveniently and efficiently configure the parameters of the peripheral device to be communicated with it, so as to realize normal, smooth and stable communication between the peripheral device and the host computer.
[0087] In the embodiment of the present invention, the algorithm and display provided are not inherently related to any specific computer, virtual system or other equipment. Various general systems can also be used together with the teaching based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described here, and the description of the above specific language is to disclose the best mode of the present invention.
[0088] In the description provided herein, numerous specific details are set forth. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
[0089] Similarly, it should be understood that in order to streamline this disclosure and assist in understanding one or more of the various inventive aspects, in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, the disclosed method should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, the inventive aspects lie in less than all the features of the single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of the invention.
[0090] Those skilled in the art will appreciate that the modules in the devices in the embodiments can be adaptively changed and disposed in one or more devices different from the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all the features disclosed in this specification (including the accompanying claims, abstract and drawings) and all the processes or units of any method or device so disclosed. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstract and drawings) can be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0091] In addition, those skilled in the art will be able to understand that although some of the embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments means that it is within the scope of the invention and forms different embodiments. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
[0092] Each component embodiment of the present invention can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components in the device according to the embodiments of the present invention. The present invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program for implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, or provided on a carrier signal, or in any other form.
[0093] It should be noted that the above embodiments illustrate the present invention rather than limit the present invention, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in the claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In the unit claims listing several devices, several of these devices can be embodied by the same item of hardware. The use of the words first, second, and third, etc. does not denote any order. These words can be interpreted as names.
Claims
1. A method for configuring peripheral parameters through a serial port, characterized in that, Applied to a parameter configuration system, the parameter configuration system includes a peripheral device and a host computer. A bypass detection circuit is provided in the peripheral device; the peripheral device is connected to the host computer through a serial port module; The serial port module includes a first serial port and a second serial port. The first serial port includes a first serial port Rx pin and a first serial port Tx pin. The second serial port includes a second serial port Rx pin and a second serial port Tx pin. The first serial port module is provided in the host computer, and the second serial port module is provided in the peripheral device. The first serial port Rx pin is connected to the second serial port Tx pin; The first serial port Tx pin is connected to the second serial port Rx pin; The peripheral device sends information to the host computer through the second serial port Tx pin, and the host computer receives the information sent by the peripheral device through the first serial port Rx pin; The host computer sends information to the peripheral device through the first serial port Tx pin, and the peripheral device receives the information sent by the host computer through the second serial port Rx pin; The bypass detection circuit is connected to the host computer through the IO port of the peripheral device itself. The IO port is set as an input IO, and the IO port is connected to the first serial port Tx pin and is in parallel with the second serial port Rx pin; A parameter configuration module is configured in the bypass detection circuit. The parameter configuration module is used to monitor the information sent by the host computer to the peripheral device through the IO port; The method includes: The host computer sets the serial port parameters of the local side to default parameters; The host computer, through the first serial port Tx pin, based on the set baud rate, continuously sends a preamble signal to the bypass detection module through the IO port for multiple times; If the parameter configuration module in the bypass detection circuit receives the preamble signal continuously for N times, it is determined that the parameters of the peripheral interface need to be configured. The peripheral device stops the operation of the second serial port of the serial port module, parses the preamble signal through the IO port, sets the serial port parameters of the second serial port to default parameters, and sends response protocol data to the host computer through the second serial port Tx pin; Wherein, the N is a positive integer.
2. The method according to claim 1, wherein The method further includes: If the bypass detection module does not receive the preamble signal continuously for N times, the number of received preamble signals is counted again.
3. The method according to claim 1, wherein The default parameters include the set baud rate.
4. The method according to claim 1, characterized in that, The host computer includes a PC.
5. The method according to claim 1, wherein Setting the serial port parameters of the serial port module includes configuring the baud rate of the serial port module.
6. The method according to claim 1, wherein The set baud rate is 110 bps or 300 bps.
7. The method according to claim 1, characterized in that, The pulse width of the preamble signal is TP, and TP = 10 / baud rate.
8. The method according to claim 1, wherein The preamble signal includes 8 data bits, a stop bit, and a start bit.
9. The method according to claim 1, wherein The preamble signal is 0x00.
10. A parameter configuration system, characterized in that, The parameter configuration system includes a peripheral device and a host computer. A bypass detection circuit is provided in the peripheral device; the peripheral device is connected to the host computer through a serial port module; the serial port module includes a first serial port and a second serial port. The first serial port includes a first serial port Rx pin and a first serial port Tx pin. The second serial port includes a second serial port Rx pin and a second serial port Tx pin. The first serial port module is provided in the host computer, and the second serial port module is provided in the peripheral device. The first serial port Rx pin is connected to the second serial port Tx pin; The first serial port Tx pin is connected to the second serial port Rx pin; The peripheral device sends information to the host computer through the Tx pin of the second serial port, and the host computer receives the information sent by the peripheral device through the Rx pin of the first serial port; The host computer sends information to the peripheral device through the Tx pin of the first serial port, and the peripheral device receives the information sent by the host computer through the Rx pin of the second serial port; The bypass detection circuit is connected to the host computer through the IO port of the peripheral device itself. The IO port is set as an input IO, the IO port is connected to the Tx pin of the first serial port, and is connected in parallel with the Rx pin of the second serial port; a parameter configuration module is configured in the bypass detection circuit, and the parameter configuration module is used to monitor the information sent by the host computer to the peripheral device through the IO port; The parameter setting unit set in the host computer is used to set the serial port parameters of the host computer locally to default parameters; the communication unit set in the host computer is used to continuously send a preamble signal to the bypass detection module through the Tx pin of the first serial port based on the set baud rate through the IO port for multiple times; The parameter configuration module is further used for, If the parameter configuration module in the bypass detection circuit receives the preamble signal continuously for N times, it is determined that the parameters of the peripheral interface need to be configured. The peripheral device stops the operation of the Rx pin of the second serial port of the serial port module, parses the preamble signal through the IO port, the peripheral device sets the serial port parameters of the second serial port to default parameters, and sends a response protocol data to the host computer through the Tx pin of the second serial port; Wherein, the N is a positive integer.
Citation Information
Patent Citations
Method for controlling serial port communication and communication serial port
CN105049151A
Control system of robot
CN205405146U