From: Lars Op den Kamp Date: Mon, 14 May 2012 13:57:43 +0000 (+0200) Subject: cec: display an alert message in case the connection couldn't be opened because of... X-Git-Tag: upstream/2.2.0~1^2~28^2~10 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7068f331f39c119c8d5ef11860e080f12841f2ce;p=deb_libcec.git cec: display an alert message in case the connection couldn't be opened because of permission errors, or if the port is busy --- diff --git a/include/cectypes.h b/include/cectypes.h index a8ff6f6..77b9927 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -1090,7 +1090,9 @@ typedef struct cec_logical_addresses typedef enum libcec_alert { CEC_ALERT_SERVICE_DEVICE, - CEC_ALERT_CONNECTION_LOST + CEC_ALERT_CONNECTION_LOST, + CEC_ALERT_PERMISSION_ERROR, + CEC_ALERT_PORT_BUSY } libcec_alert; typedef enum libcec_parameter_type diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index a68cfd3..08ae62c 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -122,6 +122,21 @@ bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONN if (!bConnectionOpened) { LIB_CEC->AddLog(CEC_LOG_ERROR, strError); + + if (m_port->GetErrorNumber() == EACCES) + { + libcec_parameter param; + param.paramType = CEC_PARAMETER_TYPE_STRING; + param.paramData = (void*)"No permission to open the device"; + LIB_CEC->Alert(CEC_ALERT_PERMISSION_ERROR, param); + } + else if (m_port->GetErrorNumber() == EBUSY) + { + libcec_parameter param; + param.paramType = CEC_PARAMETER_TYPE_STRING; + param.paramData = (void*)"The serial port is busy. Only one program can access the device directly."; + LIB_CEC->Alert(CEC_ALERT_PORT_BUSY, param); + } return false; }