[go: up one dir, main page]

CN119544821A - A gateway device Modbus data transparent transmission and protocol conversion method and device - Google Patents

A gateway device Modbus data transparent transmission and protocol conversion method and device Download PDF

Info

Publication number
CN119544821A
CN119544821A CN202411829294.9A CN202411829294A CN119544821A CN 119544821 A CN119544821 A CN 119544821A CN 202411829294 A CN202411829294 A CN 202411829294A CN 119544821 A CN119544821 A CN 119544821A
Authority
CN
China
Prior art keywords
data
modbus
downlink
serial port
uplink
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411829294.9A
Other languages
Chinese (zh)
Inventor
徐姣
于文学
周国祥
尤敏捷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Journey Information Technology Co ltd
Original Assignee
Nanjing Journey Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Journey Information Technology Co ltd filed Critical Nanjing Journey Information Technology Co ltd
Priority to CN202411829294.9A priority Critical patent/CN119544821A/en
Publication of CN119544821A publication Critical patent/CN119544821A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/08Protocols for interworking; Protocol conversion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • H04L12/40013Details regarding a bus controller
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • H04L12/40032Details regarding a bus interface enhancer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40228Modbus

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Communication Control (AREA)

Abstract

本发明公开了一种网关机设备Modbus数据透传和协议转换方法及装置,包括配置模块、数据普通传输模块、数据透传模块和其他协议上行传输模块;所述配置模块,用于在网关机中配置连接下行设备的通信节点、下行设备、下行设备的设备数据点、上行平台;数据普通传输方式中,下行数据传输和上行数据传输通过缓存分开进行,通信节点配置和上行平台配置彼此独立;数据透传方式中,上行平台下发串口采集命令,网关机将串口采集命令转发给下行串口并监听下行串口应答,当收到下行串口应答后,将下行串口应答写入上行串口;根据配置参照对下行串口应答进行解析,解析结果可以根据其他上行协议要求进行封装和传输。本发明在兼容Modbus报文采集的基础上,增加对Modbus上下行透传的报文处理,且同时支持多种上行协议数据上报的需求。

The present invention discloses a gateway device Modbus data transparent transmission and protocol conversion method and device, including a configuration module, a data common transmission module, a data transparent transmission module and other protocol uplink transmission modules; the configuration module is used to configure the communication node, the downlink device, the device data point of the downlink device, and the uplink platform connected to the downlink device in the gateway machine; in the data common transmission mode, the downlink data transmission and the uplink data transmission are carried out separately by caching, and the communication node configuration and the uplink platform configuration are independent of each other; in the data transparent transmission mode, the uplink platform issues a serial port acquisition command, the gateway machine forwards the serial port acquisition command to the downlink serial port and monitors the downlink serial port response, and when the downlink serial port response is received, the downlink serial port response is written into the uplink serial port; the downlink serial port response is parsed according to the configuration reference, and the parsing result can be encapsulated and transmitted according to other uplink protocol requirements. The present invention, on the basis of compatible Modbus message collection, increases the message processing of Modbus uplink and downlink transparent transmission, and simultaneously supports the demand for multiple uplink protocol data reporting.

Description

