Method and system for connecting and controlling multiple devices through one group of serial ports

By optimizing the serial port connection method, sharing control is connected to multiple controlled devices, solving the problems of high complexity of the main control device and increasing connection load, achieving more efficient equipment control and reducing the risk of equipment damage.

CN119135466AActive Publication Date: 2024-12-13SHANGDE (SHENZHEN) DATA TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411231705.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-12-13
Estimated Expiration
2044-09-04

AI Technical Summary

Technical Problem

When the main control device controls multiple devices through a serial port connection, it requires multiple serial port connections, resulting in high equipment complexity and increased connection load, which may lead to equipment damage.

Method used

The method of controlling multiple devices through a set of serial ports is used to determine whether to enable half-duplex or single-channel connection by using the initial serial port transmission information, optimize channel occupancy and data transmission, and share control to connect to multiple controlled devices to reduce the main Control the connection load of the device.

Benefits of technology

Effectively reduce the connection load of the main control equipment, reduce the risk of equipment damage, and improve the control efficiency of equipment and the number of controllable equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119135466A_ABST
    Figure CN119135466A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of serial port connection, and particularly discloses a method and a system for connecting and controlling a plurality of devices through a group of serial ports. A first controlled device sends a plurality of optimization data to a controlled device cluster connected with the first controlled device in series, and the controlled device cluster comprises a plurality of second controlled devices connected in sequence. Any second controlled device in the controlled device cluster serves as a target controlled device to be connected with the first controlled device in series and receive multiple pieces of optimization data, the second controlled device obtains a corresponding first starting instruction according to the optimization data and establishes controlled connection for each second controlled device according to the multiple first starting instructions, each second controlled device is controlled by the first transmission data transmitted by the previous second controlled device, and then the control of the main control device is allocated to each second controlled device, so that the transmission load of the main control device can be effectively reduced, and the damage of the main control device can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of serial port connection, and in particular to a method and system for controlling multiple devices through a group of serial port connections. Background Art

[0002] When the master control device is connected through communication transmission, a master control device must use a serial port to control multiple devices. The master control device needs to have multiple serial ports, and each controlled device needs a serial port connection of the master control device. The master control device will be connected to more cables, which will make the master control device more complicated. At the same time, the number of devices that the master control device can control will be limited by the number of serial ports on the master control device. When the master control device is connected to more cables, the connection load of the master control device will increase, which will cause damage to the master control device. Therefore, a method for controlling multiple devices through a set of serial port connections is needed to solve the above problems. Summary of the invention

[0003] The object of the present invention is to provide a method and system for controlling multiple devices through a group of serial port connections, so as to solve the technical problems raised in the above background technology.

[0004] To achieve the above object, the present invention provides the following technical solutions:

[0005] A method for controlling multiple devices via a set of serial port connections, comprising:

[0006] The control device obtains the starting serial port transmission information and sends the starting serial port transmission information to the first controlled device, wherein the control device and the first controlled device are connected in series via the serial port, and the starting serial port transmission information includes the serial port baud rate, the serial port data bit and the serial port stop bit;

[0007] The first controlled device determines whether to enable the half-duplex connection mode according to the initial serial port transmission information;

[0008] If the half-duplex connection mode is enabled, the first controlled device obtains a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device, and optimizes the plurality of channel occupancy data and the plurality of first transmission data to obtain a plurality of optimized data;

[0009] The first controlled device sends the plurality of optimization data to a controlled device cluster connected in series therewith, wherein the controlled device cluster includes a plurality of second controlled devices connected in sequence, and any second controlled device in the controlled device cluster is connected in series with the first controlled device as a first target controlled device and receives the plurality of optimization data;

[0010] The target controlled device transmits the multiple optimization data to each second controlled device in the controlled device cluster in a relay manner according to the connection order of the controlled device cluster, until the last second controlled device receives the optimization data and the connection transmission is completed, wherein, after each second controlled device receives the optimization data, each second controlled device obtains the corresponding first startup instruction according to the optimization data, and establishes a controlled connection for each second controlled device according to the multiple first startup instructions.

[0011] Preferably, after the step of determining whether to enable the half-duplex connection mode according to the initial serial port transmission information, the first controlled device further comprises:

[0012] If the half-duplex connection mode is not enabled, the first controlled device determines whether to enable the single-channel connection mode according to the initial serial port transmission information;

[0013] If the single-channel connection mode is enabled, the first controlled device obtains the target configuration address;

[0014] The first controlled device obtains address information of multiple third controlled devices in the second controlled device cluster connected in series with it, and traverses all third controlled devices according to the target configuration address, so that the target configuration address successfully matches the address information of any third controlled device in the second controlled device;

