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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2c1a615442d net: access the serial port in raw format to avoid 
character escaping
2c1a615442d is described below

commit 2c1a615442dcf6623e4b090e05cfa6fb9e4ee71c
Author: yinshengkai <[email protected]>
AuthorDate: Tue Nov 4 20:16:30 2025 +0800

    net: access the serial port in raw format to avoid character escaping
    
    If the serial port is set to isconsole,
    \n will be escaped as \r\n, causing communication failure.
    
    Signed-off-by: yinshengkai <[email protected]>
---
 drivers/net/slip.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 7227a150760..79e7f29bfb4 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -37,6 +37,7 @@
 #include <errno.h>
 #include <assert.h>
 #include <debug.h>
+#include <termios.h>
 
 #include <arpa/inet.h>
 
@@ -984,6 +985,9 @@ static int slip_txavail(FAR struct net_driver_s *dev)
 int slip_initialize(int intf, FAR const char *devname)
 {
   FAR struct slip_driver_s *self;
+#ifdef CONFIG_SERIAL_TERMIOS
+  struct termios termios;
+#endif
   int ret;
 
   /* Get the interface structure associated with this interface number. */
@@ -1006,6 +1010,22 @@ int slip_initialize(int intf, FAR const char *devname)
       return ret;
     }
 
+#ifdef CONFIG_SERIAL_TERMIOS
+  ret = file_ioctl(&self->tty, TCGETS, &termios);
+  if (ret >= 0)
+    {
+      cfmakeraw(&termios);
+      ret = file_ioctl(&self->tty, TCSETS, &termios);
+    }
+
+  if (ret < 0)
+    {
+      nerr("ERROR: Failed to get termios: %d\n", ret);
+      file_close(&self->tty);
+      return ret;
+    }
+#endif
+
   /* Put the interface in the down state.  This usually amounts to resetting
    * the device and/or calling slip_ifdown().
    */

Reply via email to