apps: Remove the check of CONFIG_SERIAL_TERMIOS

If the code only change c_oflag, c_iflag and c_lflag, not c_cflag in termios.
Follow up the change from kernel: https://github.com/apache/nuttx/pull/8843

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-03-20 01:07:21 +08:00 committed by patacongo
parent 369c354dc7
commit 86080a110e
21 changed files with 24 additions and 134 deletions

View File

@ -49,7 +49,6 @@
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <termios.h>
#include <signal.h>
#include <errno.h>
@ -67,11 +66,8 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_SERIAL_TERMIOS
# error "CONFIG_SERIAL_TERMIOS is needed by modbus example"
#endif
/* Configuration ************************************************************/
#ifndef CONFIG_EXAMPLES_MODBUS_PORT
# define CONFIG_EXAMPLES_MODBUS_PORT 0

View File

@ -50,10 +50,6 @@
/* modbus master port */
#ifndef CONFIG_SERIAL_TERMIOS
# error "CONFIG_SERIAL_TERMIOS is needed by modbus example"
#endif
#ifdef CONFIG_EXAMPLES_MODBUSMASTER_PORT
# define MBMASTER_PORT CONFIG_EXAMPLES_MODBUSMASTER_PORT
#else

View File

@ -330,7 +330,6 @@ int main(int argc, FAR char *argv[])
#endif
}
#ifdef CONFIG_SERIAL_TERMIOS
/* Enable \n -> \r\n conversion during write */
ret = tcgetattr(termpair.fd_uart, &tio);
@ -347,7 +346,6 @@ int main(int argc, FAR char *argv[])
fprintf(stderr, "ERROR: tcsetattr() failed: %d\n", errno);
goto error_serial;
}
#endif
printf("Starting a new NSH Session using %s\n", buffer);

View File

@ -388,11 +388,7 @@ int FS_opendev(int chn, int infd, int outfd)
g_file[chn] = malloc(sizeof(struct FileStream));
g_file[chn]->dev = 1;
#ifdef CONFIG_SERIAL_TERMIOS
g_file[chn]->tty = (infd == 0 ? isatty(infd) && isatty(outfd) : 0);
#else
g_file[chn]->tty = 1;
#endif
g_file[chn]->recLength = 1;
g_file[chn]->infd = infd;
g_file[chn]->inSize = 0;
@ -781,12 +777,10 @@ int FS_close(int dev)
return 0;
}
#ifdef CONFIG_SERIAL_TERMIOS
int FS_istty(int chn)
{
return (g_file[chn] && g_file[chn]->tty);
}
#endif
int FS_lock(int chn, off_t offset, off_t length, int mode, int w)
{

View File

@ -112,13 +112,7 @@ int FS_openbinaryChn(int chn, const char *name, int mode);
int FS_freechn(void);
int FS_flush(int dev);
int FS_close(int dev);
#ifdef CONFIG_SERIAL_TERMIOS
int FS_istty(int chn);
#else
# define FS_istty(chn) (1)
#endif
int FS_lock(int chn, off_t offset, off_t length, int mode, int w);
int FS_truncate(int chn);
void FS_shellmode(int chn);

View File

@ -4163,11 +4163,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file)
b->yy_bs_column = 0;
}
#ifdef CONFIG_SERIAL_TERMIOS
b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0;
#else
b->yy_is_interactive = 1;
#endif
errno = oerrno;
}

View File

@ -130,12 +130,6 @@ else
CFLAGS += -DENABLE_PTHREAD=0
endif
ifeq ($(CONFIG_SERIAL_TERMIOS),y)
CFLAGS += -DHAVE_TERMIOS_H
else
CFLAGS += -DHAVE_TERMIOS_H=0
endif
CFLAGS += -DEL_LOG_MAX=$(CONFIG_EMBEDLOG_LOG_MAX)
CFLAGS += -DEL_MEM_LINE_SIZE=$(CONFIG_EMBEDLOG_MEM_LINE_SIZE)
@ -151,6 +145,7 @@ CFLAGS += -DHAVE_ACCESS=0
CFLAGS += -DENABLE_REENTRANT
CFLAGS += -DENABLE_OUT_SYSLOG
CFLAGS += -DHAVE_STAT
CFLAGS += -DHAVE_TERMIOS_H
CFLAGS += -DHAVE_UNISTD_H
CFLAGS += -DHAVE_FSYNC
CFLAGS += -DHAVE_FILENO

