cec: display an alert message in case the connection couldn't be opened because of...
[deb_libcec.git] / src / lib / adapter / USBCECAdapterCommunication.cpp
index a68cfd3732aa9689dff517069d278c0374f96ad2..08ae62c701e681250a4948d59b16ccd908269ddc 100644 (file)
@@ -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;
     }