mirror of
https://github.com/meshtastic/python.git
synced 2026-06-02 12:45:00 -04:00
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>
This commit is contained in:
@@ -1474,6 +1474,23 @@ def common():
|
||||
message += " Please close any applications or webpages that may be using the device and try again.\n"
|
||||
message += f"\nOriginal error: {ex}"
|
||||
meshtastic.util.our_exit(message)
|
||||
except MeshInterface.MeshInterfaceError as ex:
|
||||
msg = str(ex)
|
||||
if "Timed out" in msg:
|
||||
meshtastic.util.our_exit(
|
||||
"Connection timed out.\n\n"
|
||||
"Possible causes:\n"
|
||||
" - Device is rebooting\n"
|
||||
" - Device firmware is updating\n"
|
||||
" - Serial connection was interrupted\n\n"
|
||||
"Try:\n"
|
||||
" - Wait a few seconds and try again\n"
|
||||
" - Check if device is fully booted (LED patterns)\n"
|
||||
" - Reconnect the USB cable",
|
||||
1,
|
||||
)
|
||||
else:
|
||||
meshtastic.util.our_exit(f"Connection error: {ex}", 1)
|
||||
if client.devPath is None:
|
||||
try:
|
||||
client = meshtastic.tcp_interface.TCPInterface(
|
||||
|
||||
Reference in New Issue
Block a user