mirror of
https://github.com/SHC-ASTRA/rover-ros2.git
synced 2026-04-20 11:51:16 -05:00
remove nested for loops
This commit is contained in:
@@ -69,19 +69,18 @@ class SerialConnector(Connector):
|
|||||||
|
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
self.logger.debug(f"attempt {i + 1} of 4 asking {port} for its name")
|
self.logger.debug(f"attempt {i + 1} of 4 asking {port} for its name")
|
||||||
for _ in range(4):
|
response = serial_interface.read_until(bytes("\n", "utf8"))
|
||||||
response = serial_interface.read_until(bytes("\n", "utf8"))
|
try:
|
||||||
try:
|
if b"can_relay_ready" in response:
|
||||||
if b"can_relay_ready" in response:
|
args: list[str] = response.decode("utf8").strip().split(",")
|
||||||
args: list[str] = response.decode("utf8").strip().split(",")
|
if len(args) == 2:
|
||||||
if len(args) == 2:
|
self.logger.info(f"we are talking to {args[1]}")
|
||||||
self.logger.info(f"we are talking to {args[1]}")
|
return args[1]
|
||||||
return args[1]
|
break
|
||||||
break
|
except UnicodeDecodeError as e:
|
||||||
except UnicodeDecodeError as e:
|
self.logger.info(
|
||||||
self.logger.info(
|
f"ignoring UnicodeDecodeError when asking for MCU name: {e}"
|
||||||
f"ignoring UnicodeDecodeError when asking for MCU name: {e}"
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if serial_interface.is_open:
|
if serial_interface.is_open:
|
||||||
serial_interface.close()
|
serial_interface.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user