protected bool OpenFTDIDevice(FTDI.FT_DEVICE_INFO_NODE deviceToOpen) { bool connected = false; lock (mFTDIDevice) { if (IsFTDIDeviceOpen()) { CloseFTDIDevice(); } if (FTDI.IsFTD2XXDLLLoaded()) { if (deviceToOpen != null) { if (mFTDIDevice.OpenByLocation(deviceToOpen.LocId) == FTDI.FT_STATUS.FT_OK) { FTDI.FT_STATUS ftdiStatus = FTDI.FT_STATUS.FT_OK; ftdiStatus |= mFTDIDevice.ResetDevice(); //ftdiStatus |= mFTDIDevice.ResetPort(); ftdiStatus |= mFTDIDevice.Purge(FTDI.FT_PURGE.FT_PURGE_RX | FTDI.FT_PURGE.FT_PURGE_TX); if (ftdiStatus == FTDI.FT_STATUS.FT_OK) { DisplayStatusMessage("Opened FTDI device.", StatusMessageType.LOG); DisplayStatusMessage("FTDI device info - Description: " + deviceToOpen.Description + " Serial Number: " + deviceToOpen.SerialNumber + " Device Type: " + deviceToOpen.Type + " ID: 0x" + deviceToOpen.ID.ToString("X") + " Device Flags: 0x" + deviceToOpen.Flags.ToString("X"), StatusMessageType.LOG); if (FTDI.IsFTDChipIDDLLLoaded()) { DisplayStatusMessage("FTDI ChipID DLL is loaded, checking chip ID...", StatusMessageType.LOG); uint chipID = 0; if (mFTDIDevice.GetChipIDFromCurrentDevice(out chipID) == FTDI.FT_STATUS.FT_OK) { DisplayStatusMessage("FTDI device chip ID: 0x" + chipID.ToString("X"), StatusMessageType.LOG); } else { DisplayStatusMessage("Unable to read FTDI device chip ID", StatusMessageType.LOG); } } connected = true; } else { mFTDIDevice.Close(); } } else { DisplayStatusMessage("Could not open FTDI device", StatusMessageType.LOG); } } else { DisplayStatusMessage("No FTDI device selected", StatusMessageType.LOG); } } else { DisplayStatusMessage("FTDI FTD2XX device driver DLL could not be loaded.", StatusMessageType.USER); } } return(connected); }