Gateway machine wired sensor message simulation test method and simulation test device

By configuring sensor information points and communication parameters in the gateway database, using the USB to serial tool or serial server to connect to the host computer, multi-serial port adaptation and visual operation are achieved, the gateway performance testing difficulties caused by sensor shortage is solved, batch data refresh and protocol expansion are supported, and gateway performance is verified.

CN120358169AActive Publication Date: 2025-07-22NANJING ZHENGTU INFORMATION TECH CO LTD

Patent Information

Application Number
CN202510863983.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-26
Publication Date
2025-07-22
Estimated Expiration
2045-06-26

AI Technical Summary

Technical Problem

During the development and testing of gateway machines, there is a shortage or insufficient number of sensor devices, resulting in the inability to effectively test the performance bottleneck of gateway machines in high concurrency and large data volume scenarios. Existing tools cannot visually display sensor information, and cannot simulate multiple serial port communications at the same time, which is complicated to operate.

Method used

By configuring sensor information points and communication parameters in the gateway database, using USB to serial tool or serial server to connect to the host computer, building a serial port mapping relationship, realizing multi-serial port adaptation and visual operations, simulating sensor messages, and supporting batch data refresh and protocol expansion.

Benefits of technology

It solves the problem of sensor shortage, supports multi-serial port connection, reduces operational difficulty, ensures data processing accuracy, verifys gateway performance, and adapts to future protocol expansion requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120358169A_ABST
    Figure CN120358169A_ABST
Patent Text Reader

Abstract

The invention discloses a gateway machine wired sensor message simulation test method and a simulation test device, which are suitable for a serial port communication test scene based on a Modbus RTU protocol. According to the method, external serial port communication parameters and sensor information points are configured in a gateway machine database, test signal connection between an upper computer and the gateway machine is established through a USB-to-serial tool or a serial port server, and register values are stored in a data simulation module through a Map table after the upper computer is loaded and configured; visual modification of information point values is supported, and register values are reversely calculated and updated. And meanwhile, a serial port mapping relation is constructed, a test thread and a message receiving buffer queue are created, and reading, analysis and processing of the Modbus message are realized. The method solves the problem of gateway machine pressure testing when sensors are in shortage, supports multi-serial-port flexible connection and batch visual operation, is accurate in data processing, and has protocol expansion capability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and a device for simulating and testing wired sensor messages of a gateway machine, which are applicable to the serial communication test scenario based on the Modbus RTU protocol and belong to the technology of intelligent substation rooms. Background Art

[0002] The serial port is an extremely common communication interface of gateway devices. It is one of the oldest and most mature standard interfaces for computers to communicate with external devices. Due to characteristics such as simple protocol, low implementation cost, stable communication, strong anti-interference ability, and low power consumption, common industrial devices, instruments, embedded systems, network devices, sensors, etc. on the market currently have built-in serial ports as standard communication or configuration interfaces. It can be said that the serial port is the most direct and best-compatible communication interface.

[0003] Currently, many mature and widely used industrial fieldbus protocols (such as Modbus RTU / ASCII, Profibus DP, CAN bus, etc.) are implemented based on serial communication. Among them, the Modbus RTU (Remote Terminal Unit) protocol is one of the most popular and widely adopted industrial communication protocols based on serial communication (mainly RS-485 / RS-232). It is almost everywhere in the fields of industrial automation, building control, energy monitoring, etc.

[0004] In the development and testing stage, the sensor devices to be tested for access by the gateway machine may not be in stock or the number of tests may not meet the requirements. Especially in the pressure test stage of the gateway machine, a large number of sensor devices need to be connected for data access testing to verify its stability, processing ability, communication load limit, and resource management ability. Such testing can expose the bottlenecks of the gateway in high-concurrency and large-data-volume scenarios (such as CPU, memory, threads, queue overflow, communication delay, protocol parsing errors, etc.).

