driver: fix bug in failing to emit error msg
This commit is contained in:
parent
753a16ab8e
commit
7dd551201e
@ -171,7 +171,7 @@ class FilterConfig:
|
|||||||
def _filter_type(self):
|
def _filter_type(self):
|
||||||
return "Sinc3WithFineODR"
|
return "Sinc3WithFineODR"
|
||||||
|
|
||||||
class InvalidCmd(Exception):
|
class KirdyCmdError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class Device:
|
class Device:
|
||||||
@ -890,15 +890,15 @@ class Kirdy:
|
|||||||
return json.loads(response[0])
|
return json.loads(response[0])
|
||||||
|
|
||||||
def _response_handling(self, msg, msg_type, sig=None):
|
def _response_handling(self, msg, msg_type, sig=None):
|
||||||
if msg["msg_type"] in ["InvalidCmd", "InvalidDatatype"]:
|
if msg["msg_type"] == msg_type:
|
||||||
raise InvalidCmd
|
|
||||||
elif msg["msg_type"] == msg_type:
|
|
||||||
if sig is not None:
|
if sig is not None:
|
||||||
sig.emit(msg)
|
sig.emit(msg)
|
||||||
else:
|
else:
|
||||||
logging.warn(f"Commands fail to execute. {msg['msg_type']}:{msg['msg']}")
|
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:
|
if self._err_msg_sig is not None:
|
||||||
self._err_msg_sig.emit(msg['msg'])
|
self._err_msg_sig.emit(f"{msg['msg_type']}:{str(msg['msg'])}")
|
||||||
|
else:
|
||||||
|
raise KirdyCmdError(f"{msg['msg_type']}:{str(msg['msg'])}")
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
async def _send_cmd(self, target, cmd, data=None, msg_type="Acknowledge", sig=None):
|
async def _send_cmd(self, target, cmd, data=None, msg_type="Acknowledge", sig=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user