Skip to content

Commit

Permalink
Handle scenarios where multiple devices report the same serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoolls committed Dec 4, 2013
1 parent 696de56 commit d82d563
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions MultiMiner.Win/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,8 +1754,9 @@ private int GetItemIndexForDeviceDetails(DeviceDetailsResponse deviceDetails)
if (device.Driver.Equals(deviceDetails.Driver, StringComparison.OrdinalIgnoreCase)
&&
(
//serial == serial
(!String.IsNullOrEmpty(device.Serial) && device.Serial.Equals(deviceDetails.Serial, StringComparison.OrdinalIgnoreCase))
//serial == serial && path == path (serial may not be unique)
(!String.IsNullOrEmpty(device.Serial) && device.Serial.Equals(deviceDetails.Serial, StringComparison.OrdinalIgnoreCase)
&& !String.IsNullOrEmpty(device.Path) && device.Path.Equals(deviceDetails.DevicePath, StringComparison.OrdinalIgnoreCase))

//path == path
|| (!String.IsNullOrEmpty(device.Path) && device.Path.Equals(deviceDetails.DevicePath, StringComparison.OrdinalIgnoreCase))
Expand Down
5 changes: 4 additions & 1 deletion MultiMiner.Xgminer/Device/DeviceDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public bool Equals(Object obj)
//check for Serial on both sides as the Equals() needs to be bi-directional
return target.Driver.Equals(this.Driver, StringComparison.OrdinalIgnoreCase) && target.Path.Equals(this.Path, StringComparison.OrdinalIgnoreCase);
else
return target.Driver.Equals(this.Driver, StringComparison.OrdinalIgnoreCase) && target.Serial.Equals(this.Serial, StringComparison.OrdinalIgnoreCase);
//match on Driver, Serial AND Path
//cannot just do Serial because, while it should be unique, in practice it is not
return target.Driver.Equals(this.Driver, StringComparison.OrdinalIgnoreCase) && target.Serial.Equals(this.Serial, StringComparison.OrdinalIgnoreCase)
&& target.Path.Equals(this.Path, StringComparison.OrdinalIgnoreCase);
}
}
}

0 comments on commit d82d563

Please sign in to comment.