[0005] Currently, although some Modbus Slave tools support the Modbus RTU protocol and can directly modify the values of registers, they cannot intuitively see the sensor information corresponding to the values and the actual values, and rely on relatively professional debugging experience to operate. Moreover, they cannot simulate multiple serial communications simultaneously. Multiple tool interfaces need to be opened, and large-volume data refreshing operations cannot be achieved. Summary of the Invention

[0006] Object of the Invention: In order to overcome the deficiencies existing in the prior art, the present invention provides a method and a device for simulating and testing wired sensor messages of a gateway machine. Through model design, multi-serial port adaptation, and visual operation, efficient simulation testing of a large number of sensor messages is realized.

[0007] Technical solution: To achieve the above object, the technical solution adopted by the present invention is as follows: A method for simulating and testing wired sensor messages of a gateway machine includes the following steps: Step1. In the gateway machine database, configure communication parameters for each external serial port to be accessed, select an external serial port for each sensor to be accessed, and configure the sensor and the corresponding sensor information point; Step2. Establish a test signal connection between the upper computer and the gateway machine through a USB-to-serial tool or a serial server; Step3. The upper computer obtains and loads the communication parameters of each external serial port stored in the gateway machine database and the configuration information of each sensor and the corresponding sensor information point through network communication; Step4. In the data simulation module of the upper computer, open the Modbus register buffer according to the serial port name, read / write function code, sensor communication address, and register address, and use the Map table to store the register values of each sensor information point; Step5. In the data simulation module of the upper computer, modify the information point value of the sensor information point, and display the relevant information of the latest sensor information point through a visual interface; according to the modified information point value of the sensor information point, reverse-calculate the register value and synchronously update the Map table; Step6. Construct a serial port mapping relationship between each external serial port and the transfer serial port on the corresponding USB-to-serial tool, open the transfer serial port using the baud rate and parity bit in the external serial port communication parameters, and start a test thread; or construct a serial port mapping relationship between each external serial port and the corresponding TCP service port on the serial server, and start a test thread by creating a TcpSocket connection to the corresponding TCP service port; add a message reception buffer queue for each test thread to store the received messages; Step7. Regularly obtain a read signal within the test thread. If a read signal is obtained, read all messages and append all the read messages to the message reception buffer queue; when there is a newly appended message in the message reception buffer queue, start the message processing process, take out a single-frame message from the newly appended message and parse it; Step8. For a single-frame message with a read function code, obtain the corresponding register value from the Map table according to the sensor communication address, read function code, register address, and data length parsed from the single-frame message, combined with the serial port name; for a single-frame message with a write function code, determine the sensor information point and match the correct register value according to the sensor communication address, write function code, message data, register start address, register length, and a set of register values parsed from the single-frame message, combined with the serial port name, and update the visual interface display and the Map table.

[0008] Specifically, in the Step 3, the information obtained and loaded by the host computer through network communication includes: communication parameters of the external serial port, including serial port name, baud rate, parity bit, data bit, and stop bit; configuration information of the sensor, including sensor name, model name, serial port name, and sensor communication address; configuration information of the sensor information point, including sensor information point name, sensor name, model information point name, register address, data type, data length, data parsing method, read / write function code, data offset, and conversion coefficient; according to the data type of the sensor information point, an initial value of the information point value is randomly assigned to each sensor information point.

[0009] Specifically, in the Step 5, the method for calculating the register value in reverse according to the information point value is as follows: First, calculate Value, where Value = (information point value - data offset) / conversion coefficient; then, use the data parsing method to perform reverse encapsulation on Value to obtain the register value.

[0010] Specifically, in the Step 7, the process of taking out and parsing a single-frame message from the newly appended message is as follows: Start traversing from the head of the message reception buffer queue, search for characters related to the read / write function code of the Modbus message. If found, judge whether the message length meets the requirements according to the Modbus message format. If not, continue traversing. If it meets the requirements, calculate and verify the CRC check code of the Modbus message. If the verification passes, take out the single-frame message; if not, continue traversing.

