1111import argparse
1212argcomplete : Union [None , ModuleType ] = None
1313try :
14- import argcomplete
14+ import argcomplete # type: ignore
1515except ImportError as e :
1616 pass # already set to None by default above
1717
@@ -1249,6 +1249,19 @@ def common():
12491249 noProto = args .noproto ,
12501250 noNodes = args .no_nodes ,
12511251 )
1252+ except FileNotFoundError :
1253+ # Handle the case where the serial device is not found
1254+ message = (
1255+ f"File Not Found Error:\n "
1256+ )
1257+ message += f" The serial device at '{ args .port } ' was not found.\n "
1258+ message += " Please check the following:\n "
1259+ message += " 1. Is the device connected properly?\n "
1260+ message += " 2. Is the correct serial port specified?\n "
1261+ message += " 3. Are the necessary drivers installed?\n "
1262+ message += " 4. Are you using a **power-only USB cable**? A power-only cable cannot transmit data.\n "
1263+ message += " Ensure you are using a **data-capable USB cable**.\n "
1264+ meshtastic .util .our_exit (message , 1 )
12521265 except PermissionError as ex :
12531266 username = os .getlogin ()
12541267 message = "Permission Error:\n "
@@ -1259,6 +1272,12 @@ def common():
12591272 message += " After running that command, log out and re-login for it to take effect.\n "
12601273 message += f"Error was:{ ex } "
12611274 meshtastic .util .our_exit (message )
1275+ except OSError as ex :
1276+ message = f"OS Error:\n "
1277+ message += " The serial device couldn't be opened, it might be in use by another process.\n "
1278+ message += " Please close any applications or webpages that may be using the device and try again.\n "
1279+ message += f"\n Original error: { ex } "
1280+ meshtastic .util .our_exit (message )
12621281 if client .devPath is None :
12631282 try :
12641283 client = meshtastic .tcp_interface .TCPInterface (
0 commit comments