View File

@ -11,7 +11,6 @@ if LOGGING_NXSCOPE
config LOGGING_NXSCOPE_INTF_SERIAL
bool "NxScope serial port interface support"
select SERIAL_TERMIOS
default n
---help---
For details, see logging/nxscope/nxscope_iserial.c

View File

@ -33,14 +33,6 @@
#include <logging/nxscope/nxscope.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_SERIAL_TERMIOS
# error Termios support must be enabled
#endif
/****************************************************************************
* Private Type Definition
****************************************************************************/
@ -214,6 +206,7 @@ int nxscope_ser_init(FAR struct nxscope_intf_s *intf,
tcgetattr(priv->fd, &tio);
#ifdef CONFIG_SERIAL_TERMIOS
/* Configure a baud rate */
DEBUGASSERT(priv->cfg->baud > 0);
@ -224,6 +217,7 @@ int nxscope_ser_init(FAR struct nxscope_intf_s *intf,
_err("ERROR: failed to set baud rate %d\n", errno);
goto errout;
}
#endif
/* Configure RAW mode */

View File

@ -110,9 +110,8 @@ The NuttX-named configuration options that are available include:
See also other serial settings, in particular:
- `CONFIG_SERIAL_TERMIOS` Serial driver supports `termios.h` interfaces
(`tcsetattr`, `tcflush`, etc.). If this is not defined, then the terminal
settings (baud, parity, etc.) are not configurable at runtime; serial streams
will not be flushed when closed.
If this is not defined, then the terminal settings (baud, parity, etc.)
are not configurable at runtime.
## Note

View File

@ -45,10 +45,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#ifdef CONFIG_SERIAL_TERMIOS
# include <termios.h>
#endif
#include <termios.h>
#include "port.h"
@ -78,9 +75,7 @@ static uint8_t ucBuffer[BUF_SIZE];
static int uiRxBufferPos;
static int uiTxBufferPos;
#ifdef CONFIG_SERIAL_TERMIOS
static struct termios xOldTIO;
#endif
/****************************************************************************
* Private Function Prototypes
@ -182,9 +177,7 @@ void vMBPortSerialEnable(bool bEnableRx, bool bEnableTx)
if (bEnableRx)
{
#ifdef CONFIG_SERIAL_TERMIOS
tcflush(iSerialFd, TCIFLUSH);
#endif
uiRxBufferPos = 0;
bRxEnabled = true;
}
@ -209,10 +202,7 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
{
char szDevice[16];
bool bStatus = true;
#ifdef CONFIG_SERIAL_TERMIOS
struct termios xNewTIO;
#endif
snprintf(szDevice, 16, "/dev/ttyS%d", ucPort);
@ -222,8 +212,6 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
szDevice, errno);
bStatus = false;
}
#ifdef CONFIG_SERIAL_TERMIOS
else if (tcgetattr(iSerialFd, &xOldTIO) != 0)
{
vMBPortLog(MB_LOG_ERROR, "SER-INIT", "Can't get settings from port %s: %d\n",
@ -298,7 +286,6 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
}
}
}
#endif
return bStatus;
}
@ -321,9 +308,7 @@ void vMBPortClose(void)
{
if (iSerialFd != -1)
{
#ifdef CONFIG_SERIAL_TERMIOS
tcsetattr(iSerialFd, TCSANOW, &xOldTIO);
#endif
close(iSerialFd);
iSerialFd = -1;
}

View File

@ -46,10 +46,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#ifdef CONFIG_SERIAL_TERMIOS
# include <termios.h>
#endif
#include <termios.h>
#include "port.h"
@ -82,9 +79,7 @@ static uint8_t ucBuffer[BUF_SIZE];
static int uiRxBufferPos;
static int uiTxBufferPos;
#ifdef CONFIG_SERIAL_TERMIOS
static struct termios xOldTIO;
#endif
/****************************************************************************
* Private Function Prototypes
@ -186,9 +181,7 @@ void vMBMasterPortSerialEnable(bool bEnableRx, bool bEnableTx)
if (bEnableRx)
{
#ifdef CONFIG_SERIAL_TERMIOS
tcflush(iSerialFd, TCIFLUSH);
#endif
uiRxBufferPos = 0;
bRxEnabled = true;
}
@ -213,10 +206,7 @@ bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
{
char szDevice[16];
bool bStatus = true;
#ifdef CONFIG_SERIAL_TERMIOS
struct termios xNewTIO;
#endif
snprintf(szDevice, 16, "/dev/ttyS%d", ucPort);
@ -227,8 +217,6 @@ bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
szDevice, errno);
bStatus = false;
}
#ifdef CONFIG_SERIAL_TERMIOS
else if (tcgetattr(iSerialFd, &xOldTIO) != 0)
{
vMBMasterPortLog(MB_LOG_ERROR, "SER-INIT",
@ -307,7 +295,6 @@ bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
}
}
}
#endif
return bStatus;
}
@ -330,9 +317,7 @@ void vMBMasterPortClose( void )
{
if (iSerialFd != -1)
{
#ifdef CONFIG_SERIAL_TERMIOS
tcsetattr(iSerialFd, TCSANOW, &xOldTIO);
#endif
close(iSerialFd);
iSerialFd = -1;
}

View File

@ -149,11 +149,9 @@ int nsh_login(FAR struct console_stdio_s *pstate)
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
char challenge[128];
#endif
struct termios cfg;
int ret;
int i;
#ifdef CONFIG_SERIAL_TERMIOS
struct termios cfg;
#endif
#ifdef CONFIG_NSH_PLATFORM_SKIP_LOGIN
if (platform_skip_login() == OK)
@ -199,7 +197,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
/* Disable ECHO if its a tty device */
#ifdef CONFIG_SERIAL_TERMIOS
if (isatty(INFD(pstate)))
{
if (tcgetattr(INFD(pstate), &cfg) == 0)
@ -208,7 +205,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
tcsetattr(INFD(pstate), TCSANOW, &cfg);
}
}
#endif
password[0] = '\0';
ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
@ -216,7 +212,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
/* Enable echo again after password */
#ifdef CONFIG_SERIAL_TERMIOS
if (isatty(INFD(pstate)))
{
if (tcgetattr(INFD(pstate), &cfg) == 0)
@ -225,7 +220,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
tcsetattr(INFD(pstate), TCSANOW, &cfg);
}
}
#endif
if (ret > 0)
{

View File

@ -83,11 +83,9 @@ enum parity_mode
****************************************************************************/
static struct cu_globals_s g_cu;
#ifdef CONFIG_SERIAL_TERMIOS
static int fd_std_tty;
static struct termios g_tio_std;
static struct termios g_tio_dev;
#endif
/****************************************************************************
* Public Data
@ -135,6 +133,9 @@ static void sigint(int sig)
#ifdef CONFIG_SERIAL_TERMIOS
static int set_termios(int fd, int rate, enum parity_mode parity,
int rtscts, int nocrlf)
#else
static int set_termios(int fd, int nocrlf)
#endif
{
int rc = 0;
int ret;
@ -142,6 +143,7 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
tio = g_tio_dev;
#ifdef CONFIG_SERIAL_TERMIOS
tio.c_cflag &= ~(PARENB | PARODD | CRTSCTS);
switch (parity)
@ -169,6 +171,7 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
{
tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW;
}
#endif
tio.c_oflag = OPOST;
@ -228,7 +231,6 @@ static int retrieve_termios(int fd)
return 0;
}
#endif
static void print_help(void)
{
@ -239,15 +241,13 @@ static void print_help(void)
" -o: Set odd parity\n"
" -s: Use given speed (default %d)\n"
" -r: Disable RTS/CTS flow control (default: on)\n"
" -c: Disable lf -> crlf conversion (default: off)\n"
#endif
" -c: Disable lf -> crlf conversion (default: off)\n"
" -f: Enable endless mode without escape sequence (default: off)\n"
" -?: This help\n",
#ifdef CONFIG_SERIAL_TERMIOS
CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE,
CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD
#else
CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE
#ifdef CONFIG_SERIAL_TERMIOS
, CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD
#endif
);
}
@ -297,8 +297,8 @@ int main(int argc, FAR char *argv[])
int baudrate = CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD;
enum parity_mode parity = PARITY_NONE;
int rtscts = 1;
int nocrlf = 0;
#endif
int nocrlf = 0;
int nobreak = 0;
int option;
int ret;
@ -342,11 +342,11 @@ int main(int argc, FAR char *argv[])
case 'r':
rtscts = 0;
break;
#endif
case 'c':
nocrlf = 1;
break;
#endif
case 'f':
nobreak = 1;
@ -381,7 +381,6 @@ int main(int argc, FAR char *argv[])
goto errout_with_devinit;
}
#ifdef CONFIG_SERIAL_TERMIOS
/* remember serial device termios attributes */
ret = tcgetattr(g_cu.outfd, &g_tio_dev);
@ -417,11 +416,14 @@ int main(int argc, FAR char *argv[])
tcgetattr(fd_std_tty, &g_tio_std);
}
#ifdef CONFIG_SERIAL_TERMIOS
if (set_termios(g_cu.outfd, baudrate, parity, rtscts, nocrlf) != 0)
#else
if (set_termios(g_cu.outfd, nocrlf) != 0)
#endif
{
goto errout_with_outfd_retrieve;
}
#endif
/* Open the serial device for reading. Since we are already connected,
* this should not fail.
@ -521,10 +523,8 @@ int main(int argc, FAR char *argv[])
errout_with_fds:
close(g_cu.infd);
#ifdef CONFIG_SERIAL_TERMIOS
errout_with_outfd_retrieve:
retrieve_termios(g_cu.outfd);
#endif
errout_with_outfd:
close(g_cu.outfd);
errout_with_devinit:

View File

@ -538,7 +538,6 @@ int main(int argc, FAR char *argv[])
{
/* stdin stdout */
#ifdef CONFIG_SERIAL_TERMIOS
if (!g_force)
{
if ((g_mode == UNCOMPRESS) && isatty(0))
@ -557,7 +556,6 @@ int main(int argc, FAR char *argv[])
lzf_exit(1);
}
}
#endif
if (g_mode == COMPRESS)
{

View File

@ -75,9 +75,7 @@ struct tcurses_vt100_s
int out_fd;
int keycount;
char keybuf[16];
#ifdef CONFIG_SERIAL_TERMIOS
tcflag_t lflag;
#endif
};
/************************************************************************************
@ -1469,9 +1467,7 @@ static bool tcurses_vt100_checkkey(FAR struct termcurses_s *dev)
FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
{
FAR struct tcurses_vt100_s *priv;
#ifdef CONFIG_SERIAL_TERMIOS
struct termios cfg;
#endif
/* Allocate a new device structure */
@ -1490,7 +1486,6 @@ FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
priv->out_fd = out_fd;
priv->keycount = 0;
#ifdef CONFIG_SERIAL_TERMIOS
if (isatty(priv->in_fd))
{
if (tcgetattr(priv->in_fd, &cfg) == 0)
@ -1516,7 +1511,6 @@ FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
priv->lflag = 0;
}
}
#endif
return (FAR struct termcurses_s *)priv;
}
@ -1532,10 +1526,8 @@ FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
static int tcurses_vt100_terminate(FAR struct termcurses_s *dev)
{
FAR struct tcurses_vt100_s *priv;
int fd;
#ifdef CONFIG_SERIAL_TERMIOS
struct termios cfg;
#endif
int fd;
priv = (FAR struct tcurses_vt100_s *)dev;
fd = priv->out_fd;
@ -1546,7 +1538,6 @@ static int tcurses_vt100_terminate(FAR struct termcurses_s *dev)
write(fd, g_setdefcolors, strlen(g_setdefcolors));
#ifdef CONFIG_SERIAL_TERMIOS
if (isatty(priv->in_fd))
{
if (tcgetattr(priv->in_fd, &cfg) == 0 && priv->lflag & ECHO)
@ -1555,7 +1546,6 @@ static int tcurses_vt100_terminate(FAR struct termcurses_s *dev)
tcsetattr(priv->in_fd, TCSANOW, &cfg);
}
}
#endif
return OK;
}

