OnReceive Event

This event occurs when data is received on the serial port.

Syntax

Visual Basic .NET
Sub OnReceive(ByVal Sender As Object, ByVal Count As UInt32)
Visual C#
void OnReceive(object Sender, UInt32 Count);

Parameters

Sender

Event source.

Count

Number of bytes can be read from serial port.

Code Example

// using System.Runtime.InteropServices;

private void ftspcControl1_OnReceive(object Sender, uint Count)
{
	try
	{
		IntPtr Ptr = IntPtr.Zero;
		byte[] ReadBuffer = new byte[Count];
		Ptr = Marshal.AllocHGlobal((int)Count);
		ftspcControl1.Read(Ptr, Count);
		Marshal.Copy(Ptr, ReadBuffer, 0, (int)Count);
		TextBox_Data.Text =
			System.Text.Encoding.ASCII.GetString(ReadBuffer);
	}
	catch (FTSPCException E)
	{
		MessageBox.Show("Error " + E.ErrorCode.ToString() + "\r\n" + 
		E.ErrorSource, "Error", MessageBoxButtons.OK, 
		MessageBoxIcon.Error);
	}
}