mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +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;
|
bool alreadyFound = false;
|
||||||
|
neodevice_t* shouldReplace = nullptr;
|
||||||
for(auto& foundDev : found) {
|
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;
|
alreadyFound = true;
|
||||||
|
if(foundDev.handle == 0)
|
||||||
|
shouldReplace = &foundDev;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!alreadyFound)
|
if(!alreadyFound)
|
||||||
found.push_back(device);
|
found.push_back(device);
|
||||||
|
else if(shouldReplace != nullptr)
|
||||||
|
*shouldReplace = device;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user