View File

@ -5,7 +5,6 @@
config SYSTEM_YMODEM
tristate "YMODEM"
depends on SERIAL_TERMIOS
---help---
Enable support for ymodem.

View File

@ -69,9 +69,7 @@ int main(int argc, FAR char *argv[])
FAR const char *devname = CONFIG_SYSTEM_ZMODEM_DEVNAME;
FAR const char *pathname = CONFIG_SYSTEM_ZMODEM_MOUNTPOINT;
int exitcode = EXIT_FAILURE;
#ifdef CONFIG_SERIAL_TERMIOS
struct termios saveterm;
#endif
int option;
int ret;
int fd;
@ -124,7 +122,6 @@ int main(int argc, FAR char *argv[])
goto errout;
}
#ifdef CONFIG_SERIAL_TERMIOS
/* Save the current terminal setting */
tcgetattr(fd, &saveterm);
@ -137,7 +134,6 @@ int main(int argc, FAR char *argv[])
/* Enable hardware Rx/Tx flow control */
zm_flowc(fd);
#endif
#endif
/* Get the Zmodem handle */
@ -164,18 +160,13 @@ errout_with_zmodem:
zmr_release(handle);
errout_with_device:
#ifdef CONFIG_SERIAL_TERMIOS
#ifdef CONFIG_SYSTEM_ZMODEM_FLOWC
/* Flush the serial output to assure do not hang trying to drain it */
tcflush(fd, TCIOFLUSH);
#endif
/* Restore the saved terminal setting */
tcsetattr(fd, TCSANOW, &saveterm);
#endif
close(fd);
errout:

