From 59a0143b86873e99bb8b4728337cd9a4f0224bd0 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Mon, 29 Jan 2024 22:34:15 +0100 Subject: [PATCH 1/3] Also invalidate the pip cache when the "pyproject.toml" file changes --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24bfef3..152dcca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pip - key: ${{ runner.os }}-3.8-${{ hashFiles('requirements.txt') }} + key: ${{ runner.os }}-3.8-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('requirements.txt') }} - name: Update pip run: pip install .[extra] - name: Check formatting with Black From 8740422cd933c11ab899f1778431fa0b615e970c Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Mon, 29 Jan 2024 22:34:48 +0100 Subject: [PATCH 2/3] Convert the "baudrate/bitrate" argument to an int --- pybldc/pybldc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pybldc/pybldc.py b/pybldc/pybldc.py index 19fe70f..e59cd08 100644 --- a/pybldc/pybldc.py +++ b/pybldc/pybldc.py @@ -745,6 +745,7 @@ def cli() -> None: "-b", "--baudrate", "--bitrate", + type=int, help="The baudrate/bitrate to use for serial/can (defaults to 115200 for serial and 500000 for CAN)", ) optional.add_argument( From b2c9dc9dac0cf768daa6fbc27d44b285590b2bc7 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Mon, 29 Jan 2024 22:33:52 +0100 Subject: [PATCH 3/3] Fix compatibilty with Python 3.8, as it does not support specifying the type of queue --- pybldc/pybldc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pybldc/pybldc.py b/pybldc/pybldc.py index e59cd08..057a699 100644 --- a/pybldc/pybldc.py +++ b/pybldc/pybldc.py @@ -313,7 +313,7 @@ def reset(self) -> None: def _wait_for_packet_response( self, - packet_queue: queue.Queue[List[int]], + packet_queue: queue.Queue, comm_packet_id: CommPacketId, expected_response: List[int], timeout: float, @@ -329,7 +329,7 @@ def _wait_for_packet_response( return False try: - response = packet_queue.get(timeout=timeout - dt) + response: List[int] = packet_queue.get(timeout=timeout - dt) self._logger.debug(f"PyBldcBase: Received packet response: {response}, expected: {expected_response}") # Make sure it replies with the command as the first byte and "OK" as the second byte @@ -350,7 +350,7 @@ def __init__(self, can_id: int, controller_id: int, logger: logging.Logger) -> N self._controller_id = controller_id self._logger = logger self._is_stopped = False - self.packet_queue: queue.Queue[List[int]] = queue.Queue() + self.packet_queue: queue.Queue = queue.Queue() self.pong_event = threading.Event() self._hw_type: Optional[HwType] = None @@ -524,7 +524,7 @@ def __init__( # Open the serial port, but read from it in a thread, so we are not blocking the main loop self._serial = serial.Serial(port=port, baudrate=baudrate, timeout=0.5, exclusive=True) self._shutdown_thread = threading.Event() - self._packet_queue: queue.Queue[List[int]] = queue.Queue() + self._packet_queue: queue.Queue = queue.Queue() self._thread = threading.Thread( target=self._serial_read_thread, name="_serial_read_thread", @@ -596,7 +596,7 @@ def _serial_read_thread( ser: Any, shutdown_event: threading.Event, logger: logging.Logger, - packet_queue: queue.Queue[List[int]], + packet_queue: queue.Queue, ) -> None: try: data_buffer = bytearray()