[0015] The third controlled device corresponding to any successful match establishes a communication connection with the first controlled device through the target configuration address;

[0016] The control device sends a control instruction to any third controlled device corresponding to a successful match through the first controlled device to establish a controlled connection.

[0017] Preferably, the step of the first controlled device determining whether to enable the half-duplex connection mode according to the initial serial port transmission information comprises:

[0018] The first controlled device obtains the corresponding data bit number according to the serial port data bit;

[0019] The first controlled device obtains a constant communication output of the serial port according to the serial port data bit and the serial port baud rate;

[0020] The first controlled device obtains the interval time of the serial port stop bit according to the serial port stop bit;

[0021] The first controlled device obtains the total communication transmission volume according to the constant communication output volume and the interval time of the serial port, and determines whether the total communication transmission volume is less than the preset communication transmission volume;

[0022] If the total communication transmission volume is less than the preset communication transmission volume, the first controlled device starts the half-duplex connection mode.

[0023] Preferably, the step of optimizing the plurality of channel occupancy data and the plurality of the first transmission data to obtain a plurality of optimized data comprises:

[0024] The first controlled device acquires a corresponding maximum load transmission rate and a transmission delay rate according to a plurality of first transmission data;

[0025] The first controlled device acquires a corresponding plurality of transmission bit numbers according to a plurality of the first transmission data;

[0026] The first controlled device acquires a corresponding plurality of occupied bit numbers according to a plurality of the first channel occupation data;

[0027] The first controlled device sequentially inputs the plurality of transmission bit numbers, the plurality of occupied bit numbers, the maximum load transmission rate and the transmission delay rate into the communication resource optimization model for training, and obtains a plurality of first optimized bit numbers, wherein the function formula of the communication resource optimization model is:

[0028]

[0029] Where b(i…n) represents the first optimized bit number from the i-th to the n-th, STD i Indicates the first transmission data of the i-th time, FZ MAXi represents the i-th maximum load transmission rate, s i represents the i-th transmission delay rate, ZY i Indicates the occupancy data of the first channel of the i-th channel, STD n Indicates the nth first transmission data, FZ MAXn represents the nth maximum load transmission rate, s n represents the nth transmission delay rate, ZY n represents the nth first channel occupation data, wherein i represents the number of first transmission data and first channel occupation data, i=1, 2, 3...n;

[0030] The first controlled device uses the i-th to n-th first optimized bit numbers as a plurality of optimization data.

[0031] Preferably, the step of the first controlled device acquiring a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device further comprises:

[0032] The first controlled device acquires a corresponding plurality of transmission times according to a plurality of first transmission data, and divides each transmission time into a plurality of time slots according to a preset fixed length;

[0033] The first controlled device sorts a plurality of time slots to obtain a time slot sorting table;

[0034] The first controlled device classifies the time slot sorting table according to the odd and even numbers in the sorting to obtain a plurality of odd time slots and a plurality of even time slots;

[0035] The first controlled device acquires a first transmission channel corresponding to the half-duplex connection mode, and divides the first transmission channel into a plurality of odd time slots and a plurality of even time slots to obtain a plurality of odd channels and a plurality of even channels;

[0036] The first controlled device acquires the total number of channels according to the plurality of odd-numbered channels and the plurality of even-numbered channels;

[0037] The first controlled device obtains total channel occupancy data according to the first transmission channel;

[0038] The first controlled device divides the total channel occupancy data according to the total number of channels to obtain a plurality of first channel occupancy data.

[0039] Preferably, the step of traversing all third controlled devices according to the target configuration address further includes:

[0040] The first controlled device obtains the number of data bits occupied by the second channel in the single-channel connection mode;

[0041] The first controlled device obtains the number of bits of the configuration address number information;

[0042] The first controlled device obtains a preset transmission time of configuration address number information in a single-channel connection mode;

[0043] The first controlled device calculates the rated transmission rate according to the second channel occupancy data, the number of bits of the configuration address number and the preset transmission time, wherein the calculation formula is:

[0044]

[0045] P represents the rated transmission rate, D(e) represents the number of data bits occupied by the second channel, z(y) represents the number of bits of the configuration address number; T represents the preset transmission time;

[0046] The first controlled device transmits the configuration address number information to all third controlled devices according to the rated transmission rate based on the preset transmission protocol.

[0047] The present application also provides a system for controlling multiple devices through a set of serial port connections, including:

[0048] A first acquisition module, configured to control a device to acquire initial serial port transmission information, and send the initial serial port transmission information to a first controlled device, wherein the control device and the first controlled device are connected in series via a serial port, and the initial serial port transmission information includes a serial port baud rate, a serial port data bit, and a serial port stop bit;

[0049] A first judgment module, used for the first controlled device to judge whether to open the half-duplex connection mode according to the initial serial port transmission information;

[0050] If the half-duplex connection mode is enabled, the first controlled device obtains a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device, and optimizes the plurality of channel occupancy data and the plurality of first transmission data to obtain a plurality of optimized data;

[0051] A first sending module, configured for a first controlled device to send a plurality of the optimization data to a controlled device cluster connected in series therewith, wherein the controlled device cluster includes a plurality of second controlled devices connected in sequence, and any second controlled device in the controlled device cluster is connected in series with the first controlled device as a first target controlled device and receives the plurality of the optimization data;

[0052] The first transmission module is used for the target controlled device to transmit the multiple optimization data to each second controlled device in the controlled device cluster in a relay manner according to the connection order of the controlled device cluster, until the last second controlled device receives the optimization data and the connection transmission is completed, wherein, after each second controlled device receives the optimization data, each second controlled device obtains the corresponding first startup instruction according to the optimization data, and establishes a controlled connection for each second controlled device according to the multiple first startup instructions.

[0053] Preferably, the first judgment module further includes:

[0054] A first judgment unit, configured to, if the half-duplex connection mode is not enabled, determine whether the first controlled device should enable the single-channel connection mode according to the initial serial port transmission information;

[0055] A first acquisition unit, configured to enable the first controlled device to acquire a target configuration address if the single-channel connection mode is enabled;

[0056] A second acquisition unit is used for the first controlled device to acquire address information of multiple third controlled devices in the second controlled device cluster connected in series with the first controlled device, and traverse all the third controlled devices according to the target configuration address, so that the target configuration address is successfully matched with the address information of any third controlled device in the second controlled device;

[0057] A second communication connection unit, configured for any third controlled device corresponding to a successful match to establish a communication connection with the first controlled device through a target configuration address;

[0058] The first controlled connection unit is used to control the device to send a control instruction to any third controlled device corresponding to a successful match through the first controlled device, so as to establish a controlled connection.

[0059] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned pre-job detection method when executing the computer program.

[0060] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned pre-job detection method are implemented.

[0061] The beneficial effects of the present application are as follows: when the connection mode is a half-duplex connection mode, the first controlled device sends multiple optimization data to a controlled device cluster connected in series with it, wherein the controlled device cluster includes multiple second controlled devices connected in sequence, and any second controlled device in the controlled device cluster is connected in series with the first controlled device as a target controlled device and receives multiple optimization data, so that the control device can transmit multiple first transmission data to any second controlled device in the controlled device cluster through the first controlled device, wherein each second controlled device obtains the corresponding first startup instruction according to the optimization data, and establishes a controlled connection for each second controlled device according to the multiple first startup instructions, and each second controlled device is controlled by the first transmission data transmitted by the previous second controlled device, and then the control of the master control device is evenly distributed to each second controlled device, thereby effectively reducing the connection load of the master control device and reducing damage to the master control device. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 The figure is a schematic diagram of a method flow of an embodiment of the present application.

[0063] Figure 2 A schematic diagram of the system structure of an embodiment of the present application.

[0064] Figure 3 A schematic diagram of the internal structure of a computer device according to an embodiment of the present application.

[0065] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0066] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0067] like Figure 1-3 As shown, the present application provides a method for controlling multiple devices through a set of serial port connections, including:

[0068] S1. A control device obtains initial serial port transmission information and sends the initial serial port transmission information to a first controlled device, wherein the control device and the first controlled device are connected in series via a serial port, and the initial serial port transmission information includes a serial port baud rate, a serial port data bit, and a serial port stop bit;

[0069] S2, the first controlled device determines whether to enable the half-duplex connection mode according to the initial serial port transmission information;

[0070] If the half-duplex connection mode is enabled, the first controlled device obtains a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device, and optimizes the plurality of channel occupancy data and the plurality of first transmission data to obtain a plurality of optimized data;

[0071] S3, the first controlled device sends the plurality of optimization data to a controlled device cluster connected in series therewith, wherein the controlled device cluster includes a plurality of second controlled devices connected in sequence, and any second controlled device in the controlled device cluster is connected in series with the first controlled device as a first target controlled device and receives the plurality of optimization data;

[0072] S4. The target controlled device transmits the multiple optimization data to each second controlled device in the controlled device cluster in a relay manner according to the connection order of the controlled device cluster, until the last second controlled device receives the optimization data and the connection transmission is completed, wherein, after each second controlled device receives the optimization data, each second controlled device obtains the corresponding first startup instruction according to the optimization data, and establishes a controlled connection for each second controlled device according to the multiple first startup instructions.

