A 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 upper computer to simulate sensor information point values ​​and construct serial port mapping relationships, the problem of sensor shortage in gateway testing is solved, and efficient and visual multi-serial port communication test is realized, which exposes performance bottlenecks and supports protocol expansion.

CN120358169BActive Publication Date: 2025-08-29NANJING ZHENGTU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

During the gateway testing phase, there is a lack of sufficient sensor equipment for stress testing. The existing tools cannot visually display sensor information and cannot simulate multiple serial port communications at the same time, making it difficult to expose the performance bottleneck of the gateway in high concurrency and large data volume scenarios.

Method used

By configuring sensor information points and communication parameters in the gateway database, using the upper computer to simulate sensor information point values ​​and constructing serial port mapping relationships, multi-serial port adaptation and visualization operations are realized, and batch sensor simulation testing is supported.

Benefits of technology

It realizes efficient simulation test of large batches of sensors, exposing the performance bottleneck of gateways in high concurrency scenarios, reducing operational difficulty, improving data processing accuracy and visual display, supporting multiple hardware environments, and adapting to future communication protocol expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120358169B_ABST
    Figure CN120358169B_ABST
Patent Text Reader

Abstract

The present invention discloses a gateway machine wired sensor message simulation test method and simulation test device, which are suitable for serial communication test scenarios based on the Modbus RTU protocol. The method configures external serial port communication parameters and sensor information points in the gateway machine database, uses a USB serial conversion tool or a serial port server to establish a test signal connection between the host computer and the gateway machine, and after the host computer loads the configuration, stores register values ​​in the data simulation module through a Map table, supports visual modification of information point values ​​and reverse calculation to update register values. At the same time, a serial port mapping relationship is constructed, a test thread and a message receiving buffer queue are created, and the reading, parsing and processing of Modbus messages are realized. This invention solves the gateway machine stress test problem when there is a shortage of sensors, supports flexible connection of multiple serial ports and batch visualization operations, accurately processes data and has protocol expansion capabilities.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a gateway machine wired sensor message simulation test method and simulation test device, which are applicable to serial communication test scenarios based on the Modbus RTU protocol and belong to smart substation technology. Background Art

[0002] The serial port is an extremely commonly used communication interface for gateway devices and is one of the oldest and most mature standard interfaces for communication between computers and external devices. Due to its simple protocol, low implementation cost, stable communication, strong anti-interference ability, and low power consumption, common industrial equipment, instruments, embedded systems, network equipment, 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 most compatible communication interface.

[0003] Many mature and widely used industrial fieldbus protocols (such as Modbus RTU / ASCII, Profibus DP, and CAN bus) 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 (primarily RS-485 / RS-232). It is ubiquitous in industrial automation, building control, energy monitoring, and other fields.

[0004] During the development and testing phases, the sensor devices that the gateway needs to test may be out of stock or the test quantity may not meet the requirements. Especially during the gateway stress testing phase, a large number of sensor devices need to be connected for data access testing to verify their stability, processing power, communication load limit and resource management capabilities. This test 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] Although some current ModbusSlave tools support the ModbusRTU protocol and can directly modify register values, they cannot intuitively display the sensor information corresponding to the values ​​and the actual values. They rely on professional debugging experience to operate and use them. In addition, they cannot simulate multiple serial port communications at the same time and require opening multiple tool interfaces. In addition, they cannot perform large-scale data refresh operations. Summary of the Invention

[0006] Purpose of the invention: In order to overcome the deficiencies in the prior art, the present invention provides a gateway machine wired sensor message simulation test method and simulation test device, which realizes efficient simulation testing of large quantities of sensor messages through modeling design, multi-serial port adaptation and visual operation.

[0007] Technical solution: To achieve the above purpose, the technical solution adopted by the present invention is:

[0008] A gateway machine wired sensor message simulation test method includes the following steps:

[0009] Step 1. In the gateway database, configure the communication parameters for each external serial port to be connected, select the external serial port for each sensor to be connected, and configure the sensor and the corresponding sensor information point;

