WriteArray Method

Writes specified number of bytes from array to serial port.

Syntax

Visual Basic .NET
Function WriteArray(ByVal DataBuffer As array of Byte, ByVal BytesToWrite As UInt32) As UInt32 
Visual C#
UInt32 WriteArray(byte[] DataBuffer, UInt32 BytesToWrite);

Parameters

DataBuffer

[in] SafeArray of bytes to write.

BytesToWrite

[in, optional] Number of bytes to write to serial port.

Return

Number of bytes written to serial port. It can write fewer bytes than requested; the return value must be noted, and the reminder of the operation should be retried when possible.

Errors

The method may throw exception. Refer to Handle errors sample for details.

Code Example

byte[] ReadBuffer = System.Text.Encoding.ASCII.GetBytes("Write Data");
try
{
	ftspcControl1.WriteArray(ReadBuffer, (uint)ReadBuffer.GetLength(0));
}
catch (FTSPCException E)
{
	MessageBox.Show("Error " + E.ErrorCode.ToString() + "\r\n" + 
		E.ErrorSource, "Error", MessageBoxButtons.OK,
		MessageBoxIcon.Error);
}

See Also

Write