diff --git a/ModemPool.py b/ModemPool.py index 7e7ae22..7122d4e 100644 --- a/ModemPool.py +++ b/ModemPool.py @@ -91,12 +91,16 @@ class ModemPool: def _send_command(self, cmd: str, ser, wait_time_in_s: int = 0) -> bytes: ser.write(cmd.encode()) - msg = ser.read(100) - count = 0 - while 'OK' not in str(msg) and count < wait_time_in_s: - time.sleep(1) - count = count + 1 + msg = None + try: msg = ser.read(100) + count = 0 + while 'OK' not in str(msg) and count < wait_time_in_s: + time.sleep(1) + count = count + 1 + msg = ser.read(100) + except Exception as exc: + print(exc) # msg = ser.read(100) print(msg) return msg