View File

@ -88,9 +88,7 @@ int main(int argc, FAR char *argv[])
bool skip = false;
long tmp;
int exitcode = EXIT_FAILURE;
#ifdef CONFIG_SERIAL_TERMIOS
struct termios saveterm;
#endif
int option;
int ret;
int fd;
@ -177,7 +175,6 @@ int main(int argc, FAR char *argv[])
goto errout;
}
#ifdef CONFIG_SERIAL_TERMIOS
/* Save the current terminal setting */
tcgetattr(fd, &saveterm);
@ -190,7 +187,6 @@ int main(int argc, FAR char *argv[])
/* Enable hardware Rx/Tx flow control */
zm_flowc(fd);
#endif
#endif
/* Get the Zmodem handle */
@ -264,18 +260,13 @@ errout_with_zmodem:
zms_release(handle);
errout_with_device:
#ifdef CONFIG_SERIAL_TERMIOS
# ifdef CONFIG_SYSTEM_ZMODEM_FLOWC
/* Flush the serial output to assure do not hang trying to drain it */
tcflush(fd, TCIOFLUSH);
#endif
/* Restore the saved terminal setting */
tcsetattr(fd, TCSANOW, &saveterm);
#endif
close(fd);
errout:

View File

@ -577,9 +577,7 @@ uint32_t zm_filecrc(FAR struct zm_state_s *pzm, FAR const char *filename);
*
****************************************************************************/
#ifdef CONFIG_SERIAL_TERMIOS
void zm_rawmode(int fd);
#endif
/****************************************************************************
* Name: zm_flowc

View File

@ -476,7 +476,6 @@ uint32_t zm_filecrc(FAR struct zm_state_s *pzm, FAR const char *filename)
*
****************************************************************************/
#ifdef CONFIG_SERIAL_TERMIOS
void zm_rawmode(int fd)
{
struct termios term;
@ -485,7 +484,6 @@ void zm_rawmode(int fd)
cfmakeraw(&term);
tcsetattr(fd, TCSANOW, &term);
}
#endif
/****************************************************************************
* Name: zm_flowc