点击或拖拽改变大小

XinJETcpNetWriteAsync 方法 (String, Int16)

将数据写入到Modbus的单个寄存器上去,需要指定起始地址和数据值,如果富文本地址不指定,默认使用的功能码是 0x06
To write data to a single register of Modbus, you need to specify the start address and data value. If the rich text address is not specified, the default function code is 0x06.

命名空间:  HslCommunication.Profinet.XINJE
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:12.0.0.0 (12.0.0.0)
语法
public override Task<OperateResult> WriteAsync(
	string address,
	short value
)

参数

address
类型:SystemString
起始地址,比如"100","x=4;100","s=1;100","s=1;x=4;100"
value
类型:SystemInt16
写入的short数据

返回值

类型:TaskOperateResult
是否写入成功

实现

IReadWriteNetWriteAsync(String, Int16)
IReadWriteNetWriteAsync(String, Int16)
示例
以下为三菱的连接对象示例,其他的设备读写情况参照下面的代码:
Int16类型示例
MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );

// 简单的写入
await melsec_net.WriteAsync( "D100", (short)123 );

// 如果想要判断是否写入成功
OperateResult write = await melsec_net.WriteAsync( "D100", (short)123 );
if (write.IsSuccess)
{
    // success
}
else
{
    // failed
}
参见