diff --git a/pykirdy/driver/kirdy.py b/pykirdy/driver/kirdy.py index 876f5ca..860e14b 100644 --- a/pykirdy/driver/kirdy.py +++ b/pykirdy/driver/kirdy.py @@ -642,6 +642,7 @@ class Kirdy: # PyQt Signal self._report_sig = None # Dict self._connected_sig = None # Bool + self._err_msg_sig = None # Str self.connected_event = None @@ -662,6 +663,12 @@ class Kirdy: """ self._connected_sig = sig + def set_err_msg_sig(self, sig): + """ + Emit a error message to a PyQt Signal(str) when a cmd fails to execute + """ + self._err_msg_sig = sig + def start_session(self, host='192.168.1.128', port=1337): """ Start Kirdy Connection Session. @@ -900,6 +907,10 @@ class Kirdy: elif msg["msg_type"] == msg_type: if sig is not None: sig.emit(msg) + else: + logging.warn(f"Commands fail to execute. {msg['msg_type']}:{msg['msg']}") + if self._err_msg_sig is not None and msg['msg'] is not None: + self._err_msg_sig.emit(msg['msg']) return msg async def _send_raw_cmd(self, cmd, msg_type="Acknowledge", sig=None):