BinaryCommunicationReadFromCoreServer 方法 (Byte, Boolean, Boolean) |
将二进制的数据发送到管道中去,然后从管道里接收二进制的数据回来,并返回是否成功的结果对象。
Send binary data to the pipeline, and then receive binary data back from the pipeline, and return whether the success of the result object
命名空间:
HslCommunication.Core.Net
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 public virtual OperateResult<byte[]> ReadFromCoreServer(
byte[] send,
bool hasResponseData,
bool usePackAndUnpack
)
Public Overridable Function ReadFromCoreServer (
send As Byte(),
hasResponseData As Boolean,
usePackAndUnpack As Boolean
) As OperateResult(Of Byte())
public:
virtual OperateResult<array<unsigned char>^>^ ReadFromCoreServer(
array<unsigned char>^ send,
bool hasResponseData,
bool usePackAndUnpack
)
abstract ReadFromCoreServer :
send : byte[] *
hasResponseData : bool *
usePackAndUnpack : bool -> OperateResult<byte[]>
override ReadFromCoreServer :
send : byte[] *
hasResponseData : bool *
usePackAndUnpack : bool -> OperateResult<byte[]>
参数
- send
- 类型:SystemByte
发送的完整的报文信息 - hasResponseData
- 类型:SystemBoolean
是否有等待的数据返回 - usePackAndUnpack
- 类型: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
{
}
参见