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.pull/25/head
parent
a759c1faa9
commit
2079037ae4
|
|
@ -101,6 +101,7 @@ static constexpr const char* DRIVER_FAILED_TO_OPEN = "The device driver encounte
|
||||||
static constexpr const char* DRIVER_FAILED_TO_CLOSE = "The device driver encountered a low-level error while closing the device.";
|
static constexpr const char* DRIVER_FAILED_TO_CLOSE = "The device driver encountered a low-level error while closing the device.";
|
||||||
static constexpr const char* PACKET_CHECKSUM_ERROR = "There was a checksum error while decoding a packet. The packet was dropped.";
|
static constexpr const char* PACKET_CHECKSUM_ERROR = "There was a checksum error while decoding a packet. The packet was dropped.";
|
||||||
static constexpr const char* TRANSMIT_BUFFER_FULL = "The transmit buffer is full and the device is set to non-blocking.";
|
static constexpr const char* TRANSMIT_BUFFER_FULL = "The transmit buffer is full and the device is set to non-blocking.";
|
||||||
|
static constexpr const char* DEVICE_IN_USE = "The device is currently in use by another program.";
|
||||||
static constexpr const char* PCAP_COULD_NOT_START = "The PCAP driver could not be started. Ethernet devices will not be found.";
|
static constexpr const char* PCAP_COULD_NOT_START = "The PCAP driver could not be started. Ethernet devices will not be found.";
|
||||||
static constexpr const char* PCAP_COULD_NOT_FIND_DEVICES = "The PCAP driver failed to find devices. Ethernet devices will not be found.";
|
static constexpr const char* PCAP_COULD_NOT_FIND_DEVICES = "The PCAP driver failed to find devices. Ethernet devices will not be found.";
|
||||||
static constexpr const char* PACKET_DECODING = "The packet could not be decoded.";
|
static constexpr const char* PACKET_DECODING = "The packet could not be decoded.";
|
||||||
|
|
@ -197,6 +198,8 @@ const char* APIEvent::DescriptionForType(Type type) {
|
||||||
return PACKET_CHECKSUM_ERROR;
|
return PACKET_CHECKSUM_ERROR;
|
||||||
case Type::TransmitBufferFull:
|
case Type::TransmitBufferFull:
|
||||||
return TRANSMIT_BUFFER_FULL;
|
return TRANSMIT_BUFFER_FULL;
|
||||||
|
case Type::DeviceInUse:
|
||||||
|
return DEVICE_IN_USE;
|
||||||
case Type::PCAPCouldNotStart:
|
case Type::PCAPCouldNotStart:
|
||||||
return PCAP_COULD_NOT_START;
|
return PCAP_COULD_NOT_START;
|
||||||
case Type::PCAPCouldNotFindDevices:
|
case Type::PCAPCouldNotFindDevices:
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ public:
|
||||||
DriverFailedToClose = 0x3003,
|
DriverFailedToClose = 0x3003,
|
||||||
PacketChecksumError = 0x3004,
|
PacketChecksumError = 0x3004,
|
||||||
TransmitBufferFull = 0x3005,
|
TransmitBufferFull = 0x3005,
|
||||||
|
DeviceInUse = 0x3006,
|
||||||
PCAPCouldNotStart = 0x3102,
|
PCAPCouldNotStart = 0x3102,
|
||||||
PCAPCouldNotFindDevices = 0x3103,
|
PCAPCouldNotFindDevices = 0x3103,
|
||||||
PacketDecodingError = 0x3104,
|
PacketDecodingError = 0x3104,
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,11 @@ bool FTDI::open() {
|
||||||
|
|
||||||
// At this point the handle has been checked to be within the bounds of the handles array
|
// 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];
|
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);
|
report(APIEvent::Type::DriverFailedToOpen, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue