fix: (anchor) ignore UnicodeDecodeError when getting mcu name

This commit is contained in:
David
2025-11-11 13:18:36 -06:00
parent 5e7776631d
commit 3bb3771dce

View File

@@ -144,11 +144,14 @@ class Anchor(Node):
mcu_name: str = "" mcu_name: str = ""
for _ in range(4): for _ in range(4):
response = self.serial_interface.read_until(bytes("\n", "utf8")) response = self.serial_interface.read_until(bytes("\n", "utf8"))
if b"can_relay_ready" in response: try:
args: list[str] = response.decode("utf8").strip().split(",") if b"can_relay_ready" in response:
if len(args) == 2: args: list[str] = response.decode("utf8").strip().split(",")
mcu_name = args[1] if len(args) == 2:
break mcu_name = args[1]
break
except UnicodeDecodeError:
pass # ignore malformed responses
self.get_logger().info( self.get_logger().info(
f"MCU '{mcu_name}' is ready at '{self.serial_port}'." f"MCU '{mcu_name}' is ready at '{self.serial_port}'."
) )