[0010] Step 2. Use a USB to serial converter or serial server to establish a test signal connection between the host computer and the gateway.

[0011] Step 3: The host computer obtains and loads the communication parameters of each external serial port, the configuration information of each sensor and the corresponding sensor information point stored in the gateway computer database through network communication;

[0012] 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 value of each sensor information point;

[0013] Step 5. In the data simulation module of the host computer, modify the information point value of the sensor information point and display the latest relevant information of the sensor information point through the visual interface; according to the modified information point value of the sensor information point, reversely calculate the register value and synchronously update the map table;

[0014] Step 6. Build a serial port mapping relationship between each external serial port and the corresponding serial port on the USB-to-serial tool. Use the baud rate and parity bit in the external serial port communication parameters to open the serial port and start the test thread. Alternatively, build a serial port mapping relationship between each external serial port and the corresponding TCP service port on the serial port server and start the test thread by creating a TcpSocket connection to the corresponding TCP service port. Add a message receiving buffer queue for each test thread to store received messages.

[0015] Step 7. Get the read signal regularly in the test thread. If the read signal is obtained, read all the messages and append all the read messages to the message receiving buffer queue. When there is a new message appended to the message receiving buffer queue, start the message processing process, take out the single frame message from the newly appended message and parse it.

[0016] Step 8. For single-frame messages with read function codes, obtain the corresponding register value from the Map table based on 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 single-frame messages with write function codes, determine the sensor information point and match the correct register value based on the sensor communication address, write function code, message data, register starting address, register length and a group of register values ​​obtained by parsing the single-frame message, combined with the serial port name, and update the visual interface display and Map table.

[0017] Specifically, in the Step 3, the information obtained and loaded by the host computer through the network communication method includes: 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, the initial value of the information point value is randomly assigned to each sensor information point.

[0018] Specifically, in Step 5, the method for reversely calculating the register value based on the information point value is as follows: first, calculate Value, Value = (information point value - data offset) / conversion coefficient; then, use the data parsing method to reversely encapsulate Value to obtain the register value.

[0019] Specifically, in Step 7, a single-frame message is taken out from the newly appended message and parsed. The process is: starting from the head of the message receiving buffer queue, searching for characters related to the read / write function code of the Modbus message, if found, judging whether the message length meets the requirements according to the Modbus message format, if not, continuing to traverse, if it meets, calculating and verifying the CRC check code of the Modbus message, if it passes the verification, taking out the single-frame message, if not, continuing to traverse.

[0020] Specifically, in Step 1, a sensor model and a corresponding model information point are preset in the gateway database 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 is inherited from the selected sensor model and the corresponding model information point.

[0021] Specifically, in Step 6: if the communication connection between the host computer and the gateway computer is established through the USB serial conversion tool, the host computer uses the baud rate and parity bit in the external serial port communication parameters to open the transferred serial port based on the serial port mapping relationship between the external serial port and the transferred serial port, and starts the test thread. Each transferred serial port uses an independent test thread; if the communication connection between the host computer and the gateway computer is established through the 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 the test thread. Each TCP service port uses an independent test thread.

[0022] Specifically, in Step 5, the data simulation module of the host computer supports batch updating of information point values ​​of sensor information points, and also supports single modification of information point values ​​of sensor information points.

[0023] A gateway machine wired sensor message simulation test device, comprising a gateway machine with an external serial port, an external serial port communication parameter configuration module, a sensor and a corresponding sensor information point configuration module arranged in the gateway machine; further comprising a host computer with a test interface, a data simulation module arranged in the host computer, the data simulation module comprising 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 being a USB interface or a network communication interface;

[0024] The gateway machine is connected to the host computer via a network communication mode, and a test signal connection is established between the test interface of the host computer and the external serial port of the gateway machine through a USB serial conversion tool or a serial port server;

[0025] The external serial port communication parameter configuration module configures communication parameters for each external serial port to be connected;

[0026] The sensor and corresponding sensor information point configuration module selects an external serial port for each sensor to be connected, sets the sensor communication address, and configures the sensor and the corresponding sensor information point;

