diff --git a/HybirdFrameworkCore/Utils/BitUtls.cs b/HybirdFrameworkCore/Utils/BitUtls.cs
index 8c4f63a..fcc87b8 100644
--- a/HybirdFrameworkCore/Utils/BitUtls.cs
+++ b/HybirdFrameworkCore/Utils/BitUtls.cs
@@ -54,17 +54,13 @@ public static class BitUtls
if (propertyType == STRING)
{
- return Convert.ChangeType(Encoding.ASCII.GetString(bytes, start, length/8), propertyType);
+ byte[] sub = Sub(bytes, start, length);
+ return Convert.ChangeType(Encoding.ASCII.GetString(sub), propertyType);
}
if (propertyType == BYTEARRAY)
{
- length = length / 8;
- var bt = new byte[length];
-
- for (var i = start; i < start + length; i++) bt[i - start] = bytes[i];
-
- return bt;
+ return Sub(bytes, start, length);
}
throw new ArgumentException($"参数类型{propertyType}不支持encode!");
diff --git a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusTcpMaster.cs b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusTcpMaster.cs
index 2787bca..205a783 100644
--- a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusTcpMaster.cs
+++ b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusTcpMaster.cs
@@ -184,6 +184,23 @@ public class ModbusTcpMaster
return ModbusTcpNet.ReadDiscrete(address, length);
}
+ ///
+ /// 将数据写入到Modbus的寄存器上去,需要指定起始地址和数据内容,如果富文本地址不指定,默认使用的功能码是 0x10
+ /// To write data to Modbus registers, you need to specify the start address and data content. If the rich text address is not specified, the default function code is 0x10
+ ///
+ /// 起始地址,比如"100","x=4;100","s=1;100","s=1;x=4;100"
+ /// 写入的数据,长度根据data的长度来指示
+ /// 返回写入结果
+ /// 富地址格式,支持携带站号信息,功能码信息,具体参照类的示例代码
+ ///
+ /// 此处演示批量写入的示例
+ ///
+ ///
+ public OperateResult Write(string address, byte[] value)
+ {
+ return ModbusTcpNet.Write(address, value);
+ }
+
public bool WriteValue(ModbusProperty property)
{