From 2e889843b4c171f2d6ad8e0d53084040703d11f6 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 13:18:21 +0800
Subject: [PATCH] docs: CAN 总线级应答器 + 硬件调试页多标签多会话 设计规格
---
ModBusTcpController/ModBusTcpController.cs | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/ModBusTcpController/ModBusTcpController.cs b/ModBusTcpController/ModBusTcpController.cs
index e431966..835e542 100644
--- a/ModBusTcpController/ModBusTcpController.cs
+++ b/ModBusTcpController/ModBusTcpController.cs
@@ -48,23 +48,39 @@
return res?.IsSuccess == true;
}
- public bool ReadDIInt(string address, out int res, out string msg)
+ public bool ReadDIInt16(string address, out int res, out string msg)
{
- var result = client?.ReadInt32($"x=2;{address}");
+ var result = client?.ReadInt16($"x=2;{address}");
msg = result?.Message;
res = result?.Content ?? 0;
return result?.IsSuccess == true;
}
- public bool ReadDOInt(string address, out int res, out string msg)
+ public bool ReadDOInt16(string address, out int res, out string msg)
{
- var result = client?.ReadInt32(address);
+ var result = client?.ReadInt16(address);
msg = result?.Message;
res = result?.Content ?? 0;
return result?.IsSuccess == true;
}
- public bool WriteInt(string address, int value, out string msg)
+ public bool WriteInt16(string address, short value, out string msg)
+ {
+ msg = string.Empty;
+ var res = client?.Write(address, value);
+ msg = res.Message;
+ return res?.IsSuccess == true;
+ }
+
+ public bool ReadUInt16(string address, out ushort res, out string msg)
+ {
+ var result = client?.ReadUInt16(address);
+ msg = result?.Message;
+ res = result?.Content ?? 0;
+ return result?.IsSuccess == true;
+ }
+
+ public bool WriteUInt16(string address, ushort value, out string msg)
{
msg = string.Empty;
var res = client?.Write(address, value);
--
Gitblit v1.9.1