Gateway machine device Modbus data transparent transmission and protocol conversion method and device
Technical Field
The invention relates to a gateway equipment Modbus data transparent transmission and distribution method and device, and belongs to the data transmission technology of sensors in an intelligent substation.
Background
Modbus is a serial communication protocol, is widely applied to the field of industrial automation, and is mainly used for realizing data transmission between devices and monitoring and controlling industrial processes. Modbus protocols are also more commonly used in substation rooms.
In some application scenarios, the gateway device is required to be able to realize data transparent transmission to the accessed sensor device pair, and data transparent transmission of the Modbus device to another system or device.
The network shutdown is a multi-interface network device supporting multiple protocols, and supports Modbus protocol and possibly other protocol data, so that the network shutdown also requires to convert the data into the data of other protocols and transmit the data to other systems and platforms while transmitting the data.
Disclosure of Invention
The invention aims to overcome the defects in the prior art, and provides a method for transmitting and distributing Modbus data of gateway equipment, which increases message processing on the uplink and downlink transmission of Modbus and simultaneously supports the requirements of reporting various uplink protocol data on the basis of being compatible with Modbus message acquisition.
The technical scheme adopted by the invention is as follows:
A gateway machine device Modbus data transmission and distribution method includes dividing network shutdown data types into downlink data and uplink data, wherein the downlink data refers to Modbus data interacted by downlink equipment and a gateway machine through a downlink serial port, the uplink data refers to Modbus data interacted by an uplink platform and the gateway machine through an uplink serial port and other uplink protocol data, the Modbus data transmission is divided into a data common transmission mode and a data transmission mode, in the data common transmission mode, the downlink data transmission and the uplink data transmission are carried out separately through a buffer, communication node configuration and the uplink platform configuration are independent, the data transmission mode refers to serial port acquisition commands issued by the uplink platform, the gateway machine forwards the serial port acquisition commands to the downlink serial port and monitors the downlink serial port response, and the downlink serial port response is written into the uplink serial port after the downlink serial port response is received. The gateway machine starts a data acquisition thread, monitors a read signal of an uplink serial port, adds all monitored data to the tail of a data buffer queue, firstly searches a function code in the data buffer queue, then identifies a message type based on the function code, extracts a Modbus message according to the Modbus protocol, and transmits the Modbus message to the downlink device, then reads a downlink serial port response according to the Modbus protocol within a timeout period and transmits the Modbus response to the uplink platform, if the downlink serial port response is a query response message and an uplink transmission requirement based on other uplink protocols related to the query response message exists, analyzes relevant parameters of data points of the device, analyzes the data value of the data points of the device, refreshes the data value of the data points of the device according to the analysis result, and finally packages the data message according to the corresponding other uplink protocol requirements and transmits the data up.
The gateway machine monitors a read signal of an uplink serial port, adds all monitored data to the tail of a data buffer queue, and starts searching the function code of the Modbus from the head of the data buffer queue, when the function code of the Modbus is identified, judges whether the message type of a serial port acquisition command belongs to a Modbus inquiry message or a Modbus control message according to the function code of the Modbus.
Specifically, according to the Modbus protocol, if the message type belongs to a Modbus inquiry message, judging whether the length of a received message in a data buffer queue is greater than or equal to 6, if the length of the received message is greater than or equal to 6, taking the previous byte of a function code as a slave station address, taking the last two bytes of the function code as the high bits of a register address and the low bits of the register address, taking the last two bytes of the register address as the high bits of the register number and the low bits of the register number, and taking the last two bytes as a CRC check code, calculating whether the CRC check code is correct, if so, extracting a frame of message from the data buffer queue according to the Modbus inquiry message format, if not, continuing to search the function code of the Modbus in the data buffer queue, and judging, wherein the extracted message frame is the Modbus inquiry message, and writing the extracted message frame into a downlink serial port.
Specifically, according to the Modbus protocol, if the message type belongs to the Modbus control message, the former byte of the function code is taken as the address of the slave station, the latter two bytes of the function code are taken as the high bit of the register address and the low bit of the register address, other corresponding data and CRC check codes are obtained according to the type of the function code, whether the CRC check codes are correct or not is calculated, if the CRC check codes are correct, the Modbus control message format extracts a frame of message from the data buffer queue, if the CRC check codes are incorrect, the function code continues to be searched in the data buffer queue and judged, the extracted message frame is the Modbus control message, and the extracted message frame is written into the downlink serial port.
Specifically, after the network shutdown issues the extracted message frame to the downlink equipment, the downlink serial port response message is read within the timeout period, if the read timeout period or the read downlink serial port response message length is shorter than the Modbus message format requirement, the read downlink serial port response message is discarded, and if the read downlink serial port response message length meets the Modbus message format requirement, the downlink serial port response message is written into the uplink serial port.
The communication method comprises the steps of presetting a communication mode and a communication protocol in a database dictionary table of a gateway machine, wherein the communication mode comprises serial communication, the communication protocol comprises a Modbus transparent protocol, the communication protocol of a downlink serial port is called a downlink Modbus transparent protocol, the communication protocol of an uplink serial port is called an uplink Modbus transparent protocol, a communication node, a downlink device and a device data point and an uplink platform which are connected with the downlink device are configured in a network shutdown, configuration information of the communication node comprises a communication node ID, a communication mode, a communication protocol and communication address information, the communication protocol is a downlink Modbus transparent protocol, the configuration information of the downlink device comprises a communication node ID, a device ID and a device communication parameter, the device communication parameter is a Modbus communication address of the device, the configuration information of the device data point comprises a device ID, a device data point ID and a device data point information parameter, the configuration information of the uplink platform comprises a platform ID, platform connection information and the platform protocol is an uplink Modbus transparent protocol.
Specifically, for serial port communication, the communication address information comprises a serial port address, a communication protocol, a baud rate, a parity check bit, a data bit and a stop bit, the equipment data point information parameters comprise a Modbus register address, a function code, a data type, a data length, a data analysis method, a decimal point number, a conversion relation and a data offset, and the platform connection information comprises a serial port address, a communication protocol, a baud rate, a parity check bit, a data bit and a stop bit.
Specifically, the method comprises the following steps:
Step1, performing information configuration in the network shutdown, including:
(11) Presetting a communication mode and a communication protocol in a database dictionary table of a gateway machine, wherein the communication mode comprises serial port communication, the communication protocol comprises a Modbus transparent transmission protocol, the communication protocol of a downlink serial port is called a downlink Modbus transparent transmission protocol, and the communication protocol of an uplink serial port is called an uplink Modbus transparent transmission protocol;
(12) Configuring a communication node connected with downlink equipment in a database of the network shutdown, wherein the configuration information comprises a communication node ID, a communication mode, a communication protocol and communication address information, wherein the communication protocol is a downlink Modbus transparent transmission protocol, the communication address information is combined information about equipment communication parameters, and for serial port communication, the communication address information comprises a serial port address, a communication protocol, a baud rate, a parity check bit, a data bit and a stop bit;
(13) Selecting a communication node, configuring downlink equipment, wherein the configuration information comprises a communication node ID, an equipment ID and equipment communication parameters, and the equipment communication parameters are Modbus communication addresses of the equipment;
(14) Selecting downlink equipment, configuring equipment data points, wherein the configuration information comprises equipment ID, equipment data point ID and equipment data point information parameters, the equipment data point information parameters are combined information about Modbus channels, and the equipment data point information parameters comprise Modbus register addresses, function codes, data types, data lengths, data analysis methods, decimal point numbers, conversion relations and data offsets;
(15) Configuring an uplink platform in a database of network shutdown, wherein configuration information comprises a platform ID, a platform protocol and platform connection information, wherein the platform protocol is an uplink Modbus transparent transmission protocol, the platform connection information is combination information about access parameters, and the platform connection information comprises a serial port address, a communication protocol, a baud rate, a parity check bit, a data bit and a stop bit;
Step2, loading communication node configuration, downlink equipment configuration, equipment data point configuration and uplink platform configuration;
step3, judging whether the communication node configures a downlink Modbus transparent transmission protocol, and the uplink platform configures an uplink Modbus transparent transmission protocol, wherein if not, the communication node is processed according to a common data reporting flow, and if so, the communication node is processed according to a data transparent transmission flow, wherein the data transparent transmission flow comprises the following steps:
(31) Analyzing communication address information in the communication node configuration information, and opening a downlink serial port according to the serial port address, the baud rate, the parity check bit, the data bit, the stop bit and other information of the downlink serial port;
(32) Analyzing platform connection information in the uplink platform configuration information, and opening an uplink serial port according to the serial port address, the baud rate, the parity check bit, the data bit, the stop bit and other information of the uplink serial port;
(33) Starting a data acquisition thread, monitoring a read signal of an uplink serial port, reading all data of the uplink serial port when the read signal of the uplink serial port is monitored, and adding all the read data to the tail of a data buffer queue;
(34) Searching the function code of the Modbus from the head of a queue of the data buffer, when the function code of the Modbus is identified, judging whether the message type belongs to a Modbus inquiry message or a Modbus control message according to the function code of the Modbus, and extracting a frame of message according to the format requirement of the Modbus message;
(341) According to the Modbus protocol, if the message type belongs to a Modbus inquiry message, judging whether the length of a received message in a data buffer queue is more than or equal to 6, if so, taking the previous byte of a function code as a slave station address, taking the last two bytes of the function code as the high bits of a register address and the low bits of the register address, taking the last two bytes of the register address as the high bits of the register number and the low bits of the register number, and taking the last two bytes as CRC check codes;
(342) According to the Modbus protocol, if the message type belongs to a Modbus control message, taking the previous byte of the function code as a slave station address, taking the last two bytes of the function code as the high bit of a register address and the low bit of the register address, and acquiring other corresponding data and CRC (cyclic redundancy check) codes according to the function code type;
(35) The method comprises the steps of writing a frame of extracted message into a downlink serial port, and reading a downlink serial port response message within a timeout period, discarding the read downlink serial port response message if the reading timeout period or the read downlink serial port response message length is shorter than the Modbus message format requirement, and writing the downlink serial port response message into an uplink serial port if the read downlink serial port response message length meets the Modbus message format requirement;
(36) If the downlink serial port response message is a query response message and there is an uplink transmission requirement on the query response message based on other uplink protocols, analyzing the downlink serial port response message at the same time, acquiring a slave station address, a register address and a register length in the downlink serial port response message, matching corresponding equipment data points according to the slave station address, the register address and the register length, then analyzing the data value of the equipment data points according to information such as Modbus register address, function code, data type, data length, data analysis method, decimal place number, conversion relation, data offset and the like contained in the equipment data point information parameters, refreshing the data value of the equipment data points according to analysis results, packaging the data message according to the corresponding other uplink protocol requirements, and transmitting the data.
The gateway equipment Modbus data transparent transmission and distribution device for realizing the method comprises a configuration module, a data common transmission module, a data transparent transmission module and other protocol uplink transmission modules;
The configuration module is used for configuring communication nodes connected with the downlink equipment, equipment data points of the downlink equipment and an uplink platform in the network shutdown;
the data common transmission module sets up downlink data transmission and uplink data transmission to be carried out separately through a cache when one or two of an uplink serial port or a downlink serial port in a data acquisition thread do not adopt a Modbus transparent transmission protocol, and independently configures a communication node and an uplink platform;
The gateway machine forwards the serial port acquisition command issued by the uplink platform to the downlink serial port and monitors the downlink serial port response, and writes the downlink serial port response into the uplink serial port after receiving the downlink serial port response;
And if the downlink serial port response is a query response message and an uplink transmission requirement based on other uplink protocols about the query response message exists, analyzing the query response message, acquiring relevant parameters of equipment data points, analyzing data values of the equipment data points, refreshing the data values of the equipment data points according to analysis results, and finally packaging the data message and transmitting uplink according to the corresponding other uplink protocol requirements.
The configuration module presets a communication mode and a communication protocol in a database dictionary table of a gateway machine, wherein the communication mode comprises serial communication, the communication protocol comprises a Modbus transparent protocol, the communication protocol of a downlink serial port is called a downlink Modbus transparent protocol, the communication protocol of an uplink serial port is called an uplink Modbus transparent protocol, a communication node, a downlink device, device data points of the downlink device and an uplink platform which are connected in a network machine are configured, configuration information of the communication node comprises a communication node ID, a communication mode, a communication protocol and communication address information, the communication protocol is the downlink Modbus transparent protocol, the configuration information of the downlink device comprises a communication node ID, a device ID and a device communication parameter, the device communication parameter is a Modbus communication address of the device, the configuration information of the device data point comprises a device ID, a device data point ID and a device data point information parameter, the configuration information of the uplink platform comprises a platform ID, platform protocol and platform connection information, and the platform protocol is the uplink Modbus transparent protocol.
Compared with the prior art, the method and the device for Modbus data transmission and protocol conversion of gateway equipment have the advantages that 1, the processing mechanism of Modbus uplink and downlink transmission messages is innovatively increased on the basis of being compatible with traditional Modbus message collection, 2, the characteristic that function codes of Modbus messages are relatively fixed is fully utilized, the function codes are used as message retrieval basis, modbus messages are accurately taken out and checked according to strict Modbus message formats, the data transmission error rate is effectively reduced, 3, data values can be intelligently matched according to register addresses and the number of registers in the messages, data points of the equipment are taken out, 4, multi-protocol conversion can be achieved by combining parameter configuration while Modbus data transmission is achieved, data is packaged into other uplink protocol formats, communication requirements of different systems and platforms are met, and the method and the device have high flexibility and expandability, can be easily adapted to complex and changeable industrial automation environments, and difficulty and cost of system integration are effectively reduced.
Drawings
FIG. 1 is a schematic flow chart of the method of the present invention.
Detailed Description
The invention is described in detail below with reference to the drawings and the specific embodiments.
A gateway device Modbus data transparent transmission and distribution device comprises a configuration module, a data common transmission module, a data transparent transmission module and other protocol uplink transmission modules. The configuration module is used for configuring the communication node, the downlink equipment, the equipment data points of the downlink equipment and the uplink platform which are connected with the downlink equipment in the network shutdown. And the data common transmission module sets the downlink data transmission and the uplink data transmission to be carried out separately through the cache when one or two of the uplink serial port and the downlink serial port in the data acquisition thread do not adopt the Modbus transparent transmission protocol, and configures the communication node and the uplink platform independently. The gateway machine forwards the serial port acquisition command issued by the uplink platform to the downlink serial port and monitors the downlink serial port response, and writes the downlink serial port response into the uplink serial port after receiving the downlink serial port response. And if the downlink serial port response is a query response message and an uplink transmission requirement based on other uplink protocols about the query response message exists, analyzing the query response message, acquiring relevant parameters of equipment data points, analyzing data values of the equipment data points, refreshing the data values of the equipment data points according to analysis results, and finally packaging the data message and transmitting uplink according to the corresponding other uplink protocol requirements.
In the scheme, the data types of the network shutdown are divided into downlink data and uplink data, the downlink data refers to Modbus data interacted by downlink equipment and a gateway machine through a downlink serial port, the uplink data refers to Modbus data interacted by an uplink platform and the gateway machine through an uplink serial port and other uplink protocol data, the transmission of the Modbus data is divided into a data common transmission mode and a data transmission mode, in the data common transmission mode, the downlink data transmission and the uplink data transmission are carried out separately through a cache, the communication node configuration and the uplink platform configuration are independent from each other, the data transmission mode refers to the downlink serial port acquisition command issued by the uplink platform, the gateway machine forwards the serial port acquisition command to the downlink serial port and monitors the downlink serial port response, and after the downlink serial port response is received, the downlink serial port response is written into the uplink serial port.
The following describes the present invention further by taking a sensor as an example of a downlink device in conjunction with the specific implementation steps of the Modbus data transparent transmission and distribution method of the gateway device shown in fig. 1.
Step1, information configuration is carried out in the network shutdown
Gateway machines typically support inputs and outputs for multiple interfaces and multiple protocols; in the data common transmission mode, downlink data transmission and uplink data transmission are separately carried out through buffering, a gateway machine generates proper uplink data or downlink data according to a transmission protocol and then carries out data transmission, and in the data transparent transmission mode, the gateway machine is mainly responsible for data forwarding. In order to distinguish the common data transmission mode and realize the data transmission mode, a protocol type needs to be added for the data transmission.
The communication mode and the communication protocol are preset in a database dictionary table of the gateway machine, the communication mode comprises serial port communication (shown in table 1), the communication protocol comprises Modbus transparent transmission protocol, the communication protocol of a downlink serial port is called downlink Modbus transparent transmission protocol, and the communication protocol of an uplink serial port is called uplink Modbus transparent transmission protocol (shown in table 2).
Table 1 preset communication modes in database dictionary table of gateway machine
Dictionary code Dictionary item ID Name of the name Description of the invention
commmode 1 Serial port Serial port communication
Table 2 adding communication protocols to a database dictionary table of a gateway machine
Dictionary code Dictionary item ID Name of the name Description of the invention
protocoltype 11 MODBUS transparent transmission Downstream MODBUS transparent transmission protocol
agreementtype 11 MODBUS transparent transmission Uplink MODBUS transparent transmission protocol
As shown in table 3, a communication node connected to the downstream equipment is arranged in a database of the gateway device.
Table 3 configuration of communication nodes in database of network shutdown
Fields Type(s) Description of the invention
Id Number Communication node ID, non-null,
Name String Communication node name
Commaddr String Communication address information
Commmode Number Communication method
Protocoltype Number Communication protocol
The communication address information is combined information about equipment communication parameters, and for serial port communication, the communication address information comprises serial port address, communication protocol, baud rate, parity check bit, data bit, stop bit and other information, and the communication protocol adopts downlink Modbus transparent transmission protocol.
And the gateway machine needs to collect the relevant information of the sensor and the sensor data point to carry out sensor configuration and sensor data point configuration.
As shown in table 4, the sensor configuration information includes a communication node ID, a sensor ID, and a sensor communication parameter, which is a Modbus communication address of the sensor.
Table 4 sensor configuration
Fields Type(s) Description of the invention
Id Number Sensor ID, non-null #
Name String Sensor name
commnodeid Number Communication node ID
commaddr String Sensor communication parameters
As shown in table 5, the sensor data point configuration information includes a sensor ID, a sensor data point ID, and a sensor data point information parameter, which is combination information about the Modbus channel, and the sensor data point information parameter includes information such as a Modbus register address, a function code, a data type, a data length, a data parsing method, a decimal point number, a conversion relation, and a data offset.
Table 5 sensor data point configuration
Fields Type(s) Description of the invention
Id Number Sensor data point ID, non-null
Name String Sensor data point name
sensorid Number Sensor ID
url String Sensor data point information parameters
As shown in table 6, an uplink platform is configured in a database of the network shutdown, the configuration information includes a platform ID, a platform protocol and platform connection information, the platform protocol is an uplink Modbus transparent transmission protocol, the platform connection information is combination information about access parameters, and the platform connection information includes information such as serial port address, communication protocol, baud rate, parity check bit, data bit, stop bit, and the like.
Table 6 uplink platform configuration
Fields Type(s) Description of the invention
Id Number Platform ID, non-null
Name String Platform name
type String Platform protocol, non-null
Url String Platform connectivity information
Step2, load configuration information
Loading communication node configuration, downlink equipment configuration, equipment data point configuration and uplink platform configuration.
Step3, starting a data common transmission module and a data transparent transmission module
If one or both of the communication node and the uplink platform are not configured with the Modbus transparent transmission protocol, a data common transmission module is adopted for processing according to the current common data reporting flow.
If the communication node is configured with a downlink Modbus transparent transmission protocol and the uplink platform is configured with an uplink Modbus transparent transmission protocol, a data transparent transmission module is adopted for data transmission, and the specific steps are as follows.
And step 31, analyzing communication address information in the communication node configuration information, and opening the downlink serial port according to the serial port address, the baud rate, the parity check bit, the data bit, the stop bit and other information of the downlink serial port.
And step 32, analyzing the platform connection information in the uplink platform configuration information, and opening the uplink serial port according to the serial port address, the baud rate, the parity check bit, the data bit, the stop bit and other information of the uplink serial port.
And 33, starting a data acquisition thread, monitoring a read signal of the uplink serial port, reading all data of the uplink serial port when the read signal of the uplink serial port is monitored, and adding all the read data to the tail of the data buffer queue.
And step 34, searching the function code of the Modbus from the head of the data buffer queue, judging whether the message type belongs to the Modbus inquiry message or the Modbus control message according to the function code of the Modbus when the function code of the Modbus is identified, and extracting a frame of message according to the format requirement of the Modbus message.
The query message format is shown in table 7, and the control message format is shown in table 8.
Table 7 query message format
Table 8 control message format
Step 341, according to the Modbus protocol, if the message type belongs to the Modbus query message, in combination with table 7, judging whether the length of the received message in the data buffer queue is greater than or equal to 6, if so, taking the previous byte of the function code as the slave address, taking the last two bytes of the function code as the high bits of the register address and the low bits of the register address, taking the last two bytes of the register address as the high bits of the register number and the low bits of the register number, taking the last two bytes as the CRC check code, calculating whether the CRC check code is correct, if so, extracting a frame of message from the data buffer queue according to the format of the Modbus query message, if not, continuing to search the function code of the Modbus in the data buffer queue and judging.
Step 342, according to the Modbus protocol, if the message type belongs to the Modbus control message, in combination with table 8, the previous byte of the function code is taken as the slave address, the last two bytes of the function code are taken as the high bit of the register address and the low bit of the register address, other corresponding data and the CRC check code are obtained according to the function code type, whether the CRC check code is correct or not is calculated, if so, the Modbus control message format extracts a frame of message from the data buffer queue, and if not, the function code continues to be searched in the data buffer queue and judged.
Step 35, writing the extracted frame of message into the downlink serial port, and reading the downlink serial port response message within the overtime time, and if the read overtime or the read downlink serial port response message length is shorter than the Modbus message format requirement, discarding the read downlink serial port response message, and if the read downlink serial port response message length meets the Modbus message format requirement, writing the downlink serial port response message into the uplink serial port by combining the tables 9 and 10.
Table 9 query response message format
Table 10 controls the format of the reply message
Step 36, if the downlink serial port response message is a query response message and there is an uplink transmission requirement about the query response message based on other uplink protocols, analyzing the downlink serial port response message at the same time, acquiring a slave station address, a register address and a register length in the downlink serial port response message, matching corresponding device data points according to the slave station address, the register address and the register length, then analyzing data values of the device data points according to information such as Modbus register address, function codes, data types, data lengths, data analysis methods, decimal place numbers, conversion relations, data offsets and the like contained in the device data point information parameters, refreshing the data values of the device data points according to analysis results, and packaging the data message and transmitting the data messages uplink according to the corresponding other uplink protocol requirements.
The foregoing has shown and described the basic principles, principal features and advantages of the invention. It will be appreciated by persons skilled in the art that the above embodiments are not intended to limit the invention in any way, and that all technical solutions obtained by means of equivalent substitutions or equivalent transformations fall within the scope of the invention.

