升级小板添加结果返回,升级脚本可以修改波特率
This commit is contained in:
@@ -78,14 +78,15 @@ class updata_dlg(QObject):
|
||||
self.widget = QWidget()
|
||||
self.widget.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
|
||||
self.widget.resize(703, 409)
|
||||
self.widget.setWindowTitle("批检仪程序升级")
|
||||
self.widget.setWindowTitle("赋码仪程序升级")
|
||||
self.file_list_init()
|
||||
self.save_but_init()
|
||||
self.cmd_but_init()
|
||||
self.sstate_but_init()
|
||||
self.updatas_but_init()
|
||||
self.com_but_init()
|
||||
self.save_but_init()
|
||||
# self.updatas_but_init()
|
||||
# self.cmd_but_init()
|
||||
# self.sstate_but_init()
|
||||
self.com_init()
|
||||
self.combsp_init()
|
||||
self.widget.destroyed.connect(self.quit)
|
||||
self.failed_signal.connect(self.updata_failed)
|
||||
self.cmd=0
|
||||
@@ -112,7 +113,7 @@ class updata_dlg(QObject):
|
||||
def com_but_init(self):
|
||||
self.com_but = QPushButton(self.widget)
|
||||
self.com_but.setObjectName(u"com_but")
|
||||
self.com_but.setGeometry(QRect(450, 10, 93, 28))
|
||||
self.com_but.setGeometry(QRect(590, 10, 93, 28))
|
||||
self.com_but.setText("打开端口")
|
||||
self.com_but.clicked.connect(self.com_but_clicked)
|
||||
|
||||
@@ -133,6 +134,14 @@ class updata_dlg(QObject):
|
||||
self.cmd_but.setText("升级MCU")
|
||||
self.cmd_but.clicked.connect(self.cmd_but_clicked)
|
||||
|
||||
# 初始化升级小板按钮
|
||||
def updatas_but_init(self):
|
||||
self.updatas_but = QPushButton(self.widget)
|
||||
self.updatas_but.setObjectName(u"updatas_but")
|
||||
self.updatas_but.setGeometry(QRect(590, 100, 93, 28))
|
||||
self.updatas_but.setText("升级小板")
|
||||
self.updatas_but.clicked.connect(self.updatas_but_clicked)
|
||||
|
||||
# 初始化在线状态按钮
|
||||
def sstate_but_init(self):
|
||||
self.sstate_but = QPushButton(self.widget)
|
||||
@@ -141,19 +150,11 @@ class updata_dlg(QObject):
|
||||
self.sstate_but.setText("MCU在线状态")
|
||||
self.sstate_but.clicked.connect(self.sstate_but_clicked)
|
||||
|
||||
# 初始化升级小板按钮
|
||||
def updatas_but_init(self):
|
||||
self.updatas_but = QPushButton(self.widget)
|
||||
self.updatas_but.setObjectName(u"updatas_but")
|
||||
self.updatas_but.setGeometry(QRect(590, 180, 93, 28))
|
||||
self.updatas_but.setText("升级小板")
|
||||
self.updatas_but.clicked.connect(self.updatas_but_clicked)
|
||||
|
||||
# com口
|
||||
def com_init(self):
|
||||
self.com = QComboBox(self.widget)
|
||||
self.com.setObjectName(u"com")
|
||||
self.com.setGeometry(QRect(100, 10, 300, 21))
|
||||
self.com.setGeometry(QRect(85, 10, 300, 25))
|
||||
self.com.setEditable(True)
|
||||
self.com.currentIndexChanged.connect(self.com_changed)
|
||||
self.com.addItem("utcp:7777")
|
||||
@@ -163,9 +164,22 @@ class updata_dlg(QObject):
|
||||
self.com.addItem(comport.name+":"+comport.description)
|
||||
self.com_label = QLabel(self.widget)
|
||||
self.com_label.setObjectName(u"label")
|
||||
self.com_label.setGeometry(QRect(30, 10, 72, 15))
|
||||
self.com_label.setGeometry(QRect(30, 16, 72, 15))
|
||||
self.com_label.setText("COM口:")
|
||||
|
||||
# 选择波特率
|
||||
def combsp_init(self):
|
||||
self.combsp = QComboBox(self.widget)
|
||||
self.combsp.setObjectName(u"combsp")
|
||||
self.combsp.setGeometry(QRect(470, 10, 80, 25))
|
||||
self.combsp.setEditable(True)
|
||||
self.combsp.addItem("115200")
|
||||
self.combsp.addItem("9600")
|
||||
self.combsp_label = QLabel(self.widget)
|
||||
self.combsp_label.setObjectName(u"label")
|
||||
self.combsp_label.setGeometry(QRect(410, 16, 72, 15))
|
||||
self.combsp_label.setText("波特率:")
|
||||
|
||||
# 显示消息框
|
||||
def show_msg(self,msg:str):
|
||||
m=QMessageBox(self.widget)
|
||||
@@ -261,6 +275,7 @@ class updata_dlg(QObject):
|
||||
self.port.send(self.cmd,d)
|
||||
except Exception as e:
|
||||
print("com not open")
|
||||
self.show_msg("端口未打开")
|
||||
del self.handle_
|
||||
w.close()
|
||||
return
|
||||
@@ -301,8 +316,10 @@ class updata_dlg(QObject):
|
||||
def updatas_but_clicked(self):
|
||||
print("updatas_but clicked.")
|
||||
try:
|
||||
self.port.send_str("updatas 1,2,3,4,5,6,7,8,9,10".encode("utf-8"))
|
||||
self.port.send_str("updatas 1,2,3,4,5,6,7,8,9,10")
|
||||
self.show_msg("已发送升级指令,请留意小板升级情况")
|
||||
except Exception as e:
|
||||
self.show_msg("命令发送失败")
|
||||
print("com not open")
|
||||
print(str(e))
|
||||
|
||||
@@ -353,6 +370,10 @@ class updata_dlg(QObject):
|
||||
def com_thread(self):
|
||||
self.port=prottcp.protu()
|
||||
item=self.com.itemText(self.com.currentIndex())
|
||||
bsp=self.combsp.itemText(self.combsp.currentIndex())
|
||||
com=item.split(":")[0]
|
||||
if(com!="utcp"):
|
||||
item=com+":"+bsp
|
||||
print("item text:",item)
|
||||
if(self.port.init(item)==False):
|
||||
print("init port failed.")
|
||||
|
Reference in New Issue
Block a user