[0011] Specifically, in the Step 1, in the gateway database, a sensor model and its corresponding model information points are preset for each type of sensor. The preset information of the sensor model includes the model name, and the preset information of the model information points includes model information point name, model name, register address, data type, data length, data parsing method, read / write function code, data offset, and conversion coefficient; when configuring the sensor and its corresponding sensor information points, first select the sensor model and its corresponding model information points, and the configuration information of the sensor and its corresponding sensor information points inherits from the selected sensor model and its corresponding model information points.

[0012] Specifically, in the Step6: If the communication connection between the host computer and the network gateway is established through a USB-to-serial tool, the host computer, based on the serial port mapping relationship between the external serial port and the transfer serial port, uses the baud rate and parity bit in the external serial port communication parameters to open the transfer serial port and start a test thread, with each transfer serial port using an independent test thread; if the communication connection between the host computer and the network gateway is established through a serial port server, the host computer, based on the serial port mapping relationship between the external serial port and the TCP service port, creates a TcpSocket connection corresponding to the TCP service port to start a test thread, with each TCP service port using an independent test thread.

[0013] Specifically, in the Step5, the data simulation module of the host computer supports batch updating of the information point values of the sensor information points and also supports individual modification of the information point values of the sensor information points.

[0014] A wired sensor message simulation test device for a network gateway includes a network gateway with an external serial port, and an external serial port communication parameter configuration module, sensors, and corresponding sensor information point configuration modules are arranged inside the network gateway; it also includes a host computer with a test interface, and a data simulation module is arranged inside the host computer. The data simulation module includes a configuration parameter acquisition and loading unit, a Map table, an information point value modification unit, a register value calculation unit, a test thread construction unit, a single-frame message reading and parsing unit, and a single-frame message processing unit. The test interface is a USB interface or a network communication interface; The network gateway and the host computer are connected through a network communication method, and at the same time, a test signal connection is established between the test interface of the host computer and the external serial port of the network gateway through a USB-to-serial tool or a serial port server; The external serial port communication parameter configuration module configures communication parameters for each external serial port to be connected; The sensor and the corresponding sensor information point configuration module select an external serial port for each sensor to be connected, set the sensor communication address, and configure the sensor and the corresponding sensor information points; The configuration parameter acquisition and loading unit acquires and loads the communication parameters of each external serial port and the configuration information of each sensor and the corresponding sensor information points stored in the network gateway database through a network communication method; The Map table is constructed in the Modbus register buffer according to the serial port name, read / write function code, sensor communication address, and register address, and is used to store the register values of each sensor information point; The information point value modification unit is used to modify the information point values of the sensor information points and display the relevant information of the latest sensor information points through a visual interface; The register value calculation unit calculates the register value in reverse according to the information point value of the sensor information point and sends it to the Map table; The test thread construction unit constructs the serial port mapping relationship between each external serial port and the transfer serial port on the corresponding USB-to-serial tool, opens the transfer serial port using the baud rate and parity bit in the external serial port communication parameters, and starts the test thread; or constructs the serial port mapping relationship between each external serial port and the corresponding TCP service port on the serial port server, creates a TcpSocket connection to the corresponding TCP service port to start the test thread; adds a message reception buffer queue for each test thread to store the received messages; The single-frame message reading and parsing unit periodically obtains the read signal within the test thread. If the read signal is obtained, it reads all the messages and appends all the read messages to the message reception buffer queue; when there is a newly appended message in the message reception buffer queue, it starts the message processing process, takes out the single-frame message from the newly appended message and parses it; For the single-frame message with the read function code, the single-frame message processing unit obtains the corresponding register value from the Map table according to the sensor communication address, read function code, register address, and data length obtained by parsing the single-frame message, combined with the serial port name; for the single-frame message with the write function code, according to the sensor communication address, write function code, message data, register start address, register length, and a set of register values obtained by parsing the single-frame message, combined with the serial port name, it determines the sensor information point and matches the correct register value, and updates the visualization interface display and the Map table.

