This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit e9a4c4f2c221a8d5143773ddb0a9f411417d3aea
Author: Xiang Xiao <[email protected]>
AuthorDate: Tue May 19 20:45:49 2026 +0800

    drivers/serial/netdev_console.c: Fall back to UDP if CAN fails.
    
    When both transports are enabled, try the ISO-TP console first and use
    UDP if the CAN socket cannot be set up, instead of returning from the
    first enabled transport.
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 drivers/serial/netdev_console.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/serial/netdev_console.c b/drivers/serial/netdev_console.c
index 660c1433b13..69dc4212d0a 100644
--- a/drivers/serial/netdev_console.c
+++ b/drivers/serial/netdev_console.c
@@ -282,17 +282,22 @@ static void netdev_console_shutdown(FAR struct uart_dev_s 
*dev)
 static int netdev_console_attach(FAR struct uart_dev_s *dev)
 {
   FAR struct netdev_consol_s *priv = (FAR struct netdev_consol_s *)dev;
+  int ret = -EINVAL;
 
   priv->rxdgram_off = 0;
   priv->rxdgram_len = 0;
 
+#ifdef CONFIG_CONSOLE_NETDEV_CAN
+  ret = netdev_console_can_init(dev);
+  if (ret < 0)
+#endif
+    {
 #ifdef CONFIG_CONSOLE_NETDEV_UDP
-  return netdev_console_udp_init(dev);
+      ret = netdev_console_udp_init(dev);
 #endif
+    }
 
-#ifdef CONFIG_CONSOLE_NETDEV_CAN
-  return netdev_console_can_init(dev);
-#endif
+  return ret;
 }
 
 /****************************************************************************

Reply via email to