From 85e7f66b1990c981a4258507bed8e5302a34dc1d Mon Sep 17 00:00:00 2001 From: wangfq Date: Thu, 28 May 2026 10:51:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SerialNet=20=E4=B8=8B=E5=8F=91=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E7=AB=AF=E5=8F=A3=E6=94=B9=E4=B8=BA=E8=AE=BE=E5=A4=87?= =?UTF-8?q?UDP=204900?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.py | 4 ++++ src/handlers.py | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config.py b/src/config.py index ca43c62..7c530e0 100644 --- a/src/config.py +++ b/src/config.py @@ -8,6 +8,10 @@ UDP_MSG_PORT = int(os.getenv("EDC_UDP_MSG_PORT", "5505")) TCP_PORT = int(os.getenv("EDC_TCP_PORT", "5550")) BIND_HOST = os.getenv("EDC_BIND_HOST", "0.0.0.0") +# 设备端接收端口 +DEVICE_UDP_PORT = int(os.getenv("EDC_DEVICE_UDP_PORT", "4900")) +DEVICE_TCP_PORT = int(os.getenv("EDC_DEVICE_TCP_PORT", "5550")) + # MySQL MYSQL_HOST = os.getenv("EDC_MYSQL_HOST", "127.0.0.1") MYSQL_PORT = int(os.getenv("EDC_MYSQL_PORT", "3306")) diff --git a/src/handlers.py b/src/handlers.py index 0864641..5710b82 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -376,12 +376,13 @@ async def _send_serialnet_cmd(device_id: str, dnt_id: int, record: dict): # 获取设备 IP 和 msgport dnt = await get_dnt_by_serial(device_id) - if not dnt or not dnt.get("ip") or not dnt.get("msgport"): - logger.warning(f"设备 {device_id} 无 IP/msgport 信息,跳过") + if not dnt or not dnt.get("ip"): + logger.warning(f"设备 {device_id} 无 IP 信息,跳过") return + from src.config import DEVICE_UDP_PORT send_pkg = record["send_pkg"] - addr = (dnt["ip"], dnt["msgport"]) + addr = (dnt["ip"], DEVICE_UDP_PORT) # 构造 SerialNet JSON msg = {