uart: update length checking to accomodate extra newlines

This commit is contained in:
Fischer Moseley 2024-08-23 08:35:40 -07:00
parent ed2dfd141b
commit d582dc24c8
1 changed files with 4 additions and 3 deletions

View File

@ -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