请告诉我怎样使用这个方法,第一个参数应该怎么填写
/// </summary>
/// <param name="ReadBuf">串口数据缓冲</param>
/// <param name="ReadRoom">串口数据缓冲空间大小</param>
/// <param name="ByteTime">字节间隔最大时间</param>
/// <returns>从串口实际读入的字节个数</returns>
public int ReadBlock(out byte[] ReadBuf, int ReadRoom, int ByteTime)
{
//throw new System.NotImplementedException();
ReadBuf = new byte[1024];
Array.Clear(ReadBuf, 0, ReadBuf.Length); sbyte nBytelen;
//long nByteRead; if (serialPort1.IsOpen == false)
return 0;
nBytelen = 0;
serialPort1.ReadTimeout = ByteTime; while (nBytelen < (ReadRoom - 1))
{
try
{
ReadBuf[nBytelen] = (byte)serialPort1.ReadByte();
nBytelen++; // add one
}
catch (Exception ex)
{
throw new Exception(ex.Message);
break;
}
}
ReadBuf[nBytelen] = 0x00;
return nBytelen; }
ReadBlock(out byte[] ReadBuf, 10, 1000);简单说明下:ReadBuf是返回结果,10读取次数,1000为延时时间