POSIX FTDI: Nicer error message for when device is in use

Commonly, the device is being used by another libicsneo program
(icsscand, maybe) or passed through to a VM.
This commit is contained in:
Paul Hollinsky
2020-06-24 22:15:22 -04:00
parent a759c1faa9
commit 2079037ae4
3 changed files with 9 additions and 1 deletions
+5 -1
View File
@@ -56,7 +56,11 @@ bool FTDI::open() {
// At this point the handle has been checked to be within the bounds of the handles array
std::tuple<int, std::string>& handle = handles[device.handle];
if(ftdi.openDevice(std::get<0>(handle), std::get<1>(handle).c_str()) != 0) {
const int openError = ftdi.openDevice(std::get<0>(handle), std::get<1>(handle).c_str());
if(openError == -5) { // Unable to claim device
report(APIEvent::Type::DeviceInUse, APIEvent::Severity::Error);
return false;
} else if(openError != 0) {
report(APIEvent::Type::DriverFailedToOpen, APIEvent::Severity::Error);
return false;
}