Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,10 @@ async def main() -> None:
if flow_control == "none":
flow_control = None

# First, read the hardware address of the new adapter
hwaddr = await get_adapter_hardware_addr(
port=args.adapter,
baudrate=args.baudrate,
flow_control=flow_control,
)

# Then, look at existing settings
# First, look at existing settings before touching the adapter.
# If there is nothing to migrate, skip the adapter connection entirely.
# This avoids a TimeoutError / AssertionError on dongles that reset their
# USB connection in response to a Spinel RESET (issue #4475).
all_settings = []

for settings_path in args.data_dir.glob("*.data"):
Expand All @@ -184,6 +180,13 @@ async def main() -> None:
print("No existing settings files found, skipping")
return

# Only connect to the adapter if there are settings files that need migrating
hwaddr = await get_adapter_hardware_addr(
port=args.adapter,
baudrate=args.baudrate,
flow_control=flow_control,
)

most_recent_settings_info = sorted(all_settings, reverse=True)[0]
most_recent_settings_path = most_recent_settings_info[1]
most_recent_settings = most_recent_settings_info[2]
Expand Down