Claims (10)

1. A gateway machine device Modbus data transparent transmission and distribution method is characterized in that the gateway machine is connected with downlink devices through downlink serial ports and connected with an uplink platform through uplink serial ports, modbus transparent transmission protocols are configured for the downlink serial ports and the uplink serial ports, a data acquisition thread is started by the gateway machine, reading signals of the uplink serial ports are monitored, all monitored data are added to the tail of a data buffer queue, functional codes are searched in the data buffer queue, message types are identified based on the functional codes, modbus messages are extracted according to the Modbus protocols and sent to the downlink devices, downlink serial port responses are read according to the Modbus protocols and sent to the uplink platform within timeout time, if the downlink serial port responses are query response messages, and uplink transmission requirements based on other uplink protocols on the query response messages exist, the query response messages are analyzed, relevant parameters of data points of the devices are obtained, the data points of the devices are refreshed according to the data values of the protocols of the data points of the devices, and finally the data messages are packaged according to corresponding other uplink requirements and are transmitted in an uplink mode.
2. The method for transmitting and distributing Modbus data of gateway equipment according to claim 1, wherein the gateway monitors a read signal of an uplink serial port, adds all monitored data to a queue tail of a data buffer queue, and when the Modbus function code is identified, judges whether a message type of a serial port acquisition command belongs to a Modbus inquiry message or a Modbus control message according to the Modbus function code.
3. The method for transmitting and distributing Modbus data of gateway equipment according to claim 2, wherein according to a Modbus protocol, if the message type belongs to a Modbus inquiry message, judging whether the length of a received message in a data buffer queue is greater than or equal to 6, if the message type is greater than or equal to 6, taking the front byte of the function code as a slave station address, the last two bytes of the function code as the high bits of a register address and the low bits of the register address, the last two bytes of the register address as the high bits of the register number and the low bits of the register number, calculating whether the CRC check code is correct or not, if so, extracting a frame of message from the data buffer queue according to a Modbus inquiry message format, if not, continuing to search the function code of the Modbus in the data buffer queue and judging, and if not, taking the extracted message frame as the Modbus inquiry message, and writing the extracted message frame into a downlink serial port.
4. The method for transmitting and distributing Modbus data of gateway equipment according to claim 2, wherein according to a Modbus protocol, if the message type belongs to a Modbus control message, the former byte of the function code is taken as a slave address, the latter two bytes of the function code are taken as the high bits of a register address and the low bits of the register address, other corresponding data and CRC check codes are obtained according to the function code type, whether the CRC check codes are correct or not is calculated, if the CRC check codes are correct, a frame of message is extracted from a data buffer queue in the Modbus control message format, if the CRC check codes are incorrect, the function code continues to be searched in the data buffer queue and judged, the extracted message frame is the Modbus control message, and the extracted message frame is written into a downlink serial port.
5. The Modbus data transparent transmission and distribution method of gateway equipment according to claim 1, wherein after the gateway equipment transmits the extracted message frame to the downlink equipment, the gateway equipment reads the downlink serial port response message within the timeout period, discards the read downlink serial port response message if the reading timeout period or the read downlink serial port response message length is shorter than the Modbus message format requirement, and writes the downlink serial port response message into the uplink serial port if the read downlink serial port response message length meets the Modbus message format requirement.
6. The Modbus data transmission and distribution method of gateway equipment according to claim 1 is characterized in that a communication mode and a communication protocol are preset in a database dictionary table of a gateway equipment, the communication mode comprises serial communication, the communication protocol comprises a Modbus transmission protocol, the communication protocol of a downlink serial port is called a downlink Modbus transmission protocol, the communication protocol of an uplink serial port is called an uplink Modbus transmission protocol, a communication node connected with the downlink equipment, the downlink equipment and equipment data points of the downlink equipment are configured in the gateway equipment, an uplink platform is configured, the configuration information of the communication node comprises a communication node ID, the communication mode, the communication protocol and communication address information, the communication protocol is the downlink Modbus transmission protocol, the configuration information of the downlink equipment comprises a communication node ID, equipment ID and equipment communication parameters, the equipment communication parameters are Modbus communication addresses of the equipment, the configuration information of the equipment data points comprises an equipment ID, the equipment data points and equipment data point information parameters, the configuration information of the uplink platform comprises a platform ID and platform connection information, and the platform protocol is the uplink Modbus transmission protocol.
7. The method for transparently transmitting and distributing Modbus data of gateway device according to claim 6, wherein for serial port communication, the communication address information comprises serial port address, communication protocol, baud rate, parity check bit, data bit and stop bit, the device data point information parameter comprises Modbus register address, function code, data type, data length, data parsing method, decimal place, conversion relation and data offset, and the platform connection information comprises serial port address, communication protocol, baud rate, parity check bit, data bit and stop bit.
8. The method for transparently transmitting and distributing Modbus data of gateway equipment according to claim 1, wherein the method comprises the following steps:
Step1, performing information configuration in the network shutdown, including:
(11) Presetting a communication mode and a communication protocol in a database dictionary table of a gateway machine, wherein the communication mode comprises serial port communication, the communication protocol comprises a Modbus transparent transmission protocol, the communication protocol of a downlink serial port is called a downlink Modbus transparent transmission protocol, and the communication protocol of an uplink serial port is called an uplink Modbus transparent transmission protocol;
(12) Configuring a communication node connected with downlink equipment in a database of the network shutdown, wherein the configuration information comprises a communication node ID, a communication mode, a communication protocol and communication address information, wherein the communication protocol is a downlink Modbus transparent transmission protocol, the communication address information is combined information about equipment communication parameters, and for serial port communication, the communication address information comprises a serial port address, a communication protocol, a baud rate, a parity check bit, a data bit and a stop bit;
(13) Selecting a communication node, configuring downlink equipment, wherein the configuration information comprises a communication node ID, an equipment ID and equipment communication parameters, and the equipment communication parameters are Modbus communication addresses of the equipment;
(14) Selecting downlink equipment, configuring equipment data points, wherein the configuration information comprises equipment ID, equipment data point ID and equipment data point information parameters, the equipment data point information parameters are combined information about Modbus channels, and the equipment data point information parameters comprise Modbus register addresses, function codes, data types, data lengths, data analysis methods, decimal point numbers, conversion relations and data offsets;
(15) Configuring an uplink platform in a database of network shutdown, wherein configuration information comprises a platform ID, a platform protocol and platform connection information, wherein the platform protocol is an uplink Modbus transparent transmission protocol, the platform connection information is combination information about access parameters, and the platform connection information comprises a serial port address, a communication protocol, a baud rate, a parity check bit, a data bit and a stop bit;
Step2, loading communication node configuration, downlink equipment configuration, equipment data point configuration and uplink platform configuration;
step3, judging whether the communication node configures a downlink Modbus transparent transmission protocol, and the uplink platform configures an uplink Modbus transparent transmission protocol, wherein if not, the communication node is processed according to a common data reporting flow, and if so, the communication node is processed according to a data transparent transmission flow, wherein the data transparent transmission flow comprises the following steps:
(31) Analyzing communication address information in the communication node configuration information, and opening a downlink serial port according to serial port address, baud rate, parity check bit, data bit and stop bit information of the downlink serial port;
(32) Analyzing platform connection information in the uplink platform configuration information, and opening an uplink serial port according to serial port address, baud rate, parity check bit, data bit and stop bit information of the uplink serial port;
(33) Starting a data acquisition thread, monitoring a read signal of an uplink serial port, reading all data of the uplink serial port when the read signal of the uplink serial port is monitored, and adding all the read data to the tail of a data buffer queue;
(34) Searching the function code of the Modbus from the head of a queue of the data buffer, when the function code of the Modbus is identified, judging whether the message type belongs to a Modbus inquiry message or a Modbus control message according to the function code of the Modbus, and extracting a frame of message according to the format requirement of the Modbus message;
(341) According to the Modbus protocol, if the message type belongs to a Modbus inquiry message, judging whether the length of a received message in a data buffer queue is more than or equal to 6, if so, taking the previous byte of a function code as a slave station address, taking the last two bytes of the function code as the high bits of a register address and the low bits of the register address, taking the last two bytes of the register address as the high bits of the register number and the low bits of the register number, and taking the last two bytes as CRC check codes;
(342) According to the Modbus protocol, if the message type belongs to a Modbus control message, taking the previous byte of the function code as a slave station address, taking the last two bytes of the function code as the high bit of a register address and the low bit of the register address, and acquiring other corresponding data and CRC (cyclic redundancy check) codes according to the function code type;
(35) The method comprises the steps of writing a frame of extracted message into a downlink serial port, and reading a downlink serial port response message within a timeout period, discarding the read downlink serial port response message if the reading timeout period or the read downlink serial port response message length is shorter than the Modbus message format requirement, and writing the downlink serial port response message into an uplink serial port if the read downlink serial port response message length meets the Modbus message format requirement;
(36) If the downlink serial port response message is a query response message and there is an uplink transmission requirement on the query response message based on other uplink protocols, analyzing the downlink serial port response message at the same time, acquiring a slave station address, a register address and a register length in the downlink serial port response message, matching corresponding equipment data points according to the slave station address, the register address and the register length, then analyzing the data value of the equipment data points according to Modbus register address, function codes, data types, data length, a data analysis method, decimal place numbers, conversion relations and data offset information contained in the equipment data point information parameters, refreshing the data value of the equipment data points according to analysis results, packaging the data message according to the corresponding other uplink protocol requirements, and transmitting the data.
9. The Modbus data transparent transmission and distribution device of gateway equipment is characterized by comprising a configuration module, a data common transmission module, a data transparent transmission module and other protocol uplink transmission modules;
The configuration module is used for configuring communication nodes connected with the downlink equipment, equipment data points of the downlink equipment and an uplink platform in the network shutdown;
the data common transmission module sets up downlink data transmission and uplink data transmission to be carried out separately through a cache when one or two of an uplink serial port or a downlink serial port in a data acquisition thread do not adopt a Modbus transparent transmission protocol, and independently configures a communication node and an uplink platform;
The gateway machine forwards the serial port acquisition command issued by the uplink platform to the downlink serial port and monitors the downlink serial port response, and writes the downlink serial port response into the uplink serial port after receiving the downlink serial port response;
And if the downlink serial port response is a query response message and an uplink transmission requirement based on other uplink protocols about the query response message exists, analyzing the query response message, acquiring relevant parameters of equipment data points, analyzing data values of the equipment data points, refreshing the data values of the equipment data points according to analysis results, and finally packaging the data message and transmitting uplink according to the corresponding other uplink protocol requirements.
10. The Modbus data transmission and distribution device of gateway equipment according to claim 9, wherein the configuration module is used for presetting a communication mode and a communication protocol in a database dictionary table of the gateway equipment, the communication mode comprises serial communication, the communication protocol comprises a Modbus transmission protocol, the communication protocol of a downlink serial port is called a downlink Modbus transmission protocol, the communication protocol of an uplink serial port is called an uplink Modbus transmission protocol, a communication node connected with the downlink equipment, equipment data points of the downlink equipment and an uplink platform are configured in a network shutdown, the configuration information of the communication node comprises a communication node ID, a communication mode, a communication protocol and communication address information, the communication protocol is a downlink Modbus transmission protocol, the configuration information of the downlink equipment comprises a communication node ID, an equipment ID and an equipment data point information parameter, the configuration information of the equipment data points comprises an equipment ID and an equipment data point information parameter, the configuration information of the uplink platform comprises a platform ID and platform connection information, and the platform is an uplink Modbus protocol.
CN202411829294.9A 2024-12-12 2024-12-12 A gateway device Modbus data transparent transmission and protocol conversion method and device Pending CN119544821A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411829294.9A CN119544821A (en) 2024-12-12 2024-12-12 A gateway device Modbus data transparent transmission and protocol conversion method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411829294.9A CN119544821A (en) 2024-12-12 2024-12-12 A gateway device Modbus data transparent transmission and protocol conversion method and device

