NetworkDoubleBaseReadFromCoreServer 方法 (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 OperateResult<byte[]> ReadFromCoreServer(
byte[] send,
bool hasResponseData,
bool usePackAndUnpack = true
)
Public Function ReadFromCoreServer (
send As Byte(),
hasResponseData As Boolean,
Optional usePackAndUnpack As Boolean = true
) As OperateResult(Of Byte())
public:
OperateResult<array<unsigned char>^>^ ReadFromCoreServer(
array<unsigned char>^ send,
bool hasResponseData,
bool usePackAndUnpack = true
)
member ReadFromCoreServer :
send : byte[] *
hasResponseData : bool *
?usePackAndUnpack : bool
(* Defaults:
let _usePackAndUnpack = defaultArg usePackAndUnpack true
*)
-> OperateResult<byte[]>
参数
- send
- 类型:SystemByte
发送的完整的报文信息 - hasResponseData
- 类型:SystemBoolean
是否有等待的数据返回,默认为 true - usePackAndUnpack (Optional)
- 类型:SystemBoolean
是否需要对命令重新打包,在重写PackCommandWithHeader(Byte)方法后才会有影响
返回值
类型:
OperateResultByte接收的完整的报文信息
备注
本方法用于实现本组件还未实现的一些报文功能,例如有些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
{
}
参见