diff --git a/benqprojector/__init__.py b/benqprojector/__init__.py index 32d9edd..b9b4ad6 100644 --- a/benqprojector/__init__.py +++ b/benqprojector/__init__.py @@ -5,6 +5,6 @@ @author: Rogier van Staveren """ -__version__ = "0.0.12.2" +__version__ = "0.0.12.3" from benqprojector.benqprojector import BAUD_RATES, BenQProjector diff --git a/benqprojector/benqprojector.py b/benqprojector/benqprojector.py index 2362f9d..6efb888 100644 --- a/benqprojector/benqprojector.py +++ b/benqprojector/benqprojector.py @@ -80,9 +80,9 @@ def __init__(self, command=None, action=None, response=None): class ResponseTimeoutError(BenQProjectorError): """ - Invalid response error. + Response timeout error. - If the response format does not match the expected format. + If the response takes to long to receive. """ def __init__(self, command=None, action=None, response=None): @@ -414,7 +414,7 @@ def _wait_for_prompt(self) -> bool: def _read_response(self) -> str: response = b"" last_response = datetime.now() - while (datetime.now() - last_response).total_seconds() < _RESPONSE_TIMEOUT: + while True: _response = self._connection.readline() if len(_response) > 0: response += _response @@ -427,7 +427,12 @@ def _read_response(self) -> str: return response last_response = datetime.now() - raise ResponseTimeoutError(response = response) + if (datetime.now() - last_response).total_seconds() > _RESPONSE_TIMEOUT: + logger.error("Timeout while waiting for response") + raise ResponseTimeoutError(response = response) + + logger.debug("Waiting for response") + self._sleep(0.01) def _send_raw_command(self, command: str) -> str: """ diff --git a/pyproject.toml b/pyproject.toml index 76c89d5..ce13e19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "benqprojector" -version = "0.0.12.2" +version = "0.0.12.3" license = {text = "Apache-2.0"} authors = [ { name="Rogier van Staveren" }