Publications (1)

Publication Number Publication Date
CN119544821A true CN119544821A (en) 2025-02-28

Family

ID=94700837

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411829294.9A Pending CN119544821A (en) 2024-12-12 2024-12-12 A gateway device Modbus data transparent transmission and protocol conversion method and device

Country Status (1)

Country Link
CN (1) CN119544821A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120416295A (en) * 2025-06-26 2025-08-01 江苏征途技术股份有限公司 A method and system for collecting electric meter data based on DLT698.45-2017 protocol

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109587158A (en) * 2018-12-19 2019-04-05 武汉理工光科股份有限公司 Transparent transmission and the adaptive method of Modbus protocol conversion both of which are realized in Network Serial Port
CN114741349A (en) * 2021-12-31 2022-07-12 杭州拓深科技有限公司 Multi-platform data transparent transmission 485 bus interaction method, medium, equipment and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109587158A (en) * 2018-12-19 2019-04-05 武汉理工光科股份有限公司 Transparent transmission and the adaptive method of Modbus protocol conversion both of which are realized in Network Serial Port
CN114741349A (en) * 2021-12-31 2022-07-12 杭州拓深科技有限公司 Multi-platform data transparent transmission 485 bus interaction method, medium, equipment and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120416295A (en) * 2025-06-26 2025-08-01 江苏征途技术股份有限公司 A method and system for collecting electric meter data based on DLT698.45-2017 protocol
CN120416295B (en) * 2025-06-26 2025-09-05 江苏征途技术股份有限公司 Ammeter data acquisition method and system based on DLT698.45-2017 protocol

