diff --git a/MPSSELight/ftdi/FtdiDevice.cs b/MPSSELight/ftdi/FtdiDevice.cs index 10d5399..73be8e5 100644 --- a/MPSSELight/ftdi/FtdiDevice.cs +++ b/MPSSELight/ftdi/FtdiDevice.cs @@ -43,7 +43,18 @@ private void open(string serialNumber) if (ftStatus == FTDI.FT_STATUS.FT_OK) return; - String errMsg = "Failed to open device (error " + ftStatus.ToString() + ")"; + String errMsg = "Failed to open device using serial " + serialNumber + "(error " + ftStatus.ToString() + ")"; + throw new FtdiException(errMsg); + } + } + + private void open(uint locId) { + lock (_lock) { + FTDI.FT_STATUS ftStatus = ftdi.OpenByLocation(locId); + if (ftStatus == FTDI.FT_STATUS.FT_OK) + return; + + String errMsg = "Failed to open device using index " + locId + "(error " + ftStatus.ToString() + ")"; throw new FtdiException(errMsg); } } @@ -138,6 +149,11 @@ public FtdiDevice(string serialNumber) open(serialNumber); } + public FtdiDevice(uint locId) { + ftdi = new FTDI(); + open(locId); + } + public void Dispose() { if (ftdi.IsOpen)