NetworkDoubleBaseReadFromCoreServerAsync 方法 (Byte, Boolean, Boolean) |
将数据发送到当前的网络通道中,并从网络通道中接收一个
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 Task<OperateResult<byte[]>> ReadFromCoreServerAsync(
byte[] send,
bool hasResponseData,
bool usePackAndUnpack = true
)
Public Function ReadFromCoreServerAsync (
send As Byte(),
hasResponseData As Boolean,
Optional usePackAndUnpack As Boolean = true
) As Task(Of OperateResult(Of Byte()))
public:
Task<OperateResult<array<unsigned char>^>^>^ ReadFromCoreServerAsync(
array<unsigned char>^ send,
bool hasResponseData,
bool usePackAndUnpack = true
)
member ReadFromCoreServerAsync :
send : byte[] *
hasResponseData : bool *
?usePackAndUnpack : bool
(* Defaults:
let _usePackAndUnpack = defaultArg usePackAndUnpack true
*)
-> Task<OperateResult<byte[]>>
参数
- send
- 类型:SystemByte
发送的完整的报文信息 - hasResponseData
- 类型:SystemBoolean
是否有等待的数据返回,默认为 true - usePackAndUnpack (Optional)
- 类型:SystemBoolean
是否需要对命令重新打包,在重写PackCommandWithHeader(Byte)方法后才会有影响
返回值
类型:
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
{
}
参见