Don't reuse the device object we use to get the serial

pull/4/head
Paul Hollinsky 2018-09-25 18:15:50 -04:00
parent 840fe54bcd
commit 126c8efd2a
2 changed files with 20 additions and 12 deletions

View File

@ -22,12 +22,16 @@ public:
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : PCAP::FindByProduct(PRODUCT_ID)) {
{
strncpy(neodevice.serial, SERIAL_FIND_ON_OPEN, sizeof(neodevice.serial));
neodevice.serial[sizeof(neodevice.serial) - 1] = '\0';
auto device = std::make_shared<NeoVIFIRE2ETH>(neodevice);
if(!device->open()) // We will get the serial number on open
continue; // If the open failed, we won't display the device as an option to connect to
found.push_back(device);
strncpy(neodevice.serial, device->getNeoDevice().serial, sizeof(neodevice.serial));
neodevice.serial[sizeof(neodevice.serial) - 1] = '\0';
}
found.push_back(std::make_shared<NeoVIFIRE2ETH>(neodevice));
}
return found;

View File

@ -28,12 +28,16 @@ public:
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : PCAP::FindByProduct(PRODUCT_ID)) {
{
strncpy(neodevice.serial, SERIAL_FIND_ON_OPEN, sizeof(neodevice.serial));
neodevice.serial[sizeof(neodevice.serial) - 1] = '\0';
auto device = std::make_shared<RADGalaxy>(neodevice);
if(!device->open()) // We will get the serial number on open
continue; // If the open failed, we won't display the device as an option to connect to
found.push_back(device);
strncpy(neodevice.serial, device->getNeoDevice().serial, sizeof(neodevice.serial));
neodevice.serial[sizeof(neodevice.serial) - 1] = '\0';
}
found.push_back(std::make_shared<RADGalaxy>(neodevice));
}
return found;