[0015] Specifically, a sensor model and a corresponding model information point preset module are also set in the gateway. In the gateway database, a sensor model and a corresponding model information point are preset for each type of sensor. The preset information of the sensor model includes the model name, and the preset information of the model information point includes the model information point name, model name, register address, data type, data length, data parsing method, read / write function code, data offset, and conversion coefficient; when configuring the sensor and the corresponding sensor information point, first select the sensor model and the corresponding model information point, and the configuration information of the sensor and the corresponding sensor information point inherits from the selected sensor model and the corresponding model information point.

[0016] Specifically, each USB-to-serial tool is connected to a group of corresponding external serial ports and USB interfaces. If the number of USB interfaces is insufficient, the number of USB interfaces is increased through a USB-hub.

[0017] Beneficial effects: The wired sensor message simulation test method and simulation test device provided by the present invention have the following advantages compared with the prior art: 1. Solve the problem of sensor shortage: Replace the actual sensor with a simulation tool, especially suitable for the stress test of the gateway when a large number of sensors are missing, and can verify the performance bottlenecks such as CPU, memory, and communication load of the gateway in a high-concurrency scenario; 2. Multiple serial ports and flexible connection: Support two wiring methods of USB to serial port and serial port server, and adapt to different hardware environments, including the situation of insufficient USB interfaces or lack of serial port conversion tools; 3. Visualization and batch operation: The operation interface intuitively displays the sensor values, supports batch refreshing or individual modification, reduces the operation difficulty, and does not require professional debugging experience; 4. Efficient data processing: Ensure that the values read by the gateway are consistent with the simulation display through the reverse calculation mechanism, facilitate data comparison, and verify the accuracy of the gateway's value processing; 5. Protocol extension ability: The basic architecture supports the extension of the Modbus TCP protocol and can adapt to the test requirements of more communication protocols in the future. Description of the Drawings

[0018] Figure 1 It is a schematic diagram of establishing a test signal connection between the test interface and the external serial port by using a USB to serial port tool; Figure 2 It is a schematic diagram of establishing a test signal connection between the test interface and the external serial port by using a serial port server; Figure 3 It is a schematic diagram of the visualization interface of the data simulation module; Figure 4 It is a schematic diagram of the processing flow of the data simulation module; Figure 5 It is a schematic diagram of the process of extracting a single-frame message. Detailed Embodiments

[0019] The present invention will be specifically introduced below in conjunction with the accompanying drawings and specific embodiments.

[0020] A wired sensor message simulation test device for a gateway includes a gateway with an external serial port, and an external serial port communication parameter configuration module, a sensor, and a corresponding sensor information point configuration module are set inside the gateway; it also includes a host computer with a test interface, and a data simulation module is set inside the host computer. The data simulation module includes a configuration parameter acquisition and loading unit, a Map table, an information point value modification unit, a register value calculation unit, a test thread construction unit, a single-frame message reading and parsing unit, and a single-frame message processing unit. The test interface is a USB interface or a network communication interface; the gateway and the host computer are connected through a network communication method, and at the same time, a test signal connection is established between the test interface of the host computer and the external serial port of the gateway through a USB to serial port tool or a serial port server.

[0021] There are two signal connections between the gateway and the host computer in this case: one is connected in a network communication mode, which is mainly used to obtain the database information of the gateway, and can also be understood as the information exchange other than the test signal; the other is the test signal connection, which is used to transmit the test signal between the test interface and the external serial port to implement the message simulation test.

[0022] Based on the above test device, this case also designs a method for simulating wired sensor messages of the gateway. The processing flow of the data simulation module is as Figure 4 shown. The following will be specifically described in combination with the specific implementation steps.

[0023] Step1. Preset the sensor model and the corresponding model information points In the gateway database, preset the sensor model and the corresponding model information points for each type of sensor. The preset information of the sensor model includes the model name, and the preset information of the model information points includes the model information point name, model name, register address, data type, data length, data parsing method, read / write function code, data offset, and conversion coefficient.

[0024] Model the sensors so that the same type of sensors have the same parameter data characteristics, and the information points of the same type of sensors also have the same parameter data characteristics, which is convenient for configuring sensors and the corresponding sensor data points in the gateway.

