NetworkDoubleBaseReadFromCoreServerAsync 方法 (Byte) |
将数据发送到当前的网络通道中,并从网络通道中接收一个
INetMessage指定的完整的报文,网络通道将根据
GetAvailableSocket方法自动获取,本方法是线程安全的。
Send data to the current network channel and receive a complete message specified by
INetMessage from the network channel.
The network channel will be automatically obtained according to the
GetAvailableSocket method This method is thread-safe.
命名空间:
HslCommunication.Core.Net
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 public virtual Task<OperateResult<byte[]>> ReadFromCoreServerAsync(
byte[] send
)
Public Overridable Function ReadFromCoreServerAsync (
send As Byte()
) As Task(Of OperateResult(Of Byte()))
public:
virtual Task<OperateResult<array<unsigned char>^>^>^ ReadFromCoreServerAsync(
array<unsigned char>^ send
)
abstract ReadFromCoreServerAsync :
send : byte[] -> Task<OperateResult<byte[]>>
override ReadFromCoreServerAsync :
send : byte[] -> Task<OperateResult<byte[]>>
参数
- send
- 类型:SystemByte
发送的完整的报文信息
返回值
类型:
TaskOperateResultByte接收的完整的报文信息
备注
本方法用于实现本组件还未实现的一些报文功能,例如有些modbus服务器会有一些特殊的功能码支持,需要收发特殊的报文,详细请看示例
示例
此处举例有个modbus服务器,有个特殊的功能码0x09,后面携带子数据0x01即可,发送字节为 0x00 0x00 0x00 0x00 0x00 0x03 0x01 0x09 0x01
ModbusTcpNet modbus = new ModbusTcpNet( "192.168.0.100" );
OperateResult<byte[]> read = modbus.ReadFromCoreServer( SoftBasic.HexStringToBytes( "0x00 0x00 0x00 0x00 0x00 0x03 0x01 0x09 0x01" ) );
if (read.IsSuccess)
{
Console.WriteLine( SoftBasic.ByteToHexString( read.Content, ' ' ) );
}
else
{
}
参见