Skip to content

Commit

Permalink
Merge pull request #8 from cmorty/pull/locId
Browse files Browse the repository at this point in the history
Add option to pass the location id as constructor
  • Loading branch information
zhelnio authored May 5, 2018
2 parents 5500e3a + f29a61b commit 6155a40
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion MPSSELight/ftdi/FtdiDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6155a40

Please sign in to comment.