[0025] Step2. Configure the communication parameters of the external serial port In the gateway database, configure the communication parameters for each external serial port to be connected, including the serial port name, baud rate, parity bit, data bit, and stop bit.

[0026] Step3. Configure the sensors and the corresponding sensor information points Select an external serial port and a sensor model for each sensor to be connected, and set the sensor communication address; in the gateway database, configure each sensor to be connected and the corresponding sensor information points. The configuration information of the sensors and the corresponding sensor information points inherits from the selected sensor model and the corresponding model information points.

[0027] Step4. Establish the signal connection between the host computer and the gateway There are two signal connections between the host computer and the gateway computer. First, the host computer and the gateway computer are connected through network communication, which facilitates the host computer to obtain the data stored in the gateway computer's database. Second, a test signal connection is established between the test interface of the host computer and the external serial port of the gateway computer through a USB-to-serial tool or a serial server. The test signal connection depends on the form of the test interface. If the test interface is a USB interface, either a USB-to-serial tool or a serial server can be selected; if the test interface is a network interface, a serial server needs to be selected.

[0028] As Figure 1 shown, if a USB-to-serial tool is used, it is required that there is a one-to-one correspondence between the USB interface of each host computer and the external serial port of the gateway connection. One external serial port corresponds to one USB interface and one USB-to-serial tool; if the number of USB interfaces is insufficient, the number of USB interfaces can also be increased through a USB-hub.

[0029] As Figure 2 shown, it is a schematic diagram of establishing a test signal connection between the test interface and the external serial port using a serial server. First, the host computer and the serial server are connected through network communication, and then connections are established between each TCP service port on the serial server and each external serial port.

[0030] Step5. The host computer obtains and loads the configuration information in the gateway computer's database First, the host computer obtains the communication parameters of each external serial port, the configuration information of each sensor and the corresponding sensor information points stored in the gateway computer's database through network communication; then, the obtained configuration information is loaded into the data simulation module of the host computer, including: ① The communication parameters of the external serial port, including the serial port name, baud rate, parity bit, data bit and stop bit; ② The configuration information of the sensor, including the sensor name, model name, serial port name and sensor communication address; ③ The configuration information of the sensor information point, including the sensor information point name, sensor name, model information point name, register address, data type, data length, data parsing method, read / write function code, data offset and conversion coefficient; ④ According to the data type of the sensor information point, an initial value of the information point value is randomly assigned to each sensor information point.

[0031] As Figure 3 shown, the loaded configuration information is displayed through a visual interface.

[0032] Step6. Create a Map table In the data simulation module, a Modbus register buffer is opened based on the serial port name, read / write function code, sensor communication address, and register address, and the register values of each sensor information point are stored using a Map table.

[0033] Step7. Modification of the information point value of the sensor information point The data simulation module supports batch updating of the information point values of sensor information points and also supports individual modification of the information point values of sensor information points, and displays the relevant information of the latest sensor information points through a visual interface, facilitating comparison of the changes before and after data update.

[0034] Step8. Update of the register value After the information point value of the sensor information point is updated, first, the register value is obtained through reverse calculation using the data offset, conversion coefficient, and data parsing method, and then the register value is updated to the register address according to the data length, and the Map table is updated synchronously; the calculation method of the register value is as follows: Value = (information point value - data offset) / conversion coefficient The Value is reversely encapsulated using the data parsing method to obtain the register value.

[0035] Step9. Construction of the serial port mapping relationship between the external serial port and the host computer If the communication connection between the host computer and the network gateway is established through a USB-to-serial tool, since the serial port names generated by the USB-to-serial tool are not necessarily generated in the order of COM1, COM2... in this name and sequence, it is necessary to map between the external serial port of the network gateway and the transfer serial port of the host computer and store the mapping relationship in the cache.

[0036] If the communication connection between the host computer and the network gateway is established through a serial port server, it is necessary to configure the TCP service port corresponding to the outgoing serial port of each serial port server, obtain the mapping between the external serial port of the network gateway and the TCP service port bound to the docking serial port of the serial port server, and store the mapping relationship in the cache.

