From 2c1a615442dcf6623e4b090e05cfa6fb9e4ee71c Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Tue, 4 Nov 2025 20:16:30 +0800 Subject: [PATCH] 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 --- 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 #include #include +#include #include @@ -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(). */