[0027] The configuration parameter acquisition and loading unit acquires and loads the communication parameters of each external serial port, the configuration information of each sensor and the corresponding sensor information point stored in the gateway machine database through network communication;

[0028] 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 value of each sensor information point;

[0029] The information point value modification unit is used to modify the information point value of the sensor information point and display the latest relevant information of the sensor information point through a visual interface;

[0030] 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;

[0031] The test thread construction unit constructs a serial port mapping relationship between each external serial port and the corresponding serial port on the USB serial tool, uses the baud rate and parity bit in the external serial port communication parameters to open the serial port, and starts the test thread; or constructs a 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 receiving buffer queue for each test thread to store received messages;

[0032] The single-frame message reading and parsing unit periodically obtains a read signal in the test thread. If a read signal is obtained, all messages are read and all the read messages are appended to the message receiving buffer queue. When there is a new message appended to the message receiving buffer queue, the message processing process is started to take out a single-frame message from the newly appended message and parse it.

[0033] The single-frame message processing unit, for a single-frame message with a read function code, obtains the corresponding register value from the Map table based on 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 a single-frame message with a write function code, determines the sensor information point and matches the correct register value based on the sensor communication address, write function code, message data, register starting address, register length and a group of register values ​​obtained by parsing the single-frame message, combined with the serial port name, and updates the visual interface display and the Map table.

[0034] Specifically, the gateway machine is also provided with a sensor model and corresponding model information point preset module. In the gateway machine database, the sensor model and the 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 is inherited from the selected sensor model and the corresponding model information point.

[0035] Specifically, 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.

[0036] Beneficial effects: The gateway machine wired sensor message simulation test method and simulation test device provided by the present invention have the following advantages over the existing technology: 1. Solving the problem of sensor shortage: Replacing actual sensors with simulation tools, it is particularly suitable for gateway machine stress testing when a large number of sensors are missing, and can verify the performance bottlenecks of the gateway machine such as CPU, memory, and communication load in high-concurrency scenarios; 2. Multiple serial ports and flexible connections: Supporting two wiring methods, USB to serial port and serial port server, adapting to different hardware environments, including situations where USB interfaces are insufficient or there is a lack of serial port conversion tools; 3. Visualization and batch operation: The operation interface intuitively displays sensor values, supports batch refresh or single modification, reduces the difficulty of operation, and does not require professional debugging experience; 4. Efficient data processing: The reverse calculation mechanism is used to ensure that the values ​​read by the gateway machine are consistent with the simulation display, which facilitates data comparison and verifies the accuracy of the gateway machine's numerical processing; 5. Protocol expansion capability: The infrastructure supports Modbus TCP protocol expansion, which can adapt to the testing needs of more communication protocols in the future. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A schematic diagram for establishing a test signal connection between the test interface and the external serial port using a USB to serial tool;

[0038] Figure 2 A schematic diagram of the test signal connection between the test interface and the external serial port using a serial port server;

[0039] Figure 3 This is a diagram of the visual interface of the data simulation module;

[0040] Figure 4 This is a processing flow diagram of the data simulation module;

[0041] Figure 5 The figure is a flowchart for extracting a single-frame message. DETAILED DESCRIPTION

[0042] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0043] A gateway machine wired sensor message simulation test device, comprising a gateway machine with an external serial port, an external serial port communication parameter configuration module, a sensor and a corresponding sensor information point configuration module arranged in the gateway machine; further comprising a host computer with a test interface, a data simulation module arranged in the host computer, the data simulation module comprising 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 being a USB interface or a network communication interface; the gateway machine and the host computer are connected via a network communication mode, and a test signal connection between the test interface of the host computer and the external serial port of the gateway machine is established via a USB-to-serial conversion tool or a serial port server.

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

[0045] Based on the above test device, this case also designed a gateway machine wired sensor message simulation test method. The processing flow of the data simulation module is as follows: Figure 4 As shown, the following is a detailed description in combination with specific implementation steps.

[0046] Step 1: Preset sensor model and corresponding model information points