[0037] Step10. Construction of the test thread Since the data simulation module runs in the host computer, the creation of the test thread depends on the wiring method and the serial port mapping relationship.

[0038] If the communication connection between the host computer and the network gateway is established through a USB-to-serial tool, based on the serial port mapping relationship between the external serial port and the transfer serial port, the host computer opens the transfer serial port using the baud rate and parity bit in the external serial port communication parameters and starts the test thread, and each transfer serial port uses an independent test thread; If a communication connection between the host computer and the network gateway is established through a serial port server, the host computer creates a TCP service port corresponding to a TcpSocket connection based on the serial port mapping relationship between the external serial port and the TCP service port to start a test thread, and each TCP service port uses an independent test thread.

[0039] Step11. Create a message reception buffer queue Add a message reception buffer queue for each test thread to store the received messages.

[0040] Step12. Read and parse single-frame messages As Figure 5 shown, quickly obtain the read signal at a fixed time (20 milliseconds) within the test thread. If the read signal is obtained, read all messages and append all the read messages to the message reception buffer queue; when there are newly appended messages in the message reception buffer queue, start the message processing process, take out a single-frame message from the newly appended messages and parse it. The process is as follows: ① Traverse from the head of the message reception buffer queue to find the characters related to the read / write function code of the Modbus message, including 0x01\0x02\0x03\0x04\0x05\0x06\0x0f\0x10; ② If found, judge whether the message length meets the requirements according to the Modbus message format; ③ If the message length does not meet the requirements, continue to traverse; ④ If the message length meets the requirements, calculate and verify the CRC checksum of the Modbus message; ⑤ If the CRC checksum passes the verification, take out the single-frame message; ⑥ If the CRC checksum fails to pass the verification, continue to traverse.

[0041] Step13. Process single-frame messages Processing of read function codes: For read function codes 0x01, 0x02, 0x03, 0x04, according to the sensor communication address, register address, and data length obtained by parsing the single-frame message, combined with the serial port name, obtain the corresponding register value from the Map table, splice the response data based on the obtained register value, add the sensor communication address, read function code, data length, and CRC checksum to get the response message, and finally write the response message to the transfer serial port or TCP service port.

[0042] Write function code processing: For write function codes 0x05, 0x06, 0x10, and 0x0f: First, obtain the sensor communication address, write function code, message data, register start address, register length, and a set of register values from the parsed single-frame message; then, determine the sensor information point through the serial port name, sensor communication address, write function code, register start address, and register length, and obtain the register address, data type, data length, data parsing method, data offset, and conversion coefficient of the sensor information point; next, match the correct one or more register values from the set of register values according to the register address, data length, and message data, call the data parsing method to parse the matched register values, and calculate the information point value in combination with the data offset and conversion coefficient; finally, use the calculated information point value to update the visualization interface display, and at the same time use the matched register values to update the Map table.

[0043] The above has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the above embodiments do not limit the present invention in any form. Any technical solutions obtained by using equivalent replacement or equivalent transformation fall within the protection scope of the present invention.

Claims

