Make sure to close underlying com if we fail to open

checksum-failure-logging
Paul Hollinsky 2019-05-14 15:20:04 -04:00
parent f3cd9ac94b
commit 288ff3565e
1 changed files with 3 additions and 1 deletions

View File

@ -151,13 +151,15 @@ bool Device::open() {
break;
}
if(!serial) {
err(APIError::NoSerialNumber);
err(APIError::NoSerialNumber); // Communication could not be established with the device. Perhaps it is not powered with 12 volts?
com->close();
return false;
}
std::string currentSerial = getNeoDevice().serial;
if(currentSerial != serial->deviceSerial) {
err(APIError::IncorrectSerialNumber);
com->close();
return false;
}