From 7068f331f39c119c8d5ef11860e080f12841f2ce Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 14 May 2012 15:57:43 +0200 Subject: [PATCH] cec: display an alert message in case the connection couldn't be opened because of permission errors, or if the port is busy --- include/cectypes.h | 4 +++- src/lib/adapter/USBCECAdapterCommunication.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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; } -- 2.34.1