1. A method for simulating and testing wired sensor messages of a gateway device, characterized in that: It includes the following steps: Step 1: In the gateway database, configure communication parameters for each external serial port to be accessed, select an external serial port for each sensor to be accessed, and configure the sensor and its corresponding sensor information point; Step 2: Establish a test signal connection between the host computer and the gateway through a USB-to-serial tool or a serial server; Step 3: The host computer obtains and loads the communication parameters of each external serial port stored in the gateway database and the configuration information of each sensor and its corresponding sensor information point through network communication; Step 4: In the data simulation module of the host computer, open the Modbus register buffer according to the serial port name, read / write function code, sensor communication address, and register address, and use the Map table to store the register values of each sensor information point; Step 5: In the data simulation module of the host computer, modify the information point value of the sensor information point, and display the relevant information of the latest sensor information point through the visualization interface; according to the modified information point value of the sensor information point, calculate the register value in reverse and synchronously update the Map table; Step 6: Build the serial port mapping relationship between each external serial port and the transfer serial port on the corresponding USB-to-serial tool, open the transfer serial port using the baud rate and parity bit in the external serial port communication parameters, and start the test thread; Or build the serial port mapping relationship between each external serial port and the corresponding TCP service port on the serial server, and start the test thread by creating a TcpSocket connection to the corresponding TCP service port; Add a message reception buffer queue for each test thread to store the received messages; Step 7: Regularly obtain the read signal within the test thread. If the read signal is obtained, read all messages and append all the read messages to the message reception buffer queue; When there is a newly appended message in the message reception buffer queue, start the message processing process, take out a single-frame message from the newly appended message and parse it; Step 8: For the single-frame message with the read function code, obtain the corresponding register value from the Map table according to the sensor communication address, read function code, register address, and data length parsed from the single-frame message, combined with the serial port name; for the single-frame message with the write function code, determine the sensor information point and match the correct register value according to the sensor communication address, write function code, message data, register start address, register length, and a set of register values parsed from the single-frame message, combined with the serial port name, and update the visualization interface display and the Map table.

2. The method for simulating and testing the wired sensor messages of the gateway according to claim 1, wherein: In the said Step 3, the information obtained and loaded by the host computer through network communication includes: communication parameters of the external serial port, including serial port name, baud rate, parity bit, data bit, and stop bit; configuration information of the sensor, including sensor name, model name, serial port name, and sensor communication address; configuration information of the sensor information point, including sensor information point name, sensor name, model information point name, register address, data type, data length, data parsing method, read / write function code, data offset, and conversion coefficient; according to the data type of the sensor information point, an initial value of the information point value is randomly assigned to each sensor information point.

3. The method for simulating and testing the wired sensor message of the gateway according to claim 1, characterized in that: In the said Step 5, the method for inversely calculating the register value according to the information point value is: First, calculate Value, Value = (information point value - data offset) / conversion coefficient; then, use the data parsing method to inversely encapsulate Value to obtain the register value.

4. The method for simulating and testing the wired sensor messages of the gateway according to claim 1, wherein: In the said Step 7, the process of taking out and parsing a single-frame message from the newly appended message is: Start traversing from the head of the message receiving buffer queue, search for characters related to the read / write function code of the Modbus message. If found, judge whether the message length meets the requirements according to the Modbus message format. If not, continue traversing. If it meets the requirements, calculate and verify the CRC check code of the Modbus message. If the verification passes, take out the single-frame message. If it fails, continue traversing.

5. The method for simulating and testing the wired sensor message of the gateway according to claim 1, wherein: In the said Step 1, in the gateway database, sensor models and corresponding model information points are preset for each type of sensor. The preset information of the sensor model includes the model name. The preset information of the model information point includes model information point name, model name, register address, data type, data length, data parsing method, read / write function code, data offset, and conversion coefficient. When configuring the sensor and the corresponding sensor information point, first select the sensor model and the corresponding model information point. The configuration information of the sensor and the corresponding sensor information point inherits from the selected sensor model and the corresponding model information point.

6. The wired sensor message simulation test method for the gateway according to claim 1, wherein: In the said Step 6: If the communication connection between the host computer and the gateway is established through the USB-to-serial tool, the host computer, based on the serial port mapping relationship between the external serial port and the transfer serial port, uses the baud rate and parity bit in the external serial port communication parameters to open the transfer serial port and start a test thread. Each transfer serial port uses an independent test thread; If the communication connection between the host computer and the gateway is established through the serial port server, the host computer, based on the serial port mapping relationship between the external serial port and the TCP service port, creates a TcpSocket connection corresponding to the TCP service port to start a test thread. Each TCP service port uses an independent test thread.

7. The method for simulating and testing the wired sensor message of the gateway according to claim 1, wherein: In the said Step 5, the data simulation module of the host computer supports batch updating of the information point values of the sensor information points and also supports individual modification of the information point values of the sensor information points.