[0073] As described in the above steps S1-S4, when the master control device is connected through communication transmission, a master control device needs to use a serial port to control multiple devices, wherein the master control device needs to have multiple serial ports, and each controlled device needs a serial port connection of the master control device. The master control device end will be connected to more cables, which will make the master control device more complex. At the same time, the number of devices that the master control device can control will be limited by the number of serial ports on the master control end. When the master control device end is connected to more cables, the connection load of the master control device will increase, which will cause damage to the master control device. Based on this, it is necessary to transmit information at the starting serial port. The serial port baud rate, serial port data bit and serial port stop bit are extracted, and the connection mode between the first controlled device and the controlled device cluster is determined by the serial port baud rate, serial port data bit and serial port stop bit. In this way, the optimal controlled connection can be provided for the main control device through the selection of the connection mode, so that the main control device can run efficiently. When the half-duplex connection mode is turned on, the first controlled device obtains multiple channel occupancy data and multiple first transmission data connected to the serial port of the control device, and optimizes the multiple channel occupancy data and the multiple first transmission data to obtain multiple optimized data. In this way, the channel occupancy data is optimized in advance. The row elimination can provide a real data transmission volume for the transmission of multiple optimized data. At the same time, after the multiple optimized data are sent to the controlled device cluster connected in series, wherein the controlled device cluster includes multiple second controlled devices connected in sequence, any second controlled device in the controlled device cluster is connected in series with the first controlled device as the first target controlled device and receives multiple optimized data, and then the target controlled device transmits the multiple optimized data to each second controlled device in the controlled device cluster in a relay manner according to the connection sequence of the controlled device cluster, until the last second controlled device receives the optimized data and the connection transmission ends, wherein each second controlled device receives the optimized data, and each second controlled device obtains the corresponding first startup instruction according to the optimized data, and establishes a controlled connection for each second controlled device according to the multiple first startup instructions, so that each second controlled device is controlled by the first transmission data transmitted by the previous second controlled device under the relay transmission control, and then the connection control of the master control device is evenly distributed to each second controlled device, thereby effectively reducing the connection load of the master control device and reducing the damage to the master control device.

[0074] In one embodiment, after step S2 of the first controlled device determining whether to enable the half-duplex connection mode according to the initial serial port transmission information, the method further includes:

[0075] S21, if the half-duplex connection mode is not enabled, the first controlled device determines whether to enable the single-channel connection mode according to the initial serial port transmission information;

[0076] S22: If the single-channel connection mode is enabled, the first controlled device obtains the target configuration address;

[0077] S23, the first controlled device obtains address information of multiple third controlled devices in the second controlled device cluster connected in series with it, and traverses all third controlled devices according to the target configuration address, so that the target configuration address successfully matches the address information of any third controlled device in the second controlled device;

[0078] S24, any third controlled device corresponding to a successful match establishes a communication connection with the first controlled device through the target configuration address;

[0079] S25. The control device sends a control instruction to any third controlled device corresponding to a successful match through the first controlled device to establish a controlled connection.

[0080] As described in the above steps S21-S25, when the connection mode is a single-channel connection mode, the first controlled device obtains the target configuration address, the first controlled device obtains the address information of multiple third controlled devices in the second controlled device cluster connected in series with it, and traverses all third controlled devices according to the target configuration address, so that the target configuration address is successfully matched with the address information of any third controlled device in the second controlled device, and any third controlled device corresponding to the successful match is established with the first controlled device through the target configuration address. The control device then sends a control instruction to any third controlled device corresponding to the successful match through the first controlled device to establish a controlled connection, so that the first target controlled device can be directionally controlled in the single-channel connection mode, and in the single-channel connection mode, the first controlled device and the multiple third controlled devices are all used as media for transmission, and only one third controlled device is controlled at a time, which will reduce the connection load of the master control device, and can also control multiple devices in a direction, and can also avoid damage to the master control device due to increased connection load.

[0081] In one embodiment, step S2 of the first controlled device determining whether to enable the half-duplex connection mode according to the initial serial port transmission information includes:

[0082] S201, the first controlled device obtains the corresponding data bit number according to the serial port data bit;

[0083] The first controlled device obtains a constant communication output of the serial port according to the serial port data bit and the serial port baud rate;

[0084] S202, the first controlled device obtains the interval time of the serial port stop bit according to the serial port stop bit;

[0085] S203, the first controlled device obtains a total communication transmission amount according to the constant communication output amount and the interval time of the serial port, and determines whether the total communication transmission amount is less than a preset communication transmission amount;

[0086] If the total communication transmission volume is less than the preset communication transmission volume, the first controlled device starts the half-duplex connection mode.

