public int write(uint handle, byte[] data, int length)
{
//Free the memory from the last call to write()
Marshal.FreeHGlobal(transmitPtr);
//Copy the buffer to a stream of bytes
transmitPtr = Marshal.AllocHGlobal((int)length);
Marshal.Copy(data, 0, transmitPtr, (int)length);
uint bytesWritten = 0;
//Write the data to the serial buffer
status = FT_Write(handle, transmitPtr, (uint)length, ref bytesWritten);
return (int)bytesWritten;
}