FTD2XX_NET.FTDI.GetModemStatus C# (CSharp) Method

GetModemStatus() public method

Gets the current modem status.
public GetModemStatus ( byte &ModemStatus ) : FT_STATUS
ModemStatus byte A bit map representaion of the current modem status.
return FT_STATUS
        public FT_STATUS GetModemStatus(ref byte ModemStatus)
        {
            // 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_GetModemStatus != IntPtr.Zero)
            {
                tFT_GetModemStatus FT_GetModemStatus = (tFT_GetModemStatus)Marshal.GetDelegateForFunctionPointer(pFT_GetModemStatus, typeof(tFT_GetModemStatus));

                UInt32 ModemLineStatus = 0;

                if (ftHandle != IntPtr.Zero)
                {
                    // Call FT_GetModemStatus
                    ftStatus = FT_GetModemStatus(ftHandle, ref ModemLineStatus);

                }
                ModemStatus = Convert.ToByte(ModemLineStatus & 0x000000FF);
            }
            else
            {
                if (pFT_GetModemStatus == IntPtr.Zero)
                {
                    LogB.Debug("FTD2XX: Failed to load function FT_GetModemStatus.");
                }
            }
            return ftStatus;
        }