Skip to content

Commit

Permalink
Raise the serial port timeout while in the simulaor
Browse files Browse the repository at this point in the history
This is to account for running the simulator below 1x speed
  • Loading branch information
WillB97 committed May 20, 2024
1 parent 8e6dd15 commit 52043fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sbot/serial_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
from __future__ import annotations

import os
import logging
import sys
import threading
Expand All @@ -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], ...]
Expand Down Expand Up @@ -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,
):
Expand Down

0 comments on commit 52043fa

Please sign in to comment.