File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
ardupilot_methodic_configurator Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -288,7 +288,36 @@ def __create_connection_with_retry(
288
288
if log_errors :
289
289
logging_warning (_ ("Connection failed: %s" ), e )
290
290
logging_error (_ ("Failed to connect after %d attempts." ), retries )
291
- return str (e )
291
+ error_message = str (e )
292
+ guidance = self .__get_connection_error_guidance (e , self .comport .device if self .comport else "" )
293
+ if guidance :
294
+ error_message = f"{ error_message } \n \n { guidance } "
295
+ return error_message
296
+
297
+ def __get_connection_error_guidance (self , error : Exception , device : str ) -> str :
298
+ """
299
+ Provides guidance based on the type of connection error.
300
+
301
+ Args:
302
+ error (Exception): The exception that occurred during connection.
303
+ device (str): The device path or connection string.
304
+
305
+ Returns:
306
+ str: Guidance message specific to the error type, or empty string if no specific guidance.
307
+
308
+ """
309
+ # Check for permission denied errors on Linux
310
+ if isinstance (error , PermissionError ) and os_name == "posix" and "/dev/" in device :
311
+ return _ (
312
+ "Permission denied accessing the serial port. This is common on Linux systems.\n "
313
+ "To fix this issue, add your user to the 'dialout' group with the following command:\n "
314
+ " sudo adduser $USER dialout\n "
315
+ "Then log out and log back in for the changes to take effect."
316
+ )
317
+
318
+ # Add more specific guidance for other error types as needed
319
+
320
+ return ""
292
321
293
322
def __process_autopilot_version (self , m : MAVLink_autopilot_version_message , banner_msgs : list [str ]) -> str :
294
323
if m is None :
You can’t perform that action at this time.
0 commit comments