Similar Documents

Publication Publication Date Title
CN110933146A (en) Data conversion method and device and server
CN103532998B (en) Protocol/data conversion device and method
CN105187283A (en) Industrial control network slave station communication method and device based on EtherCAT protocol
CN119544821A (en) A gateway device Modbus data transparent transmission and protocol conversion method and device
CN113162931A (en) Method for transmitting Modbus RTU protocol in wide area network
EP3160088B1 (en) Mib data broadcast using inexpensive method incorporating microcontroller and fpga
CN105187332A (en) Multi-source data transmission method based on Zigbee network
CN113452804B (en) On-board communication device based on VHDL language to realize ARP and UDP protocol data communication
CN212486527U (en) Slave station conversion device based on MODBUS protocol
CN115866081A (en) Industrial Ethernet protocol conversion method based on SOC
CN114726674A (en) FPGA-based PROFIBUS bus process data extraction method
JP2702031B2 (en) Satellite communication controller
CN109951458B (en) RapidIO/FC protocol conversion system and method applied to simulation ICP environment
CN119945982A (en) A high frame rate data transmission system based on FPGA
US20120307833A1 (en) Domain gateway control system and method thereof
CN119201803A (en) A single-channel multi-data source transmission system and method based on SRIO
CN103609194B (en) Communication device, communication system and communication method
CN111246459A (en) Wireless ad hoc network based on synchronous broadcast and data transmission method thereof
CN110213118B (en) FC network system and flow control method thereof
CN117376442B (en) Remote data concentrator protocol conversion method and equipment based on hardware processing architecture
CN218941111U (en) A microcontroller, electronic device and vehicle
CN120378465B (en) A distributed control system and control network
CN117880004B (en) A method and device for bridging a WIFI module to a wired Ethernet via an MCU
CN118714091B (en) Service processing method based on efficient analysis
CN117520244A (en) RS485 type sensor universal acquisition unit and data acquisition and processing method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination