Skip to content

Commit 1fc2407

Browse files
lexfreiclaude
andcommitted
fix(cli): add timeout error handling for serial connections
Handle MeshInterface.MeshInterfaceError when device is rebooting or connection times out, with user-friendly error message. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
1 parent 25ffd25 commit 1fc2407

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

meshtastic/__main__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,23 @@ def common():
14741474
message += " Please close any applications or webpages that may be using the device and try again.\n"
14751475
message += f"\nOriginal error: {ex}"
14761476
meshtastic.util.our_exit(message)
1477+
except MeshInterface.MeshInterfaceError as ex:
1478+
msg = str(ex)
1479+
if "Timed out" in msg:
1480+
meshtastic.util.our_exit(
1481+
"Connection timed out.\n\n"
1482+
"Possible causes:\n"
1483+
" - Device is rebooting\n"
1484+
" - Device firmware is updating\n"
1485+
" - Serial connection was interrupted\n\n"
1486+
"Try:\n"
1487+
" - Wait a few seconds and try again\n"
1488+
" - Check if device is fully booted (LED patterns)\n"
1489+
" - Reconnect the USB cable",
1490+
1,
1491+
)
1492+
else:
1493+
meshtastic.util.our_exit(f"Connection error: {ex}", 1)
14771494
if client.devPath is None:
14781495
try:
14791496
client = meshtastic.tcp_interface.TCPInterface(

0 commit comments

Comments
 (0)