[0047] 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, 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.

[0048] The sensors are modeled so that sensors of the same type have the same parameter data characteristics, and sensor information points of the same type also have the same parameter data characteristics, which facilitates the configuration of sensors and corresponding sensor data points in the gateway machine.

[0049] Step 2: Configure the communication parameters of the external serial port

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

[0051] Step 3: Configure sensors and corresponding sensor information points

[0052] Select an external serial port and sensor model for each sensor to be connected, and set the sensor communication address; configure each sensor to be connected and the corresponding sensor information point in the gateway database. The configuration information of the sensor and the corresponding sensor information point is inherited from the selected sensor model and the corresponding model information point.

[0053] Step 4: Build the signal connection between the host computer and the gateway computer

[0054] There are two signal connections between the host computer and the gateway. First, connect the host computer and the gateway via network communication, allowing the host computer to access data stored in the gateway's database. Second, establish a test signal connection between the host computer's test interface and the gateway's external serial port using a USB-to-serial converter or serial server. The test signal connection depends on the test interface type. If the test interface is USB, you can use either a USB-to-serial converter or a serial server. If the test interface is a network interface, you need to use a serial server.

[0055] like Figure 1 As shown in the figure, if a USB-to-serial tool is used, there must be a one-to-one correspondence between the USB interface of each host computer and the external serial port connected to the gateway. 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.

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

[0057] Step 5: The host computer obtains and loads the configuration information in the gateway database

[0058] First, the host computer obtains the communication parameters of each external serial port, the configuration information of each sensor and the corresponding sensor information point stored in the gateway computer database through network communication; then, the obtained configuration information is loaded into the data simulation module of the host computer, including:

[0059] ① Communication parameters of the external serial port, including serial port name, baud rate, parity bit, data bits, and stop bits;

[0060] ②Sensor configuration information, including sensor name, model name, serial port name and sensor communication address;

[0061] ③ Configuration information of sensor information points, 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;

[0062] ④ According to the data type of the sensor information point, randomly assign an initial value of the information point value to each sensor information point.

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

[0064] Step 6. Create a Map table

[0065] In the data simulation module, the Modbus register buffer is opened according to the serial port name, read / write function code, sensor communication address and register address, and the register value of each sensor information point is stored in the Map table.

[0066] Step 7. Modify the information point value of the sensor information point

[0067] The data simulation module supports batch updating of information point values ​​of sensor information points, and also supports single modification of information point values ​​of sensor information points. It also displays the latest relevant information of sensor information points through a visual interface, making it easy to compare the changes before and after data update.

[0068] Step 8. Update register value

[0069] After the information point value of the sensor information point is updated, the data offset, conversion coefficient and data parsing method are used to perform reverse calculation to obtain the register value. Then, the register value is updated to the register address according to the data length, and the map table is updated synchronously. The register value calculation method is as follows:

[0070] Value = (information point value - data offset) / conversion factor

[0071] Use data parsing method to reverse encapsulate Value and obtain register value.

[0072] Step 9: Build the mapping relationship between the external serial port and the host computer serial port

[0073] If the communication connection between the host computer and the gateway computer 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, etc., it is necessary to map the external serial port of the gateway computer to the transferred serial port of the host computer and store the mapping relationship in the cache.

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

[0075] Step 10. Build a test thread

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

[0077] If the communication connection between the host computer and the gateway is established through the USB serial conversion tool, the host computer will open the transferred serial port based on the serial port mapping relationship between the external serial port and the transferred serial port, using the baud rate and parity bit in the external serial port communication parameters, and start the test thread. Each transferred serial port uses an independent test thread;

[0078] If the communication connection between the host computer and the gateway is established through the serial device server, the host computer creates a TCP service port corresponding to the TcpSocket connection to start the test thread based on the serial port mapping relationship between the external serial port and the TCP service port. Each TCP service port uses an independent test thread.

[0079] Step 11: Create a message receiving buffer queue

[0080] A message receiving buffer queue is added for each test thread to store received messages.

[0081] Step 12: Reading and parsing single-frame messages

