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 <yinshengkai@bytedance.com>
This commit is contained in:
yinshengkai
2025-11-04 20:16:30 +08:00
committed by Donny(董九柱)
parent f9c5647813
commit 2c1a615442
+20
View File
@@ -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().
*/