[0087] As described in the above steps S201-S203, when distinguishing between the half-duplex connection mode and the single-channel connection mode, first obtain the corresponding data bit number according to the serial port data bit, wherein the single-channel data bit number is usually less than 8 digits, and the number of digits above 8 as long as it is an even multiple is usually the number of digits of the half-duplex connection mode. When the data is transmitted, it can be efficiently transmitted in different modes by classification, and then the rated first transmission data can obtain the serial port constant communication output under the conditions of the serial port data bit and the serial port baud rate. In this way, the transmitted data can be preliminarily divided according to the serial port constant communication output, and then the serial port stop bit interval is obtained according to the serial port stop bit, and then according to The total communication transmission volume is obtained by the constant communication output of the serial port and the interval time, wherein the total communication transmission volume is calculated by multiplying the constant communication output of the serial port and the interval time. Since the transmission volume of the single-channel connection mode is faster than the half-duplex connection mode, if the total communication transmission volume transmitted within the preset time is greater than the preset communication transmission volume, it is a single-channel connection mode. On this basis, it is determined whether the total communication transmission volume is less than the preset communication transmission volume. If the total communication transmission volume is less than the preset communication transmission volume, the first controlled device starts the half-duplex connection mode, otherwise, the single-channel connection mode is started. Determining the connection mode is conducive to classifying the instruction data during the connection and can reduce the abnormal resource allocation of the serial port during transmission.

[0088] In one embodiment, the step S2 of the first controlled device acquiring a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device further includes:

[0089] S204, the first controlled device acquires a corresponding plurality of transmission times according to the plurality of first transmission data, and divides each transmission time into a plurality of time slots according to a preset fixed length;

[0090] S205, the first controlled device sorts a number of time slots to obtain a time slot sorting table;

[0091] S206, the first controlled device classifies the time slot sorting table according to the odd and even numbers in the sorting to obtain a plurality of odd time slots and a plurality of even time slots;

[0092] S207: The first controlled device obtains a first transmission channel corresponding to the half-duplex connection mode, and divides the first transmission channel into a plurality of odd time slots and a plurality of even time slots to obtain a plurality of odd channels and a plurality of even channels;

[0093] S208, the first controlled device obtains a total number of channels according to the plurality of odd-numbered channels and the plurality of even-numbered channels;

[0094] S209, the first controlled device obtains total channel occupancy data according to the first transmission channel;

[0095] S2010: The first controlled device divides the total channel occupancy data according to the total number of channels to obtain a plurality of first channel occupancy data.

[0096] As described in the above steps S204-S2010, the first controlled device of the present invention obtains corresponding multiple transmission times according to multiple first transmission data, and divides each transmission time into multiple time slots according to a preset fixed length, and then the first controlled device sorts the multiple time slots to obtain a time slot sorting table, wherein the time slot is mainly used in the time division multiplexing mode, and then the first controlled device classifies the time slot sorting table according to the odd and even in the sorting to obtain multiple odd time slots and multiple even time slots, so that the channels under the half-duplex connection mode are split in advance, and the data are preliminarily classified, and after the preliminary classification, the confusion caused by multiple data connections can be reduced, and the split data can be sorted according to the odd and even. The even channels are transmitted alternately, and then the first controlled device obtains the total number of channels according to the multiple odd channels and the multiple even channels, wherein each channel is rated to occupy fixed data, wherein the fixed data includes the transmission protocol of the channel and the data occupied by the channel medium, etc. On this basis, the total channel occupancy data can be obtained according to the first transmission channel by the first controlled device, and the first controlled device divides the total channel occupancy data according to the total number of channels to obtain multiple first channel occupancy data, and after the multiple first channel occupancy data are obtained, eliminating them can make the basis for calculating the amount of data for connection transmission correct, so as to facilitate more accurate calculation of the data for connection transmission between the control device and the controlled device.

[0097] In one embodiment, the step S2 of optimizing the plurality of channel occupancy data and the plurality of the first transmission data to obtain a plurality of optimized data includes:

[0098] S4011. The first controlled device obtains a corresponding maximum load transmission rate and a transmission delay rate according to a plurality of first transmission data;

[0099] S4012: The first controlled device obtains a corresponding plurality of transmission bit numbers according to a plurality of the first transmission data;

[0100] S4013: The first controlled device obtains a corresponding plurality of occupied bit numbers according to a plurality of first channel occupation data;

[0101] S4014, the first controlled device sequentially inputs the plurality of transmission bit numbers, the plurality of occupied bit numbers, the maximum load transmission rate and the transmission delay rate into the communication resource optimization model for training, and obtains a plurality of first optimized bit numbers, wherein the function formula of the communication resource optimization model is:

[0102]

