mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 02:36:11 +08:00
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:
@@ -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().
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user