[0082] like Figure 5 As shown, a read signal is obtained at a fast timing (20 milliseconds) within the test thread. If a read signal is obtained, all messages are read and appended to the message receiving buffer queue. When there is a new message appended to the message receiving buffer queue, the message processing flow is started, and a single-frame message is taken out from the newly appended message and parsed. The process is as follows:

[0083] ① Start traversing from the head of the message receiving buffer queue and search for characters related to the read / write function code of the Modbus message, including 0x01\0x02\0x03\0x04\0x05\0x06\0x0f\0x10;

[0084] ② If found, determine whether the message length meets the requirements based on the Modbus message format;

[0085] ③If the message length does not match, continue traversing;

[0086] ④ If the message length meets the requirements, calculate and verify the CRC check code of the Modbus message;

[0087] ⑤ If the CRC check code passes the verification, the single frame message is taken out;

[0088] ⑥If the CRC check code fails, continue traversing.

[0089] Step 13: Single-frame message processing

[0090] Read function code processing: For read function codes 0x01, 0x02, 0x03, and 0x04, the corresponding register value is obtained from the Map table based on the sensor communication address, register address, and data length obtained by parsing the single-frame message, combined with the serial port name. The response data is spliced ​​based on the obtained register value, and the sensor communication address, read function code, data length, and CRC checksum are added to obtain the response message. Finally, the response message is written to the transferred serial port or TCP service port.

[0091] Write function code processing: For write function codes such as 0x05, 0x06, 0x10, and 0x0f: First, obtain the sensor communication address, write function code, message data, register starting address, register length, and a group of register values ​​based on the analysis of the single-frame message; then, determine the sensor information point through the serial port name, sensor communication address, write function code, register starting 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; then, match the correct one or more register values ​​from a group of register values ​​based on the register address, data length, and message data, call the data parsing method to perform data parsing on 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 visual interface display, and use the matched register value to update the Map table.

[0092] The above shows and describes 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, and any technical solutions obtained by equivalent replacement or equivalent transformation fall within the scope of protection of the present invention.

Claims

1. A gateway wired sensor message simulation test method, characterized by: The steps include: Step 1. In the gateway database, configure the communication parameters for each external serial port to be connected, select the external serial port for each sensor to be connected, and configure the sensor and the corresponding sensor information point; Step 2. Use a USB to serial converter or serial server to establish a test signal connection between the host computer and the gateway. Step 3: The host computer obtains and loads the communication parameters of each external serial port, the configuration information of each sensor and the corresponding sensor information point stored in the gateway computer database 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 value 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 latest relevant information of the sensor information point through the visual interface; according to the modified information point value of the sensor information point, reversely calculate the register value and synchronously update the map table; Step 6. Build a serial port mapping relationship between each external serial port and the corresponding serial port on the USB to serial tool. Use the baud rate and parity bit in the external serial port communication parameters to open the serial port and start the test thread. Alternatively, a serial port mapping relationship is established between each external serial port and the corresponding TCP service port on the serial port server, and a test thread is started by creating a TcpSocket connection to the corresponding TCP service port. Add a message receiving buffer queue for each test thread to store received messages; Step 7: Get the read signal regularly in the test thread. If the read signal is obtained, read all the messages and append all the read messages to the message receiving buffer queue. When there is a new message added to the message receiving buffer queue, the message processing process is started, and a single-frame message is taken out from the newly added message and parsed; Step 8. For single-frame messages with read function codes, obtain the corresponding register value from the Map table based on 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 single-frame messages with write function codes, determine the sensor information point and match the correct register value based on the sensor communication address, write function code, message data, register starting address, register length and a group of register values ​​obtained by parsing the single-frame message, combined with the serial port name, and update the visual interface display and Map table.

2. The gateway machine wired sensor message simulation test method according to claim 1 is characterized in that: In the Step 3, the information obtained and loaded by the host computer through the network communication method includes: 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, the initial value of the information point value is randomly assigned to each sensor information point.