[0103] Where b(i…n) represents the first optimized bit number from the i-th to the n-th, STD i Indicates the first transmission data of the i-th time, FZ MAXi represents the i-th maximum load transmission rate, s i represents the i-th transmission delay rate, ZY i Indicates the occupancy data of the first channel of the i-th channel, STD n Indicates the nth first transmission data, FZ MAXn represents the nth maximum load transmission rate, s n represents the nth transmission delay rate, ZY n represents the nth first channel occupation data, wherein i represents the number of first transmission data and first channel occupation data, i=1, 2, 3...n;

[0104] S4015. The first controlled device uses the first optimized bit numbers from the i-th to the n-th as a plurality of optimized data.

[0105] As described in the above steps S4011-S4015, the first controlled device of the present invention obtains the corresponding maximum load transmission rate and transmission delay rate according to multiple first transmission data, and then inputs the multiple first transmission data, multiple first channel occupancy data, maximum load transmission rate and transmission delay rate into the communication resource optimization model for training in sequence to obtain multiple first optimization data. In this way, after the data is optimized, the multiple first optimization data can remain stable during the transmission connection, and the stable transmission connection can avoid confusion in the connection transmission between the control device and the controlled device.

[0106] In one embodiment, the step S23 of traversing all third controlled devices according to the target configuration address further includes:

[0107] S231, the first controlled device obtains the number of occupied data bits of the second channel in the single-channel connection mode;

[0108] S232, the first controlled device obtains the number of bits of the configuration address number information;

[0109] S233, the first controlled device obtains a preset transmission time of the configuration address number information in a single-channel connection mode;

[0110] S234. The first controlled device calculates the rated transmission rate according to the second channel occupancy data, the number of bits of the configuration address number and the preset transmission time, wherein the calculation formula is:

[0111]

[0112] P represents the rated transmission rate, D(e) represents the number of data bits occupied by the second channel, z(y) represents the number of bits of the configuration address number; T represents the preset transmission time;

[0113] S235: The first controlled device transmits the configuration address number information to all third controlled devices according to the rated transmission rate based on the preset transmission protocol.

[0114] As described in the above steps S231-S235, the first controlled device of the present application obtains the number of occupied data bits of the second channel in the single-channel connection mode, and then the first controlled device obtains the number of configuration address number bits of the configuration address number information, and then the first controlled device obtains the preset transmission time of the configuration address number information in the single-channel connection mode, and then the first controlled device calculates the rated transmission rate according to the second channel occupancy data, the number of configuration address number bits and the preset transmission time. In this way, after obtaining the rated transmission rate, it is beneficial for the first controlled device to traverse the configuration address number information according to the rated transmission rate based on the preset transmission protocol to all third controlled devices, thereby avoiding resource allocation abnormalities when the serial port provides connection transmission between the control device and the controlled device.

[0115] The present application also provides a system for controlling multiple devices through a set of serial port connections, including:

[0116] A first acquisition module 1 is used to control a device to acquire initial serial port transmission information and send the initial serial port transmission information to a first controlled device, wherein the control device and the first controlled device are connected in series via a serial port, and the initial serial port transmission information includes a serial port baud rate, a serial port data bit, and a serial port stop bit;

[0117] A first judgment module 2 is used for the first controlled device to judge whether to open the half-duplex connection mode according to the initial serial port transmission information;

[0118] If the half-duplex connection mode is enabled, the first controlled device obtains a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device, and optimizes the plurality of channel occupancy data and the plurality of first transmission data to obtain a plurality of optimized data;

[0119] A first sending module 3 is used for the first controlled device to send the plurality of optimization data to a controlled device cluster connected in series with the first controlled device, wherein the controlled device cluster includes a plurality of second controlled devices connected in sequence, and any second controlled device in the controlled device cluster is connected in series with the first controlled device as a first target controlled device and receives the plurality of optimization data;

[0120] The first transmission module 4 is used for the target controlled device to transmit multiple optimization data to each second controlled device in the controlled device cluster in a relay manner according to the connection order of the controlled device cluster, until the last second controlled device receives the optimization data and the connection transmission is completed, wherein, after each second controlled device receives the optimization data, each second controlled device obtains the corresponding first startup instruction according to the optimization data, and establishes a controlled connection for each second controlled device according to the multiple first startup instructions.

[0121] In one embodiment, the first determination module further includes:

[0122] A first judgment unit, configured to, if the half-duplex connection mode is not enabled, determine whether the first controlled device should enable the single-channel connection mode according to the initial serial port transmission information;

[0123] A first acquisition unit, configured to enable the first controlled device to acquire a target configuration address if the single-channel connection mode is enabled;

[0124] A second acquisition unit is used for the first controlled device to acquire address information of multiple third controlled devices in the second controlled device cluster connected in series with the first controlled device, and traverse all the third controlled devices according to the target configuration address, so that the target configuration address is successfully matched with the address information of any third controlled device in the second controlled device;