8. A wired sensor message simulation test device for a gateway, characterized in that: It includes a gateway with an external serial port, and an external serial port communication parameter configuration module, sensors and corresponding sensor information point configuration modules are set inside the gateway; it also includes a host computer with a test interface, and a data simulation module is set inside the host computer. The data simulation module includes a configuration parameter acquisition and loading unit, a Map table, an information point value modification unit, a register value calculation unit, a test thread construction unit, a single-frame message reading and parsing unit, and a single-frame message processing unit. The test interface is a USB interface or a network communication interface; The gateway is connected to the host computer through a network communication method, and at the same time, a test signal connection is established between the test interface of the host computer and the external serial port of the gateway through a USB-to-serial tool or a serial server; The external serial port communication parameter configuration module configures communication parameters for each external serial port to be connected; The sensors and corresponding sensor information point configuration modules select external serial ports for each sensor to be connected, set the sensor communication address, and configure the sensors and corresponding sensor information points; The configuration parameter acquisition and loading unit acquires and loads the communication parameters of each external serial port and the configuration information of each sensor and the corresponding sensor information points stored in the gateway database through a network communication method; The Map table is constructed in the Modbus register buffer according to the serial port name, read / write function code, sensor communication address, and register address, and is used to store the register values of each sensor information point; The information point value modification unit is used to modify the information point values of the sensor information points and display the relevant information of the latest sensor information points through a visual interface; The register value calculation unit reversely calculates the register value according to the information point value of the sensor information point and sends it to the Map table; The test thread construction unit constructs the serial port mapping relationship between each external serial port and the transfer serial port on the corresponding USB-to-serial tool, opens the transfer serial port using the baud rate and parity bit in the external serial port communication parameters, and starts the test thread; Or construct the serial port mapping relationship between each external serial port and the corresponding TCP service port on the serial server, and create a TcpSocket connection to the corresponding TCP service port to start the test thread; Add a message reception buffer queue for each test thread to store the received messages; The single-frame message reading and parsing unit periodically obtains a read signal within the test thread. If the read signal is obtained, it reads all messages and appends the read all messages to the message reception buffer queue; When there is a newly appended message in the message reception buffer queue, start the message processing process, take out a single-frame message from the newly appended message and parse it; For the single-frame message of the read function code, the single-frame message processing unit obtains the corresponding register value from the Map table according to the sensor communication address, read function code, register address, and data length obtained by parsing the single-frame message, in combination with the serial port name; for the single-frame message of the write function code, according to the sensor communication address, write function code, message data, register start address, register length, and a set of register values obtained by parsing the single-frame message, in combination with the serial port name, it determines the sensor information point and matches the correct register value, and updates the visualization interface display and the Map table.

9. The wired sensor message simulation test device for a gateway according to claim 8, characterized in that: A sensor model and a corresponding model information point preset module are also set in the gateway. In the gateway database, a sensor model and a corresponding model information point are preset for each type of sensor. The preset information of the sensor model includes the model name, and the preset information of the model information point includes the model information point name, model name, register address, data type, data length, data parsing method, read / write function code, data offset, and conversion coefficient; when configuring the sensor and the corresponding sensor information point, first select the sensor model and the corresponding model information point, and the configuration information of the sensor and the corresponding sensor information point inherits from the selected sensor model and the corresponding model information point.

10. The wired sensor message simulation test device for a gateway according to claim 8, characterized in that: Each USB-to-serial tool is connected to a corresponding set of external serial ports and USB interfaces. If the number of USB interfaces is insufficient, the number of USB interfaces is increased through a USB-hub.

Citation Information

Patent Citations

  • Node data transmission method

    CN110839221A

  • Serial port test equipment

    CN114020550A

  • Offline closed-loop test method for telecontrol gateway machine

    CN119254682A

  • Simulation debugging method and device for wireless Lora sensor in power transformation and distribution station room

    CN119676748A

  • Multifunctional Modbus equipment testing device

    CN217508790U

Cited By

  • Method, module and device for debugging external serial port and troubleshooting communication fault of gateway machine

    CN120614280A