Esempio n. 1
0
        public static void Read(FT_HANDLE handle, byte[] buffer)
        {
            uint      bytesReturned;
            FT_STATUS status =
                FT_Read(handle, buffer, (uint)buffer.Length, out bytesReturned);

            if (status != FT_STATUS.FT_OK || bytesReturned != buffer.Length)
            {
                throw new InvalidOperationException();
            }
        }
Esempio n. 2
0
        public static byte ReadByte(FT_HANDLE handle)
        {
            byte      buffer;
            uint      bytesReturned;
            FT_STATUS status = FT_ReadByte(handle, out buffer, 1, out bytesReturned);

            if (status != FT_STATUS.FT_OK || bytesReturned != 1)
            {
                throw new InvalidOperationException();
            }
            return(buffer);
        }
Esempio n. 3
0
        public static FT_STATUS Write(FT_HANDLE handle, byte[] buffer)
        {
            uint      bytesWritten;
            FT_STATUS status = FT_Write(handle, buffer, (uint)buffer.Length,
                                        out bytesWritten);

            if (bytesWritten != buffer.Length)
            {
                return(FT_STATUS.FT_FAILED_TO_WRITE_DEVICE);
            }
            else
            {
                return(status);
            }
        }
Esempio n. 4
0
        public static int BytesToRead(FT_HANDLE handle)
        {
            uint amountInRxQueue;
            uint amountInTxQueue;
            uint eventStatus;

            if (FT_GetStatus(handle, out amountInRxQueue, out amountInTxQueue,
                             out eventStatus) == FT_STATUS.FT_OK)
            {
                return((int)amountInRxQueue);
            }
            else
            {
                return(0);
            }
        }