From d582dc24c896e8e20ec0fc3dbbc45cf8002430bb Mon Sep 17 00:00:00 2001 From: Fischer Moseley <42497969+fischermoseley@users.noreply.github.com> Date: Fri, 23 Aug 2024 08:35:40 -0700 Subject: [PATCH] uart: update length checking to accomodate extra newlines --- src/manta/uart/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/manta/uart/__init__.py b/src/manta/uart/__init__.py index 6da521e..9a3ff72 100644 --- a/src/manta/uart/__init__.py +++ b/src/manta/uart/__init__.py @@ -173,11 +173,12 @@ class UARTInterface(Elaboratable): ser.write(bytes_out.encode("ascii")) # Read responses have the same length as read requests - bytes_in = ser.read(7 * len(addr_chunk)) + bytes_expected = 7 * len(addr_chunk) + bytes_in = ser.read(bytes_expected) - if len(bytes_in) != len(bytes_out): + if len(bytes_in) != bytes_expected: raise ValueError( - f"Only got {len(bytes_in)} out of {len(bytes_out)} bytes." + f"Only got {len(bytes_in)} out of {bytes_expected} bytes." ) # Split received bytes into individual responses and decode