[0125] A second communication connection unit, configured for any third controlled device corresponding to a successful match to establish a communication connection with the first controlled device through a target configuration address;

[0126] The first controlled connection unit is used to control the device to send a control instruction to any third controlled device corresponding to a successful match through the first controlled device, so as to establish a controlled connection.

[0127] like Figure 3 As shown, the present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned pre-job detection method when executing the computer program.

[0128] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned pre-job detection method are implemented.

[0129] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0130] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.

[0131] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for controlling multiple devices through a set of serial port connections, characterized in that: include: The control device obtains the starting serial port transmission information and sends the starting serial port transmission information to the first controlled device, wherein the control device and the first controlled device are connected in series via the serial port, and the starting serial port transmission information includes the serial port baud rate, the serial port data bit and the serial port stop bit; The first controlled device determines whether to enable the half-duplex connection mode according to the initial serial port transmission information; If the half-duplex connection mode is enabled, the first controlled device obtains a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device, and optimizes the plurality of channel occupancy data and the plurality of first transmission data to obtain a plurality of optimized data; The first controlled device sends the plurality of optimization data to a controlled device cluster connected in series therewith, wherein the controlled device cluster includes a plurality of second controlled devices connected in sequence, and any second controlled device in the controlled device cluster is connected in series with the first controlled device as a first target controlled device and receives the plurality of optimization data; The target controlled device transmits the multiple optimization data to each second controlled device in the controlled device cluster in a relay manner according to the connection order of the controlled device cluster, until the last second controlled device receives the optimization data and the connection transmission is completed, wherein, after each second controlled device receives the optimization data, each second controlled device obtains the corresponding first startup instruction according to the optimization data, and establishes a controlled connection for each second controlled device according to the multiple first startup instructions.

2. The method for controlling multiple devices through a set of serial port connections according to claim 1, characterized in that: After the step of determining whether to enable the half-duplex connection mode according to the initial serial port transmission information, the first controlled device further includes: If the half-duplex connection mode is not enabled, the first controlled device determines whether to enable the single-channel connection mode according to the initial serial port transmission information; If the single-channel connection mode is enabled, the first controlled device obtains the target configuration address; The first controlled device obtains address information of multiple third controlled devices in the second controlled device cluster connected in series with it, and traverses all third controlled devices according to the target configuration address, so that the target configuration address successfully matches the address information of any third controlled device in the second controlled device; The third controlled device corresponding to any successful match establishes a communication connection with the first controlled device through the target configuration address; The control device sends a control instruction to any third controlled device corresponding to a successful match through the first controlled device to establish a controlled connection.

3. The method for controlling multiple devices through a set of serial port connections according to claim 1, characterized in that: The step of the first controlled device determining whether to enable the half-duplex connection mode according to the initial serial port transmission information comprises: The first controlled device obtains the corresponding data bit number according to the serial port data bit; The first controlled device obtains a constant communication output of the serial port according to the serial port data bit and the serial port baud rate; The first controlled device obtains the interval time of the serial port stop bit according to the serial port stop bit; The first controlled device obtains the total communication transmission volume according to the constant communication output volume and the interval time of the serial port, and determines whether the total communication transmission volume is less than the preset communication transmission volume; If the total communication transmission volume is less than the preset communication transmission volume, the first controlled device starts the half-duplex connection mode.

4. The method for controlling multiple devices through a set of serial port connections according to claim 1, characterized in that: The step of optimizing the plurality of channel occupancy data and the plurality of the first transmission data to obtain a plurality of optimized data comprises: The first controlled device acquires a corresponding maximum load transmission rate and a transmission delay rate according to a plurality of first transmission data; The first controlled device acquires a corresponding plurality of transmission bit numbers according to a plurality of the first transmission data; The first controlled device acquires a corresponding plurality of occupied bit numbers according to a plurality of the first channel occupation data; The first controlled device sequentially inputs the plurality of transmission bit numbers, the plurality of occupied bit numbers, the maximum load transmission rate, and the transmission delay rate into the communication resource optimization model for training, and obtains a plurality of first optimized bit numbers, wherein the function formula of the communication resource optimization model is: Where b(i…n) represents the first optimized bit number from the i-th to the n-th, STD i Indicates the first transmission data of the i-th time, FZ MAXi represents the i-th maximum load transmission rate, s i represents the i-th transmission delay rate, ZY i Indicates the occupancy data of the first channel of the i-th channel, STD n Indicates the nth first transmission data, FZ MAXn represents the nth maximum load transmission rate, s n represents the nth transmission delay rate, ZY n represents the nth first channel occupation data, wherein i represents the number of first transmission data and first channel occupation data, i=1, 2, 3...n; The first controlled device uses the i-th to n-th first optimized bit numbers as a plurality of optimization data.

