从串口接收指定长度的字节数组信息,还可以指定超时时间,以及休眠间歇时间。
Receive byte array information of specified length from the serial port, and can also specify the timeout time and sleep intermittent time.
命名空间:
HslCommunication
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:11.5.3.0 (11.5.3.0)
语法public static OperateResult<byte[]> Receive(
this SerialPort serialPort,
int length,
int timeout,
int sleepTime
)
<ExtensionAttribute>
Public Shared Function Receive (
serialPort As SerialPort,
length As Integer,
timeout As Integer,
sleepTime As Integer
) As OperateResult(Of Byte())
public:
[ExtensionAttribute]
static OperateResult<array<unsigned char>^>^ Receive(
SerialPort^ serialPort,
int length,
int timeout,
int sleepTime
)
[<ExtensionAttribute>]
static member Receive :
serialPort : SerialPort *
length : int *
timeout : int *
sleepTime : int -> OperateResult<byte[]>
参数
- serialPort
- 类型:System.IO.PortsSerialPort
串口信息 - length
- 类型:SystemInt32
准备接收的字节长度 - timeout
- 类型:SystemInt32
超时时间 - sleepTime
- 类型:SystemInt32
间歇休眠时间
返回值
类型:
OperateResultByte接收的结果内容对象
备注
在 Visual Basic 和 C# 中,这个方法可以当成为类型
SerialPort 的实例方法来调用。在采用实例方法语法调用这个方法时,请省略第一个参数。请参考
扩展方法 (Visual Basic) 或
扩展方法 (C# 编程指南) 获取更多信息。
参见