3. The gateway machine wired sensor message simulation test method according to claim 1 is characterized in that: In Step 5, the method for reversely calculating the register value based on the information point value is as follows: first, calculate Value, Value = (information point value - data offset) / conversion coefficient; then, use the data parsing method to reversely encapsulate Value to obtain the register value.

4. The gateway machine wired sensor message simulation test method according to claim 1, characterized in that: In Step 7, a single-frame message is taken out from the newly appended message and parsed. The process is as follows: traverse from the head of the message receiving buffer queue to search for characters related to the read / write function code of the Modbus message. If found, determine whether the message length meets the requirements according to the Modbus message format. If not, continue traversing. If it meets, calculate and verify the CRC check code of the Modbus message. If it passes the verification, take out the single-frame message. If it fails, continue traversing.

5. The gateway machine wired sensor message simulation test method according to claim 1, characterized in that: In Step 1, 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 is inherited from the selected sensor model and the corresponding model information point.

6. The gateway machine wired sensor message simulation test method according to claim 1, characterized in that: In Step 6: if the communication connection between the host computer and the gateway computer is established by the USB serial conversion tool, the host computer opens the transferred serial port based on the serial port mapping relationship between the external serial port and the transferred serial port, using the baud rate and parity bit in the external serial port communication parameters, and starts the test thread, and each transferred serial port uses an independent test thread; If the communication connection between the host computer and the gateway is established through the serial device server, the host computer creates a TCP service port corresponding to the TcpSocket connection to start the test thread based on the serial port mapping relationship between the external serial port and the TCP service port. Each TCP service port uses an independent test thread.

7. The gateway machine wired sensor message simulation test method according to claim 1, characterized in that: In 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 single modification of the information point values ​​of the sensor information points.

8. A gateway wired sensor message simulation test device, characterized by: It includes a gateway machine with an external serial port, in which an external serial port communication parameter configuration module, a sensor and a corresponding sensor information point configuration module are set; it also includes a host computer with a test interface, in which a data simulation module is set, and 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 machine is connected to the host computer via a network communication mode, and a test signal connection is established between the test interface of the host computer and the external serial port of the gateway machine through a USB serial conversion 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 corresponding sensor information point configuration module selects an external serial port for each sensor to be connected, sets the sensor communication address, and configures the sensor and the corresponding sensor information point; The configuration parameter acquisition and loading unit acquires and loads the communication parameters of each external serial port, the configuration information of each sensor and the corresponding sensor information point stored in the gateway machine database through network communication; 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 value of each sensor information point; The information point value modification unit is used to modify the information point value of the sensor information point and display the latest relevant information of the sensor information point 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 a serial port mapping relationship between each external serial port and the corresponding serial port on the USB serial conversion tool, uses the baud rate and parity bit in the external serial port communication parameters to open the serial port, and starts the test thread; Alternatively, build a serial port mapping relationship between each external serial port and the corresponding TCP service port on the serial port server, and create a TcpSocket connection to the corresponding TCP service port to start the test thread; Add a message receiving buffer queue for each test thread to store received messages; The single-frame message reading and parsing unit regularly obtains a read signal in the test thread. If a read signal is obtained, all messages are read and all the read messages are appended to the message receiving buffer queue. When there is a new message added to the message receiving buffer queue, the message processing process is started, and a single-frame message is taken out from the newly added message and parsed; The single-frame message processing unit, for a single-frame message with a read function code, obtains the corresponding register value from the Map table based on 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 a single-frame message with a write function code, determines the sensor information point and matches the correct register value based on the sensor communication address, write function code, message data, register starting address, register length and a group of register values ​​obtained by parsing the single-frame message, combined with the serial port name, and updates the visual interface display and the Map table.

9. The gateway machine wired sensor message simulation test device according to claim 8, characterized in that: The gateway machine is also provided with a sensor model and corresponding model information point preset module. In the gateway machine database, the sensor model and the 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 is inherited from the selected sensor model and the corresponding model information point.

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

Citation Information

Patent Citations

  • Node data transmission method

    CN110839221A

  • Multifunctional Modbus equipment testing device

    CN217508790U