5. The method for controlling multiple devices through a set of serial port connections according to claim 1, characterized in that: The step of the first controlled device acquiring a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device also includes: The first controlled device acquires a corresponding plurality of transmission times according to a plurality of first transmission data, and divides each transmission time into a plurality of time slots according to a preset fixed length; The first controlled device sorts a plurality of time slots to obtain a time slot sorting table; The first controlled device classifies the time slot sorting table according to the odd and even numbers in the sorting to obtain a plurality of odd time slots and a plurality of even time slots; The first controlled device acquires a first transmission channel corresponding to the half-duplex connection mode, and divides the first transmission channel into a plurality of odd time slots and a plurality of even time slots to obtain a plurality of odd channels and a plurality of even channels; The first controlled device acquires the total number of channels according to the plurality of odd-numbered channels and the plurality of even-numbered channels; The first controlled device obtains total channel occupancy data according to the first transmission channel; The first controlled device divides the total channel occupancy data according to the total number of channels to obtain a plurality of first channel occupancy data.

6. The method for controlling multiple devices through a set of serial port connections according to claim 2, characterized in that: The step of traversing all third controlled devices according to the target configuration address also includes: The first controlled device obtains the number of data bits occupied by the second channel in the single-channel connection mode; The first controlled device obtains the number of bits of the configuration address number information; The first controlled device obtains a preset transmission time of configuration address number information in a single-channel connection mode; The first controlled device calculates the rated transmission rate according to the second channel occupancy data, the number of bits of the configuration address number and the preset transmission time, wherein the calculation formula is: P represents the rated transmission rate, D(e) represents the number of data bits occupied by the second channel, z(y) represents the number of bits of the configuration address number; T represents the preset transmission time; The first controlled device transmits the configuration address number information to all third controlled devices according to the rated transmission rate based on the preset transmission protocol.

7. A system for controlling multiple devices through a set of serial ports, characterized in that: include: A first acquisition module, configured to control a device to acquire initial serial port transmission information, and send the initial serial port transmission information to a first controlled device, wherein the control device and the first controlled device are connected in series via a serial port, and the initial serial port transmission information includes a serial port baud rate, a serial port data bit, and a serial port stop bit; A first judgment module, used for the first controlled device to judge whether to open the half-duplex connection mode according to the initial serial port transmission information; If the half-duplex connection mode is enabled, the first controlled device obtains a plurality of channel occupancy data and a plurality of first transmission data connected to the serial port of the control device, and optimizes the plurality of channel occupancy data and the plurality of first transmission data to obtain a plurality of optimized data; A first sending module, configured for a first controlled device to send a plurality of the optimization data to a controlled device cluster connected in series therewith, wherein the controlled device cluster includes a plurality of second controlled devices connected in sequence, and any second controlled device in the controlled device cluster is connected in series with the first controlled device as a first target controlled device and receives the plurality of the optimization data; The first transmission module is used for the target controlled device to transmit the multiple optimization data to each second controlled device in the controlled device cluster in a relay manner according to the connection order of the controlled device cluster, until the last second controlled device receives the optimization data and the connection transmission is completed, wherein, after each second controlled device receives the optimization data, each second controlled device obtains the corresponding first startup instruction according to the optimization data, and establishes a controlled connection for each second controlled device according to the multiple first startup instructions.

8. A system for controlling multiple devices through a set of serial ports according to claim 7, characterized in that: The first judgment module further includes: A first judgment unit, configured to, if the half-duplex connection mode is not enabled, determine whether the first controlled device should enable the single-channel connection mode according to the initial serial port transmission information; A first acquisition unit, configured to enable the first controlled device to acquire a target configuration address if the single-channel connection mode is enabled; A second acquisition unit is used for the first controlled device to acquire address information of multiple third controlled devices in the second controlled device cluster connected in series with the first controlled device, and traverse all the third controlled devices according to the target configuration address, so that the target configuration address is successfully matched with the address information of any third controlled device in the second controlled device; A second communication connection unit, configured for any third controlled device corresponding to a successful match to establish a communication connection with the first controlled device through a target configuration address; The first controlled connection unit is used to control the device to send a control instruction to any third controlled device corresponding to a successful match through the first controlled device, so as to establish a controlled connection.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Serial port communication system and method

    CN105243039A

  • Serial port communication system, method and device and electronic equipment

    CN111159092A

  • Serial port one-to-many communication method and system and electrical equipment

    CN117331877A

  • Serial port communication method, computer equipment and computer readable storage medium

    CN118093491A

  • Cluster control method, cluster control system, and terminal device

    US20190351545A1