|
@@ -1,5 +1,5 @@
|
|
|
#!/usr/bin/env python3
|
|
#!/usr/bin/env python3
|
|
|
-"""6400V2.0 scope test 1.0.3: SET35 / GET86, 500Hz PWM, no shutdown command."""
|
|
|
|
|
|
|
+"""6400V2.0 scope test 1.0.5: SET35 / GET86, 20Hz PWM, fan 5s 50%/0% toggle, no shutdown command."""
|
|
|
import argparse
|
|
import argparse
|
|
|
import binascii
|
|
import binascii
|
|
|
import datetime as dt
|
|
import datetime as dt
|
|
@@ -13,10 +13,50 @@ import sys
|
|
|
import time
|
|
import time
|
|
|
import unicodedata
|
|
import unicodedata
|
|
|
|
|
|
|
|
-SCRIPT_VERSION = "1.0.3"
|
|
|
|
|
|
|
+SCRIPT_VERSION = "1.0.4"
|
|
|
BOX_WIDTH = 90
|
|
BOX_WIDTH = 90
|
|
|
-DEFAULT_PORT = "/dev/serial/by-path/pci-0000:00:14.0-usb-0:2:1.0-port0"
|
|
|
|
|
-DUTIES = bytes(range(1, 36))
|
|
|
|
|
|
|
+DEFAULT_PORT = "/dev/serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0"
|
|
|
|
|
+FALLBACK_USB1_PORTS = (
|
|
|
|
|
+ "/dev/serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0",
|
|
|
|
|
+ "/dev/serial/by-path/pci-0000:00:14.0-usb-0:2:1.0-port0",
|
|
|
|
|
+ "/dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0",
|
|
|
|
|
+ "/dev/ttyUSB1",
|
|
|
|
|
+)
|
|
|
|
|
+PTC_DUTIES = bytes(range(1, 25))
|
|
|
|
|
+SSR_DUTIES = bytes((33, 34, 35))
|
|
|
|
|
+FAN_DUTY_HIGH = 50
|
|
|
|
|
+FAN_DUTY_LOW = 0
|
|
|
|
|
+FAN_HOLD_SECONDS = 5.0
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def resolve_port(port):
|
|
|
|
|
+ real = os.path.realpath(port)
|
|
|
|
|
+ if real == "/dev/ttyUSB0" or "BG00WPDX" in str(port):
|
|
|
|
|
+ raise RuntimeError("USB0属于其他项目,拒绝打开")
|
|
|
|
|
+ if os.path.exists(port):
|
|
|
|
|
+ return port
|
|
|
|
|
+ if port in FALLBACK_USB1_PORTS:
|
|
|
|
|
+ by_path_dir = Path("/dev/serial/by-path")
|
|
|
|
|
+ candidates = list(FALLBACK_USB1_PORTS)
|
|
|
|
|
+ if by_path_dir.is_dir():
|
|
|
|
|
+ candidates.extend(str(p) for p in sorted(by_path_dir.iterdir()))
|
|
|
|
|
+ for cand in candidates:
|
|
|
|
|
+ if os.path.exists(cand) and os.path.realpath(cand) == "/dev/ttyUSB1":
|
|
|
|
|
+ return cand
|
|
|
|
|
+ return port
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def fan_duty_for_elapsed(elapsed=0.0):
|
|
|
|
|
+ phase = int((max(0.0, float(elapsed)) + 1e-9) // FAN_HOLD_SECONDS) % 2
|
|
|
|
|
+ return FAN_DUTY_HIGH if phase == 0 else FAN_DUTY_LOW
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def build_duties(fan_duty=FAN_DUTY_HIGH):
|
|
|
|
|
+ return PTC_DUTIES + bytes([fan_duty]) * 8 + SSR_DUTIES
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+DUTIES = build_duties(FAN_DUTY_HIGH)
|
|
|
|
|
+DUTIES_FAN_ZERO = build_duties(FAN_DUTY_LOW)
|
|
|
CT_CONNECTORS = ("U6-local", "CON53", "CON55", "CON56", "CON57",
|
|
CT_CONNECTORS = ("U6-local", "CON53", "CON55", "CON56", "CON57",
|
|
|
"CON79", "CON80", "CON81", "CON82")
|
|
"CON79", "CON80", "CON81", "CON82")
|
|
|
CT_ROLES = ("U6芯片本地", "腔1进风口", "腔1出风口", "腔2进风口", "腔2出风口",
|
|
CT_ROLES = ("U6芯片本地", "腔1进风口", "腔1出风口", "腔2进风口", "腔2出风口",
|
|
@@ -117,16 +157,16 @@ def output_rows():
|
|
|
rows = []
|
|
rows = []
|
|
|
for i in range(24):
|
|
for i in range(24):
|
|
|
rows.append((i, f"PTC{i:02d} 腔{i // 6 + 1} 第{i % 6 + 1}路",
|
|
rows.append((i, f"PTC{i:02d} 腔{i // 6 + 1} 第{i % 6 + 1}路",
|
|
|
- PTC_PINS[i], PTC_BALLS[i], 500))
|
|
|
|
|
|
|
+ PTC_PINS[i], PTC_BALLS[i], 20))
|
|
|
for j in range(8):
|
|
for j in range(8):
|
|
|
role = "进风" if j < 4 else "排风"
|
|
role = "进风" if j < 4 else "排风"
|
|
|
rows.append((24 + j, f"腔{j % 4 + 1}{role}",
|
|
rows.append((24 + j, f"腔{j % 4 + 1}{role}",
|
|
|
- FAN_PINS[j], FAN_BALLS[j], 500))
|
|
|
|
|
|
|
+ FAN_PINS[j], FAN_BALLS[j], 20))
|
|
|
for j, (name, pin, ball) in enumerate((
|
|
for j, (name, pin, ball) in enumerate((
|
|
|
("SSR1 腔1", "CON165.1", "E14"),
|
|
("SSR1 腔1", "CON165.1", "E14"),
|
|
|
("SSR2 腔2+3共用", "CON165.2", "E8"),
|
|
("SSR2 腔2+3共用", "CON165.2", "E8"),
|
|
|
("SSR4 腔4", "CON165.4", "D9"))):
|
|
("SSR4 腔4", "CON165.4", "D9"))):
|
|
|
- rows.append((32 + j, name, pin, ball, 500))
|
|
|
|
|
|
|
+ rows.append((32 + j, name, pin, ball, 20))
|
|
|
return rows
|
|
return rows
|
|
|
|
|
|
|
|
|
|
|
|
@@ -171,13 +211,13 @@ def show_map(style=None):
|
|
|
st = style or Style(enabled=sys.stdout.isatty() and not os.environ.get("NO_COLOR"))
|
|
st = style or Style(enabled=sys.stdout.isatty() and not os.environ.get("NO_COLOR"))
|
|
|
top, mid, sep, bot, row, _ = _box_helpers(st)
|
|
top, mid, sep, bot, row, _ = _box_helpers(st)
|
|
|
|
|
|
|
|
- print(top(f"6400V2.0 示波器与温度测试 (脚本 v{SCRIPT_VERSION} / 适配固件 3.0.3)"))
|
|
|
|
|
|
|
+ print(top(f"6400V2.0 示波器与温度测试 (脚本 v{SCRIPT_VERSION} / 适配固件 3.0.4)"))
|
|
|
print(row(
|
|
print(row(
|
|
|
f"{st.bold('协议')}: SET35 / GET86 (921600 8N1) "
|
|
f"{st.bold('协议')}: SET35 / GET86 (921600 8N1) "
|
|
|
- f"{st.bold('统一频率')}: 500Hz (周期 2.00ms, 1% = 20µs)"
|
|
|
|
|
|
|
+ f"{st.bold('统一频率')}: 20Hz (周期 50.00ms, 1% = 0.50ms)"
|
|
|
))
|
|
))
|
|
|
print(row(
|
|
print(row(
|
|
|
- f"{st.bold('规则')}: SET字节从0编号,35路占空比 = 字节编号 + 1 (%);退出仅停发等待30s看门狗"
|
|
|
|
|
|
|
+ f"{st.bold('规则')}: PTC=1~24%,风扇8路=5秒50%/5秒0%交替往复,SSR=33~35%;退出仅停发等30s看门狗"
|
|
|
))
|
|
))
|
|
|
print(mid("35路 PWM 输出与测量点映射表"))
|
|
print(mid("35路 PWM 输出与测量点映射表"))
|
|
|
header = (
|
|
header = (
|
|
@@ -198,17 +238,21 @@ def show_map(style=None):
|
|
|
print(row(st.bold_yellow("▶ PTC 加热片 (24路) — 连接器脚为功率正端;示波器读数须结合测量位置与板上驱动极性")))
|
|
print(row(st.bold_yellow("▶ PTC 加热片 (24路) — 连接器脚为功率正端;示波器读数须结合测量位置与板上驱动极性")))
|
|
|
elif i == 24:
|
|
elif i == 24:
|
|
|
print(sep())
|
|
print(sep())
|
|
|
- print(row(st.bold_yellow("▶ 风扇 PWM (8路) — 连接器高电平占空比=D;FPGA引脚经2N7002反相,低电平占空比=D")))
|
|
|
|
|
|
|
+ print(row(st.bold_yellow("▶ 风扇 PWM (8路) — 默认5s 50%/5s 0%交替;接口高电平=D,FPGA脚经2N7002反相低电平=D")))
|
|
|
elif i == 32:
|
|
elif i == 32:
|
|
|
print(sep())
|
|
print(sep())
|
|
|
print(row(st.bold_yellow("▶ SSR 加热块 (3路) — CON165为3.3V控制端;24V功率端空载测波形建议接330Ω/5W假负载")))
|
|
print(row(st.bold_yellow("▶ SSR 加热块 (3路) — CON165为3.3V控制端;24V功率端空载测波形建议接330Ω/5W假负载")))
|
|
|
|
|
|
|
|
duty = DUTIES[i]
|
|
duty = DUTIES[i]
|
|
|
- pulse_us = duty * 20
|
|
|
|
|
|
|
+ pulse_ms = duty * 0.5
|
|
|
idx_s = pad(f"{i:2d}", 7, "center")
|
|
idx_s = pad(f"{i:2d}", 7, "center")
|
|
|
name_s = pad(name, 16)
|
|
name_s = pad(name, 16)
|
|
|
- duty_s = pad(f"{duty:2d}%", 6, "right")
|
|
|
|
|
- pulse_s = pad(f"{pulse_us:3d}µs", 8, "right")
|
|
|
|
|
|
|
+ if 24 <= i < 32:
|
|
|
|
|
+ duty_s = pad("50%/0%", 6, "right")
|
|
|
|
|
+ pulse_s = pad("25.0/0ms", 8, "right")
|
|
|
|
|
+ else:
|
|
|
|
|
+ duty_s = pad(f"{duty:2d}%", 6, "right")
|
|
|
|
|
+ pulse_s = pad(f"{pulse_ms:5.1f}ms", 8, "right")
|
|
|
hz_s = pad(f"{hz:3d}Hz", 6, "right")
|
|
hz_s = pad(f"{hz:3d}Hz", 6, "right")
|
|
|
pin_s = pad(pin, 9)
|
|
pin_s = pad(pin, 9)
|
|
|
ball_s = pad(ball, 5)
|
|
ball_s = pad(ball, 5)
|
|
@@ -359,10 +403,12 @@ class Link:
|
|
|
frames.append((kind, payload))
|
|
frames.append((kind, payload))
|
|
|
return frames
|
|
return frames
|
|
|
|
|
|
|
|
- def request(self, kind, end):
|
|
|
|
|
|
|
+ def request(self, kind, end, payload=None):
|
|
|
if time.monotonic() >= end:
|
|
if time.monotonic() >= end:
|
|
|
raise TimeoutError("运行时间结束")
|
|
raise TimeoutError("运行时间结束")
|
|
|
- raw = frame(kind, DUTIES if kind == 1 else b"")
|
|
|
|
|
|
|
+ if payload is None:
|
|
|
|
|
+ payload = DUTIES if kind == 1 else b""
|
|
|
|
|
+ raw = frame(kind, payload)
|
|
|
self.serial.write(raw)
|
|
self.serial.write(raw)
|
|
|
self.event("TX", type=f"{kind:02X}", hex=raw.hex(" "))
|
|
self.event("TX", type=f"{kind:02X}", hex=raw.hex(" "))
|
|
|
limit = min(end, time.monotonic() + 0.7)
|
|
limit = min(end, time.monotonic() + 0.7)
|
|
@@ -410,7 +456,8 @@ def styled_temp(value, style, width=3):
|
|
|
|
|
|
|
|
def render_live_panel(style, *, cycles, total_cycles, elapsed, remaining,
|
|
def render_live_panel(style, *, cycles, total_cycles, elapsed, remaining,
|
|
|
read_only, matches, outputs, ct, errors, bad_crc,
|
|
read_only, matches, outputs, ct, errors, bad_crc,
|
|
|
- diag, diag_slots, last_error, last_ack_age=None):
|
|
|
|
|
|
|
+ diag, diag_slots, last_error, last_ack_age=None,
|
|
|
|
|
+ expected_outputs=None):
|
|
|
top, mid, _, bot, row, split2 = _box_helpers(style)
|
|
top, mid, _, bot, row, split2 = _box_helpers(style)
|
|
|
total_dur = max(0.001, elapsed + remaining)
|
|
total_dur = max(0.001, elapsed + remaining)
|
|
|
ratio = min(1.0, elapsed / total_dur)
|
|
ratio = min(1.0, elapsed / total_dur)
|
|
@@ -449,22 +496,30 @@ def render_live_panel(style, *, cycles, total_cycles, elapsed, remaining,
|
|
|
f"错误: {err_str} │ 丢弃CRC: {crc_str} │ 看门狗: {watchdog}",
|
|
f"错误: {err_str} │ 丢弃CRC: {crc_str} │ 看门狗: {watchdog}",
|
|
|
left_w=33,
|
|
left_w=33,
|
|
|
),
|
|
),
|
|
|
- mid("35路 PWM 控制回读核对 (500Hz / 周期 2.00ms)"),
|
|
|
|
|
|
|
+ mid("35路 PWM 控制回读核对 (20Hz / 周期 50.00ms)"),
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
if outputs and len(outputs) == 35:
|
|
if outputs and len(outputs) == 35:
|
|
|
- ptc_ok = list(outputs[:24]) == list(DUTIES[:24])
|
|
|
|
|
- fan_ok = list(outputs[24:32]) == list(DUTIES[24:32])
|
|
|
|
|
|
|
+ ptc_ok = list(outputs[:24]) == list(PTC_DUTIES)
|
|
|
|
|
+ fan_vals = list(outputs[24:32])
|
|
|
|
|
+ if expected_outputs is not None and len(expected_outputs) == 35:
|
|
|
|
|
+ fan_ok = fan_vals == list(expected_outputs[24:32])
|
|
|
|
|
+ else:
|
|
|
|
|
+ fan_ok = fan_vals in ([FAN_DUTY_HIGH] * 8, [FAN_DUTY_LOW] * 8)
|
|
|
ssr_vals = list(outputs[32:35])
|
|
ssr_vals = list(outputs[32:35])
|
|
|
- ssr_ok = ssr_vals == list(DUTIES[32:35])
|
|
|
|
|
|
|
+ ssr_ok = ssr_vals == list(SSR_DUTIES)
|
|
|
b1 = style.green("✓") if ptc_ok or read_only else style.red("✗")
|
|
b1 = style.green("✓") if ptc_ok or read_only else style.red("✗")
|
|
|
b2 = style.green("✓") if fan_ok or read_only else style.red("✗")
|
|
b2 = style.green("✓") if fan_ok or read_only else style.red("✗")
|
|
|
b3 = style.green("✓") if ssr_ok or read_only else style.red("✗")
|
|
b3 = style.green("✓") if ssr_ok or read_only else style.red("✗")
|
|
|
if matches is None:
|
|
if matches is None:
|
|
|
b1 = b2 = b3 = style.yellow("?")
|
|
b1 = b2 = b3 = style.yellow("?")
|
|
|
|
|
+ if len(set(fan_vals)) == 1:
|
|
|
|
|
+ fan_text = f"进/排风8路: {fan_vals[0]:2d}% ({fan_vals[0]*20:4d}µs, 5s 50/0%) {b2}"
|
|
|
|
|
+ else:
|
|
|
|
|
+ fan_text = f"进/排风8路: {outputs[24]:2d}%~{outputs[31]:2d}% ({outputs[24]*20:4d}~{outputs[31]*20:4d}µs) {b2}"
|
|
|
lines.append(split2(
|
|
lines.append(split2(
|
|
|
f"PTC00..23 : 1%~24% ( 20~480µs) {b1}",
|
|
f"PTC00..23 : 1%~24% ( 20~480µs) {b1}",
|
|
|
- f"进/排风8路: {outputs[24]:2d}%~{outputs[31]:2d}% ({outputs[24]*20:3d}~{outputs[31]*20:3d}µs) {b2}",
|
|
|
|
|
|
|
+ fan_text,
|
|
|
left_w=41,
|
|
left_w=41,
|
|
|
))
|
|
))
|
|
|
lines.append(row(
|
|
lines.append(row(
|
|
@@ -525,7 +580,9 @@ def render_live_panel(style, *, cycles, total_cycles, elapsed, remaining,
|
|
|
|
|
|
|
|
|
|
|
|
|
def run(args):
|
|
def run(args):
|
|
|
- if os.path.realpath(args.port) == "/dev/ttyUSB0":
|
|
|
|
|
|
|
+ port = resolve_port(args.port)
|
|
|
|
|
+ real_port = os.path.realpath(port)
|
|
|
|
|
+ if real_port == "/dev/ttyUSB0":
|
|
|
raise RuntimeError("USB0属于其他项目,拒绝打开")
|
|
raise RuntimeError("USB0属于其他项目,拒绝打开")
|
|
|
is_tty = sys.stdout.isatty()
|
|
is_tty = sys.stdout.isatty()
|
|
|
use_color = is_tty and not os.environ.get("NO_COLOR") and not getattr(args, "no_color", False)
|
|
use_color = is_tty and not os.environ.get("NO_COLOR") and not getattr(args, "no_color", False)
|
|
@@ -537,8 +594,7 @@ def run(args):
|
|
|
(dt.datetime.now().strftime("%Y%m%d-%H%M%S-%f") + ".jsonl"))
|
|
(dt.datetime.now().strftime("%Y%m%d-%H%M%S-%f") + ".jsonl"))
|
|
|
log_path.parent.mkdir(parents=True, exist_ok=True)
|
|
log_path.parent.mkdir(parents=True, exist_ok=True)
|
|
|
show_map(style=style)
|
|
show_map(style=style)
|
|
|
- real_port = os.path.realpath(args.port)
|
|
|
|
|
- print(f"{style.bold('串口')}:{args.port} -> {style.cyan(real_port)} / 921600 8N1")
|
|
|
|
|
|
|
+ print(f"{style.bold('串口')}:{port} -> {style.cyan(real_port)} / 921600 8N1")
|
|
|
print(f"{style.bold('计划')}:运行 {style.bold(f'{args.minutes:g}')} 分钟,每 {style.bold(f'{args.interval:g}')} 秒一轮;日志:{style.dim(log_path)}")
|
|
print(f"{style.bold('计划')}:运行 {style.bold(f'{args.minutes:g}')} 分钟,每 {style.bold(f'{args.interval:g}')} 秒一轮;日志:{style.dim(log_path)}")
|
|
|
print(f"{style.yellow('提示')}:Ctrl+C停止。结束只关闭串口,不发归零/恢复命令;最后有效命令后约30秒由固件超时。", flush=True)
|
|
print(f"{style.yellow('提示')}:Ctrl+C停止。结束只关闭串口,不发归零/恢复命令;最后有效命令后约30秒由固件超时。", flush=True)
|
|
|
if live_mode:
|
|
if live_mode:
|
|
@@ -551,6 +607,7 @@ def run(args):
|
|
|
next_due = start
|
|
next_due = start
|
|
|
prev_panel_lines = 0
|
|
prev_panel_lines = 0
|
|
|
last_outputs = None
|
|
last_outputs = None
|
|
|
|
|
+ last_expected_outputs = DUTIES
|
|
|
last_ct = None
|
|
last_ct = None
|
|
|
last_matches = None
|
|
last_matches = None
|
|
|
last_error = None
|
|
last_error = None
|
|
@@ -582,6 +639,7 @@ def run(args):
|
|
|
diag_slots=link.diag_slots,
|
|
diag_slots=link.diag_slots,
|
|
|
last_error=last_error,
|
|
last_error=last_error,
|
|
|
last_ack_age=None if link.last_ack_at is None else now_m - link.last_ack_at,
|
|
last_ack_age=None if link.last_ack_at is None else now_m - link.last_ack_at,
|
|
|
|
|
+ expected_outputs=last_expected_outputs,
|
|
|
)
|
|
)
|
|
|
clear_live_panel()
|
|
clear_live_panel()
|
|
|
sys.stdout.write("\n".join(panel) + "\n")
|
|
sys.stdout.write("\n".join(panel) + "\n")
|
|
@@ -589,33 +647,40 @@ def run(args):
|
|
|
prev_panel_lines = len(panel)
|
|
prev_panel_lines = len(panel)
|
|
|
|
|
|
|
|
with log_path.open("x", encoding="utf-8") as log:
|
|
with log_path.open("x", encoding="utf-8") as log:
|
|
|
- link = Link(args.port, log)
|
|
|
|
|
- link.event("START", port=args.port, minutes=args.minutes,
|
|
|
|
|
|
|
+ link = Link(port, log)
|
|
|
|
|
+ link.event("START", port=port, minutes=args.minutes,
|
|
|
interval=args.interval, read_only=args.read_only,
|
|
interval=args.interval, read_only=args.read_only,
|
|
|
- set_payload=list(DUTIES))
|
|
|
|
|
|
|
+ set_payload=list(DUTIES),
|
|
|
|
|
+ set_payload_fan0=list(DUTIES_FAN_ZERO),
|
|
|
|
|
+ fan_hold_seconds=FAN_HOLD_SECONDS)
|
|
|
if live_mode:
|
|
if live_mode:
|
|
|
sys.stdout.write("\x1b[?25l")
|
|
sys.stdout.write("\x1b[?25l")
|
|
|
sys.stdout.flush()
|
|
sys.stdout.flush()
|
|
|
try:
|
|
try:
|
|
|
link.synchronize(end)
|
|
link.synchronize(end)
|
|
|
print(f"启动同步:清理{link.startup_bytes}字节缓存(原始字节已记录);以下CRC为运行期统计。", flush=True)
|
|
print(f"启动同步:清理{link.startup_bytes}字节缓存(原始字节已记录);以下CRC为运行期统计。", flush=True)
|
|
|
|
|
+ loop_start = next_due = time.monotonic()
|
|
|
while time.monotonic() < end:
|
|
while time.monotonic() < end:
|
|
|
cycles += 1
|
|
cycles += 1
|
|
|
last_matches = None
|
|
last_matches = None
|
|
|
|
|
+ fan_duty = fan_duty_for_elapsed(time.monotonic() - loop_start)
|
|
|
|
|
+ expected_duties = build_duties(fan_duty)
|
|
|
|
|
+ last_expected_outputs = expected_duties
|
|
|
try:
|
|
try:
|
|
|
if not args.read_only:
|
|
if not args.read_only:
|
|
|
- link.request(1, end)
|
|
|
|
|
|
|
+ link.request(1, end, expected_duties)
|
|
|
data = link.request(2, end)
|
|
data = link.request(2, end)
|
|
|
outputs = data[:32] + data[83:86]
|
|
outputs = data[:32] + data[83:86]
|
|
|
- matches = outputs == DUTIES
|
|
|
|
|
|
|
+ matches = outputs == expected_duties
|
|
|
if not args.read_only and not matches:
|
|
if not args.read_only and not matches:
|
|
|
- raise RuntimeError(f"输出回读不符:{list(outputs)}")
|
|
|
|
|
|
|
+ raise RuntimeError(f"输出回读不符:{list(outputs)} (期望风扇={fan_duty}%)")
|
|
|
ct = list(data[56:65])
|
|
ct = list(data[56:65])
|
|
|
last_outputs = outputs
|
|
last_outputs = outputs
|
|
|
last_ct = ct
|
|
last_ct = ct
|
|
|
last_matches = matches
|
|
last_matches = matches
|
|
|
link.event("CYCLE", cycle=cycles,
|
|
link.event("CYCLE", cycle=cycles,
|
|
|
elapsed=round(time.monotonic() - start, 3),
|
|
elapsed=round(time.monotonic() - start, 3),
|
|
|
|
|
+ fan_duty=fan_duty,
|
|
|
output_match=matches, outputs=list(outputs),
|
|
output_match=matches, outputs=list(outputs),
|
|
|
ct=ct, ct_reserved=list(data[65:83]),
|
|
ct=ct, ct_reserved=list(data[65:83]),
|
|
|
bmc=list(data[32:56]))
|
|
bmc=list(data[32:56]))
|
|
@@ -624,7 +689,7 @@ def run(args):
|
|
|
else:
|
|
else:
|
|
|
values = " ".join(f"CT{i}/{name}={temp(value)}"
|
|
values = " ".join(f"CT{i}/{name}={temp(value)}"
|
|
|
for i, (name, value) in enumerate(zip(CT_CONNECTORS, ct)))
|
|
for i, (name, value) in enumerate(zip(CT_CONNECTORS, ct)))
|
|
|
- mode = "GET OK" if args.read_only else "SET/GET 35路一致"
|
|
|
|
|
|
|
+ mode = "GET OK" if args.read_only else f"SET/GET 35路一致 (风扇={fan_duty}%)"
|
|
|
print(f"[{dt.datetime.now():%H:%M:%S}] #{cycles} {mode}\n {values}", flush=True)
|
|
print(f"[{dt.datetime.now():%H:%M:%S}] #{cycles} {mode}\n {values}", flush=True)
|
|
|
if link.diag:
|
|
if link.diag:
|
|
|
d = link.diag
|
|
d = link.diag
|
|
@@ -644,7 +709,7 @@ def run(args):
|
|
|
draw_live_panel()
|
|
draw_live_panel()
|
|
|
else:
|
|
else:
|
|
|
print(f"[{dt.datetime.now():%H:%M:%S}] {exc}", flush=True)
|
|
print(f"[{dt.datetime.now():%H:%M:%S}] {exc}", flush=True)
|
|
|
- next_due = max(next_due + args.interval, time.monotonic())
|
|
|
|
|
|
|
+ next_due = max(loop_start + cycles * args.interval, time.monotonic())
|
|
|
link.idle_until(min(next_due, end))
|
|
link.idle_until(min(next_due, end))
|
|
|
except KeyboardInterrupt:
|
|
except KeyboardInterrupt:
|
|
|
print("\n已停止发送。", flush=True)
|
|
print("\n已停止发送。", flush=True)
|
|
@@ -682,8 +747,9 @@ def main(argv=None):
|
|
|
style = Style(enabled=use_color)
|
|
style = Style(enabled=use_color)
|
|
|
if args.dry_run:
|
|
if args.dry_run:
|
|
|
show_map(style=style)
|
|
show_map(style=style)
|
|
|
- print("SET_ALL:", frame(1, DUTIES).hex(" ").upper())
|
|
|
|
|
- print("GET_ALL:", frame(2).hex(" ").upper())
|
|
|
|
|
|
|
+ print("SET_ALL (风扇50%):", frame(1, DUTIES).hex(" ").upper())
|
|
|
|
|
+ print("SET_ALL (风扇0%) :", frame(1, DUTIES_FAN_ZERO).hex(" ").upper())
|
|
|
|
|
+ print("GET_ALL :", frame(2).hex(" ").upper())
|
|
|
return 0
|
|
return 0
|
|
|
signal.signal(signal.SIGTERM, stop_sending)
|
|
signal.signal(signal.SIGTERM, stop_sending)
|
|
|
try:
|
|
try:
|