From 123dfc44115d6e8c980074f160a475feece472a7 Mon Sep 17 00:00:00 2001 From: wsy182 <2392948297@qq.com> Date: Mon, 17 Nov 2025 09:58:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(wits):=20=E6=B7=BB=E5=8A=A0WITS=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A8=A1=E6=8B=9F=E5=8F=91=E9=80=81=E8=84=9A=E6=9C=AC?= =?UTF-8?q?-=20=E5=AE=9E=E7=8E=B0=E9=9A=8F=E6=9C=BA=E7=94=9F=E6=88=90WITS?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD=20-=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=95=B4=E6=95=B0=E5=92=8C=E6=B5=AE=E7=82=B9?= =?UTF-8?q?=E6=95=B0=E4=B8=A4=E7=A7=8D=E6=95=B0=E6=8D=AE=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=20-=20=E9=85=8D=E7=BD=AE=E7=9B=AE=E6=A0=87=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E5=92=8C=E7=AB=AF=E5=8F=A3=E8=BF=9B=E8=A1=8CTCP=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=20-=20=E5=BE=AA=E7=8E=AF=E5=8F=91=E9=80=81=E9=A2=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=9A=84WITS=E5=AD=97=E6=AE=B5=E7=A0=81=20-?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E5=8F=91=E9=80=81=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=92=8C=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=9C=BA=E5=88=B6-=20=E6=8F=90=E4=BE=9B=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A1=8C=E5=85=A5=E5=8F=A3=E7=9B=B4=E6=8E=A5=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- send_wtis.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 send_wtis.py diff --git a/send_wtis.py b/send_wtis.py new file mode 100644 index 0000000..1cbda50 --- /dev/null +++ b/send_wtis.py @@ -0,0 +1,61 @@ +import socket +import random +import time + +HOST = "192.168.1.5" # 目标地址 +PORT = 9929 # 目标端口 + +# 你给的示例里出现的所有前四位字段 +WITS_CODES = [ + "0105", + "0106", + "0108", + "0112", + "0114", + "0116", + "0118", + "0120", + "0121", + "0122" +] + +def random_value(prefix): + """ + 生成类似你收到的数据: + - 有些是整数:例如 0105 251114 + - 有些是浮点:例如 0108 37.26745 + """ + # 随机决定生成整数 or 小数 + if random.random() < 0.3: + # 生成整数(6位左右) + value = str(random.randint(100000, 999999)) + else: + # 生成浮点(保留4~5位小数) + value = f"{random.uniform(0, 500):.5f}" + + return prefix + value + + +def send_wits_data(): + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((HOST, PORT)) + print("Connected to target. Sending WITS data...") + + try: + while True: + for code in WITS_CODES: + msg = random_value(code) + + sock.sendall((msg + "\r\n").encode()) + print("Sent:", msg) + + time.sleep(0.2) # 每条间隔 200ms,可根据需要调整 + + except Exception as e: + print("Error:", e) + finally: + sock.close() + + +if __name__ == "__main__": + send_wits_data()