From 52043fa1d7c84d24c6052a15366c93abe63a3232 Mon Sep 17 00:00:00 2001 From: WillB97 Date: Mon, 20 May 2024 22:53:45 +0100 Subject: [PATCH] Raise the serial port timeout while in the simulaor This is to account for running the simulator below 1x speed --- sbot/serial_wrapper.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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, ):