FTD2XX_NET.FTDI.EEReadUserArea C# (CSharp) Method

EEReadUserArea() public method

Reads data from the user area of the device EEPROM.
public EEReadUserArea ( byte UserAreaDataBuffer, UInt32 &numBytesRead ) : FT_STATUS
UserAreaDataBuffer byte An array of bytes which will be populated with the data read from the device EEPROM user area.
numBytesRead System.UInt32 The number of bytes actually read from the EEPROM user area.
return FT_STATUS
        public FT_STATUS EEReadUserArea(byte[] UserAreaDataBuffer, ref UInt32 numBytesRead)
        {
            // Initialise ftStatus to something other than FT_OK
            FT_STATUS ftStatus = FT_STATUS.FT_OTHER_ERROR;

            // If the DLL hasn't been loaded, just return here
            if (hFTD2XXDLL == IntPtr.Zero)
                return ftStatus;

            // Check for our required function pointers being set up
            if ((pFT_EE_UASize != IntPtr.Zero) & (pFT_EE_UARead != IntPtr.Zero))
            {
                tFT_EE_UASize FT_EE_UASize = (tFT_EE_UASize)Marshal.GetDelegateForFunctionPointer(pFT_EE_UASize, typeof(tFT_EE_UASize));
                tFT_EE_UARead FT_EE_UARead = (tFT_EE_UARead)Marshal.GetDelegateForFunctionPointer(pFT_EE_UARead, typeof(tFT_EE_UARead));

                if (ftHandle != IntPtr.Zero)
                {
                    UInt32 UASize = 0;
                    // Get size of user area to allocate an array of the correct size.
                    // The application must also get the UA size for its copy
                    ftStatus = FT_EE_UASize(ftHandle, ref UASize);

                    // Make sure we have enough storage for the whole user area
                    if (UserAreaDataBuffer.Length >= UASize)
                    {
                        // Call FT_EE_UARead
                        ftStatus = FT_EE_UARead(ftHandle, UserAreaDataBuffer, UserAreaDataBuffer.Length, ref numBytesRead);
                    }
                }
            }
            else
            {
                if (pFT_EE_UASize == IntPtr.Zero)
                {
                    LogB.Debug("FTD2XX: Failed to load function FT_EE_UASize.");
                }
                if (pFT_EE_UARead == IntPtr.Zero)
                {
                    LogB.Debug("FTD2XX: Failed to load function FT_EE_UARead.");
                }
            }
            return ftStatus;
        }