mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Improved FTDI device finding logic
This commit is contained in:
@@ -101,15 +101,20 @@ std::vector<neodevice_t> VCP::FindByProduct(int product, std::vector<std::wstrin
|
||||
}
|
||||
|
||||
bool alreadyFound = false;
|
||||
neodevice_t* shouldReplace = nullptr;
|
||||
for(auto& foundDev : found) {
|
||||
if(foundDev.handle == device.handle && serial == foundDev.serial) {
|
||||
if((foundDev.handle == device.handle || foundDev.handle == 0 || device.handle == 0) && serial == foundDev.serial) {
|
||||
alreadyFound = true;
|
||||
if(foundDev.handle == 0)
|
||||
shouldReplace = &foundDev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!alreadyFound)
|
||||
found.push_back(device);
|
||||
else if(shouldReplace != nullptr)
|
||||
*shouldReplace = device;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user