OmronFinsServer.ReadFromCoreServer 方法 (PipeSession,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.Profinet.Omron
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 protected override OperateResult<byte[]> ReadFromCoreServer(
PipeSession session,
byte[] receive
)
Protected Overrides Function ReadFromCoreServer (
session As PipeSession,
receive As Byte()
) As OperateResult(Of Byte())
protected:
virtual OperateResult<array<unsigned char>^>^ ReadFromCoreServer(
PipeSession^ session,
array<unsigned char>^ receive
) override
abstract ReadFromCoreServer :
session : PipeSession *
receive : byte[] -> OperateResult<byte[]>
override ReadFromCoreServer :
session : PipeSession *
receive : byte[] -> OperateResult<byte[]>
参数
- session
- 类型:HslCommunication.Core.Net.PipeSession
[缺少 "M:HslCommunication.Profinet.Omron.OmronFinsServer.ReadFromCoreServer(HslCommunication.Core.Net.PipeSession,System.Byte[])" 的 <param name="session"/> 文档]
- receive
- 类型:System.Byte[]
[缺少 "M:HslCommunication.Profinet.Omron.OmronFinsServer.ReadFromCoreServer(HslCommunication.Core.Net.PipeSession,System.Byte[])" 的 <param name="receive"/> 文档]
返回值
类型:
OperateResult<Byte[]>接收的完整的报文信息
备注
本方法用于实现本组件还未实现的一些报文功能,例如有些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
{
}
参见