diff --git a/sbot/serial_wrapper.py b/sbot/serial_wrapper.py index 7013d41..a5a8a75 100644 --- a/sbot/serial_wrapper.py +++ b/sbot/serial_wrapper.py @@ -6,6 +6,7 @@ """ from __future__ import annotations +import os import logging import sys import threading @@ -30,6 +31,11 @@ E = TypeVar("E", bound=BaseException) +if os.environ.get('WEBOTS_SIMULATOR', '') == '1': + BASE_TIMEOUT = 5 +else: + BASE_TIMEOUT = 0.5 + def retry( times: int, exceptions: type[E] | tuple[type[E], ...] @@ -80,7 +86,7 @@ def __init__( self, port: str, baud: int, - timeout: float = 0.5, + timeout: float = BASE_TIMEOUT, identity: BoardIdentity = BoardIdentity(), delay_after_connect: float = 0, ):