public FT_STATUS CyclePort()
{
// 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_CyclePort != IntPtr.Zero) & (pFT_Close != IntPtr.Zero))
{
tFT_CyclePort FT_CyclePort = (tFT_CyclePort)Marshal.GetDelegateForFunctionPointer(pFT_CyclePort, typeof(tFT_CyclePort));
tFT_Close FT_Close = (tFT_Close)Marshal.GetDelegateForFunctionPointer(pFT_Close, typeof(tFT_Close));
if (ftHandle != IntPtr.Zero)
{
// Call FT_CyclePort
ftStatus = FT_CyclePort(ftHandle);
if (ftStatus == FT_STATUS.FT_OK)
{
// If successful, call FT_Close
ftStatus = FT_Close(ftHandle);
if (ftStatus == FT_STATUS.FT_OK)
{
ftHandle = IntPtr.Zero;
}
}
}
}
else
{
if (pFT_CyclePort == IntPtr.Zero)
{
LogB.Debug("FTD2XX: Failed to load function FT_CyclePort.");
}
if (pFT_Close == IntPtr.Zero)
{
LogB.Debug("FTD2XX: Failed to load function FT_Close.");
}
}
return ftStatus;
}