RS485串口继电器modbus RTU读写通信调试软件工具和python源码

Posted i数采物联-上海/河南

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RS485串口继电器modbus RTU读写通信调试软件工具和python源码相关的知识,希望对你有一定的参考价值。


源码程序开发相关环境:
PyQt55.15.2
PyQt5-sip
12.10.1
pyserial3.5
pywin32-ctypes
0.2.0
requests2.28.0
typing-extensions
4.2.0
urllib31.26.9
yarg
0.1.9
zipp==3.8.0
主界面部分代码:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'untitled.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(700, 906)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox.setGeometry(QtCore.QRect(40, 20, 301, 101))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.groupBox.setFont(font)
        self.groupBox.setStyleSheet("")
        self.groupBox.setObjectName("groupBox")
        self.pushButton_7 = QtWidgets.QPushButton(self.groupBox)
        self.pushButton_7.setGeometry(QtCore.QRect(40, 22, 91, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.pushButton_7.setFont(font)
        self.pushButton_7.setStyleSheet("")
        self.pushButton_7.setObjectName("pushButton_7")
        self.pushButton_8 = QtWidgets.QPushButton(self.groupBox)
        self.pushButton_8.setGeometry(QtCore.QRect(170, 20, 91, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.pushButton_8.setFont(font)
        self.pushButton_8.setStyleSheet("")
        self.pushButton_8.setObjectName("pushButton_8")
        self.pushButton_9 = QtWidgets.QPushButton(self.groupBox)
        self.pushButton_9.setGeometry(QtCore.QRect(170, 60, 91, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.pushButton_9.setFont(font)
        self.pushButton_9.setStyleSheet("")
        self.pushButton_9.setObjectName("pushButton_9")
        self.label_16 = QtWidgets.QLabel(self.groupBox)
        self.label_16.setGeometry(QtCore.QRect(40, 60, 71, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.label_16.setFont(font)
        self.label_16.setStyleSheet("")
        self.label_16.setObjectName("label_16")
        self.label_17 = QtWidgets.QLabel(self.groupBox)
        self.label_17.setGeometry(QtCore.QRect(110, 60, 54, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.label_17.setFont(font)
        self.label_17.setStyleSheet("")
        self.label_17.setObjectName("label_17")
        self.groupBox_2 = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox_2.setGeometry(QtCore.QRect(350, 310, 311, 161))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.groupBox_2.setFont(font)
        self.groupBox_2.setStyleSheet("")
        self.groupBox_2.setObjectName("groupBox_2")
        self.lineEdit_1 = QtWidgets.QLineEdit(self.groupBox_2)
        self.lineEdit_1.setGeometry(QtCore.QRect(20, 50, 71, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.lineEdit_1.setFont(font)
        self.lineEdit_1.setStyleSheet("")
        self.lineEdit_1.setObjectName("lineEdit_1")
        self.lineEdit_2 = QtWidgets.QLineEdit(self.groupBox_2)
        self.lineEdit_2.setGeometry(QtCore.QRect(100, 50, 61, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.lineEdit_2.setFont(font)
        self.lineEdit_2.setStyleSheet("")
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.lineEdit_3 = QtWidgets.QLineEdit(self.groupBox_2)
        self.lineEdit_3.setGeometry(QtCore.QRect(170, 50, 61, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.lineEdit_3.setFont(font)
        self.lineEdit_3.setStyleSheet("")
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.label = QtWidgets.QLabel(self.groupBox_2)
        self.label.setGeometry(QtCore.QRect(20, 21, 81, 21))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(8)
        self.label.setFont(font)
        self.label.setStyleSheet("")
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.groupBox_2)
        self.label_2.setGeometry(QtCore.QRect(100, 21, 71, 21))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(8)
        self.label_2.setFont(font)
        self.label_2.setStyleSheet("")
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(self.groupBox_2)
        self.label_3.setGeometry(QtCore.QRect(170, 21, 81, 21))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(8)
        self.label_3.setFont(font)
        self.label_3.setStyleSheet("")
        self.label_3.setObjectName("label_3")
        self.pushButton_5 = QtWidgets.QPushButton(self.groupBox_2)
        self.pushButton_5.setGeometry(QtCore.QRect(240, 50, 51, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.pushButton_5.setFont(font)
        self.pushButton_5.setStyleSheet("")
        self.pushButton_5.setObjectName("pushButton_5")
        self.lineEdit_4 = QtWidgets.QLineEdit(self.groupBox_2)
        self.lineEdit_4.setGeometry(QtCore.QRect(20, 110, 271, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(8)
        self.lineEdit_4.setFont(font)
        self.lineEdit_4.setStyleSheet("")
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.label_4 = QtWidgets.QLabel(self.groupBox_2)
        self.label_4.setGeometry(QtCore.QRect(20, 85, 71, 21))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.label_4.setFont(font)
        self.label_4.setStyleSheet("")
        self.label_4.setObjectName("label_4")
        self.groupBox_3 = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox_3.setGeometry(QtCore.QRect(40, 310, 301, 161))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.groupBox_3.setFont(font)
        self.groupBox_3.setStyleSheet("")
        self.groupBox_3.setObjectName("groupBox_3")
        self.label_5 = QtWidgets.QLabel(self.groupBox_3)
        self.label_5.setGeometry(QtCore.QRect(20, 25, 81, 21))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(8)
        self.label_5.setFont(font)
        self.label_5.setStyleSheet("")
        self.label_5.setObjectName("label_5")
        self.lineEdit_5 = QtWidgets.QLineEdit(self.groupBox_3)
        self.lineEdit_5.setGeometry(QtCore.QRect(20, 50, 71, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.lineEdit_5.setFont(font)
        self.lineEdit_5.setStyleSheet("")
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.label_6 = QtWidgets.QLabel(self.groupBox_3)
        self.label_6.setGeometry(QtCore.QRect(170, 25, 61, 21))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(8)
        self.label_6.setFont(font)
        self.label_6.setStyleSheet("")
        self.label_6.setObjectName("label_6")
        self.pushButton_6 = QtWidgets.QPushButton(self.groupBox_3)
        self.pushButton_6.setGeometry(QtCore.QRect(230, 50, 51, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.pushButton_6.setFont(font)
        self.pushButton_6.setStyleSheet("")
        self.pushButton_6.setObjectName("pushButton_6")
        self.lineEdit_6 = QtWidgets.QLineEdit(self.groupBox_3)
        self.lineEdit_6.setGeometry(QtCore.QRect(100, 50, 61, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.lineEdit_6.setFont(font)
        self.lineEdit_6.setStyleSheet("")
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.lineEdit_7 = QtWidgets.QLineEdit(self.groupBox_3)
        self.lineEdit_7.setGeometry(QtCore.QRect(170, 50, 51, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.lineEdit_7.setFont(font)
        self.lineEdit_7.setStyleSheet("")
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.label_7 = QtWidgets.QLabel(self.groupBox_3)
        self.label_7.setGeometry(QtCore.QRect(100, 25, 71, 21))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(8)
        self.label_7.setFont(font)
        self.label_7.setStyleSheet("")
        self.label_7.setObjectName("label_7")
        self.label_8 = QtWidgets.QLabel(self.groupBox_3)
        self.label_8.setGeometry(QtCore.QRect(20, 85, 71, 21))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.label_8.setFont(font)
        self.label_8.setStyleSheet("")
        self.label_8.setObjectName("label_8")
        self.lineEdit_8 = QtWidgets.QLineEdit(self.groupBox_3)
        self.lineEdit_8.setGeometry(QtCore.QRect(20, 110, 261, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.lineEdit_8.setFont(font)
        self.lineEdit_8.setStyleSheet("")
        self.lineEdit_8.setObjectName("lineEdit_8")
        self.groupBox_5 = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox_5.setGeometry(QtCore.QRect(40, 610, 301, 261))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.groupBox_5.setFont(font)
        self.groupBox_5.setStyleSheet("")
        self.groupBox_5.setObjectName("groupBox_5")
        self.textBrowser = QtWidgets.QTextBrowser(self.groupBox_5)
        self.textBrowser.setGeometry(QtCore.QRect(10, 30, 281, 121))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(8)
        self.textBrowser.setFont(font)
        self.textBrowser.setStyleSheet("")
        self.textBrowser.setObjectName("textBrowser")
        self.groupBox_8 = QtWidgets.QGroupBox(self.groupBox_5)
        self.groupBox_8.setGeometry(QtCore.QRect(10, 160, 281, 91))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.groupBox_8.setFont(font)
        self.groupBox_8.setStyleSheet("")
        self.groupBox_8.setObjectName("groupBox_8")
        self.lineEdit_14 = QtWidgets.QLineEdit(self.groupBox_8)
        self.lineEdit_14.setGeometry(QtCore.QRect(10, 20, 261, 31))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.lineEdit_14.setFont(font)
        self.lineEdit_14.setStyleSheet("")
        self.lineEdit_14.setObjectName("lineEdit_14")
        self.pushButton_3 = QtWidgets.QPushButton(self.groupBox_8)
        self.pushButton_3.setGeometry(QtCore.QRect(10, 60, 75, 23))
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        self.pushButton_3.setFont(font)
        self.pushButton_3.setStyleSheet("")
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_4 = QtWidgets.QPushButton(self.groupBox_8)
        self.pushButton_4.setGeometry(QtCore.QRect(1

以上是关于RS485串口继电器modbus RTU读写通信调试软件工具和python源码的主要内容,如果未能解决你的问题,请参考以下文章

串口通信modbus协议格式查询方式下怎么读写寄存器

普通PC通过USB转485串口 ModBus-RTU通信协议控制伺服电机

标准modbus-rtu通信协议是485通信吗?

RS485 MODBUS RTU通信协议

泓格WINPAC主机与第三方模块rs 485 modbus rtu通信测试

用java(modbus4j)如何给继电器发送RTU消息?