VixenModules.Controller.OpenDMX.FTDI.write C# (CSharp) Method

write() public method

public write ( uint handle, byte data, int length ) : int
handle uint
data byte
length int
return int
        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;
        }