点击或拖拽改变大小

SerialDeviceBaseReadUInt16Async 方法 (String)

异步读取16位的无符号整型
Asynchronously read 16-bit unsigned integer

命名空间:  HslCommunication.Serial
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:11.8.2.0 (11.8.2.0)
语法
public Task<OperateResult<ushort>> ReadUInt16Async(
	string address
)

参数

address
类型:SystemString
起始地址

返回值

类型:TaskOperateResultUInt16
带有成功标识的ushort数据

实现

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

// 以下是简单的读取,没有仔细校验的方式
ushort d100 = (await melsec_net.ReadUInt16Async( "D100" )).Content;

// 如果需要判断是否读取成功
OperateResult<ushort> R_d100 = await melsec_net.ReadUInt16Async( "D100" );
if (R_d100.IsSuccess)
{
    // success
    ushort value = R_d100.Content;
}
else
{
    // failed
}
参见