protected byte[] GetBytes(SerialPort port)
{
byte[] bigBuffer = null;
while (true)
{
//new up a buffer to read the available bytes
byte[] buffer = new byte[port.BytesToRead];
//read all of the available bytes, only read the buffer length
int count = port.Read(buffer, 0, buffer.Length);
//combine what we had before with the new data
bigBuffer = CombineArrays(buffer, bigBuffer);
if (count <= 0)
{
var result = _channel.ConvertTo(bigBuffer);
if (OnReceived != null) OnReceived(result, _port, _channel, DateTime.Now);
}
}
return bigBuffer;
}