feat: DLD154Tool Modbus 复位 MCU 按钮 (HR 0x0012=0x2C2C, 对齐 700BS 0x2C)
This commit is contained in:
@@ -31,6 +31,7 @@ from protocol_700bs import (
|
||||
from protocol_modbus import (
|
||||
build_read_input_regs, build_read_holding_regs, build_read_discrete_inputs,
|
||||
build_write_single_reg, build_write_multiple_regs, build_report_slave_id,
|
||||
build_reset_mcu,
|
||||
parse_response, is_active_report,
|
||||
FullDataBlock,
|
||||
)
|
||||
@@ -380,6 +381,11 @@ class TabModbus(QWidget):
|
||||
btn_write.clicked.connect(self._write_single)
|
||||
hl.addWidget(btn_write)
|
||||
|
||||
btn_reset = QPushButton("复位 MCU (0x0012=0x2C2C)")
|
||||
btn_reset.setStyleSheet("color: red; font-weight: bold;")
|
||||
btn_reset.clicked.connect(self._send_reset)
|
||||
hl.addWidget(btn_reset)
|
||||
|
||||
layout.addWidget(gb_write)
|
||||
|
||||
# ── 主动上报控制 ──
|
||||
@@ -458,6 +464,12 @@ class TabModbus(QWidget):
|
||||
self.send_request.emit(build_write_single_reg(self._addr(), reg, val))
|
||||
self.log_signal.emit(f"[Modbus] FC 0x06 write reg=0x{reg:04X} val=0x{val:04X}")
|
||||
|
||||
def _send_reset(self):
|
||||
if QMessageBox.question(self, "确认", "发送复位 MCU 命令 (HR 0x0012=0x2C2C)?",
|
||||
QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes:
|
||||
self.send_request.emit(build_reset_mcu(self._addr()))
|
||||
self.log_signal.emit("[Modbus] 发送复位 MCU 命令 (HR 0x0012=0x2C2C)")
|
||||
|
||||
def _toggle_auto_report(self, checked: bool):
|
||||
self._auto_report_enabled = checked
|
||||
val = 1 if checked else 0
|
||||
|
||||
@@ -111,6 +111,11 @@ def build_report_slave_id(addr: int) -> bytes:
|
||||
return build_request(addr, 0x11, b'')
|
||||
|
||||
|
||||
def build_reset_mcu(addr: int) -> bytes:
|
||||
"""FC 0x06 — 写 HR 0x0012=0x2C2C 复位 MCU"""
|
||||
return build_write_single_reg(addr, 0x0012, 0x2C2C)
|
||||
|
||||
|
||||
# ══════════════════════════════════════════════════
|
||||
# 响应解析
|
||||
# ══════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user