diff --git a/boards/z80/ez80/z20x/src/w25_main.c b/boards/z80/ez80/z20x/src/w25_main.c index 138b28a5a0e..fbd19d9d0f7 100644 --- a/boards/z80/ez80/z20x/src/w25_main.c +++ b/boards/z80/ez80/z20x/src/w25_main.c @@ -545,7 +545,6 @@ static int w25_boot_program(void) return ret; } -#ifdef CONFIG_SERIAL_TERMIOS /* Drain all pending Tx output in stdout. "Booting..." message will be * lost if the outgoing Tx bytes are not drained. */ @@ -557,7 +556,6 @@ static int w25_boot_program(void) fprintf(stderr, "ERROR: tcdrain() failed: %d\n", ret); return ret; } -#endif /* Start the successfully loaded program */ diff --git a/drivers/sensors/wtgahrs2.c b/drivers/sensors/wtgahrs2.c index 8b349fea448..84ce9ef9b88 100644 --- a/drivers/sensors/wtgahrs2.c +++ b/drivers/sensors/wtgahrs2.c @@ -433,9 +433,7 @@ int wtgahrs2_initialize(FAR const char *path, int devno) { FAR struct wtgahrs2_dev_s *rtdata; FAR struct wtgahrs2_sensor_s *tmp; -#ifdef CONFIG_SERIAL_TERMIOS struct termios opt; -#endif FAR char *argv[2]; char arg1[16]; int ret; @@ -462,14 +460,16 @@ int wtgahrs2_initialize(FAR const char *path, int devno) goto open_err; } -#ifdef CONFIG_SERIAL_TERMIOS file_ioctl(&rtdata->file, TCGETS, &opt); cfmakeraw(&opt); + +#ifdef CONFIG_SERIAL_TERMIOS cfsetispeed(&opt, B115200); cfsetospeed(&opt, B115200); - file_ioctl(&rtdata->file, TCSETS, &opt); #endif + file_ioctl(&rtdata->file, TCSETS, &opt); + /* Accelerometer register */ tmp = &rtdata->dev[WTGAHRS2_ACCEL_IDX]; diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index b22bac4df73..421c2514bea 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -169,9 +169,10 @@ config SERIAL_TERMIOS depends on ARCH_HAVE_SERIAL_TERMIOS default n ---help--- - 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 cannot be flushed, etc.. + If this is not defined, then the terminal hardware setting + (baud, parity, flow control) is not configurable at runtime. + Note: other software setting (echo, \r\n<->\n, break, tcflush) + is always supported. config TTY_LAUNCH bool "Enable feature TTY launch program" diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 89c76409699..bd869e4415a 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -73,9 +73,7 @@ struct pty_dev_s struct file pd_src; /* Provides data to read() method (pipe output) */ struct file pd_sink; /* Accepts data from write() method (pipe input) */ bool pd_master; /* True: this is the master */ -#ifdef CONFIG_SERIAL_TERMIOS tcflag_t pd_iflag; /* Terminal input modes */ -#endif tcflag_t pd_oflag; /* Terminal output modes */ struct pty_poll_s pd_poll[CONFIG_DEV_PTY_NPOLLWAITERS]; }; @@ -394,18 +392,15 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) FAR struct inode *inode; FAR struct pty_dev_s *dev; ssize_t ntotal; -#ifdef CONFIG_SERIAL_TERMIOS ssize_t i; ssize_t j; char ch; -#endif DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; dev = inode->i_private; DEBUGASSERT(dev != NULL); -#ifdef CONFIG_SERIAL_TERMIOS /* Do input processing if any is enabled * * Specifically not handled: @@ -460,7 +455,6 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len) } } else -#endif { /* NOTE: the source pipe will block if no data is available in * the pipe. Otherwise, it will return data from the pipe. If @@ -681,7 +675,6 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; -#ifdef CONFIG_SERIAL_TERMIOS case TCGETS: { FAR struct termios *termiosp = (FAR struct termios *)arg; @@ -718,7 +711,6 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ret = OK; } break; -#endif /* Get the number of bytes that are immediately available for reading * from the source pipe. diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 2a24f5dac39..dea33b0a796 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -315,7 +315,6 @@ static inline ssize_t uart_irqwrite(FAR uart_dev_t *dev, { int ch = *buffer++; -#ifdef CONFIG_SERIAL_TERMIOS /* Do output post-processing */ if ((dev->tc_oflag & OPOST) != 0) @@ -335,15 +334,6 @@ static inline ssize_t uart_irqwrite(FAR uart_dev_t *dev, } } -#else /* !CONFIG_SERIAL_TERMIOS */ - /* If this is the console, then we should replace LF with CR-LF */ - - if (dev->isconsole && ch == '\n') - { - uart_putc(dev, '\r'); - } -#endif - /* Output the character, using the low-level direct UART interfaces */ uart_putc(dev, ch); @@ -847,7 +837,6 @@ static ssize_t uart_read(FAR struct file *filep, rxbuf->tail = tail; -#ifdef CONFIG_SERIAL_TERMIOS /* Do input processing if any is enabled */ if (dev->tc_iflag & (INLCR | IGNCR | ICRNL)) @@ -879,25 +868,13 @@ static ssize_t uart_read(FAR struct file *filep, * IUCLC - Not Posix * IXON/OXOFF - no xon/xoff flow control. */ -#else - if (dev->isconsole && ch == '\r') - { - ch = '\n'; - } -#endif /* Store the received character */ *buffer++ = ch; recvd++; - if ( -#ifdef CONFIG_SERIAL_TERMIOS - dev->tc_lflag & ECHO -#else - dev->isconsole -#endif - ) + if (dev->tc_lflag & ECHO) { /* Check for the beginning of a VT100 escape sequence, 3 byte */ @@ -1271,7 +1248,6 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, ch = *buffer++; ret = OK; -#ifdef CONFIG_SERIAL_TERMIOS /* Do output post-processing */ if ((dev->tc_oflag & OPOST) != 0) @@ -1299,15 +1275,6 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, */ } -#else /* !CONFIG_SERIAL_TERMIOS */ - /* If this is the console, convert \n -> \r\n */ - - if (dev->isconsole && ch == '\n') - { - ret = uart_putxmitchar(dev, '\r', oktoblock); - } -#endif - /* Put the character into the transmit buffer */ if (ret >= 0) @@ -1550,7 +1517,6 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } } -#ifdef CONFIG_SERIAL_TERMIOS /* Append any higher level TTY flags */ if (ret == OK || ret == -ENOTTY) @@ -1599,7 +1565,6 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; } } -#endif return ret; } @@ -1817,7 +1782,6 @@ int uart_register(FAR const char *path, FAR uart_dev_t *dev) dev->pid = INVALID_PROCESS_ID; #endif -#ifdef CONFIG_SERIAL_TERMIOS /* If this UART is a serial console */ if (dev->isconsole) @@ -1838,7 +1802,6 @@ int uart_register(FAR const char *path, FAR uart_dev_t *dev) dev->escape = 0; } -#endif /* Initialize mutex & semaphores */ @@ -2031,11 +1994,7 @@ int uart_check_special(FAR uart_dev_t *dev, const char *buf, size_t size) { size_t i; -#ifdef CONFIG_SERIAL_TERMIOS if ((dev->tc_lflag & ISIG) == 0) -#else - if (!dev->isconsole) -#endif { return 0; } diff --git a/include/nuttx/serial/serial.h b/include/nuttx/serial/serial.h index e1a094d0d3d..e784a9257fa 100644 --- a/include/nuttx/serial/serial.h +++ b/include/nuttx/serial/serial.h @@ -284,13 +284,11 @@ struct uart_dev_s pid_t pid; /* Thread PID to receive signals (-1 if none) */ #endif -#ifdef CONFIG_SERIAL_TERMIOS /* Terminal control flags */ tcflag_t tc_iflag; /* Input modes */ tcflag_t tc_oflag; /* Output modes */ tcflag_t tc_lflag; /* Local modes */ -#endif /* Semaphores & mutex */ diff --git a/include/pty.h b/include/pty.h index bf8577690ac..2844d4d3eba 100644 --- a/include/pty.h +++ b/include/pty.h @@ -31,7 +31,7 @@ #include #include -#if defined(CONFIG_SERIAL_TERMIOS) && defined(CONFIG_PSEUDOTERM) +#ifdef CONFIG_PSEUDOTERM /**************************************************************************** * Public Function Prototypes @@ -59,5 +59,5 @@ int openpty(FAR int *master, FAR int *slave, FAR char *name, } #endif -#endif /* CONFIG_SERIAL_TERMIOS && CONFIG_PSEUDOTERM */ +#endif /* CONFIG_PSEUDOTERM */ #endif /* __INCLUDE_PTY_H */ diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv index 5059f905cb5..f2ebdbe7b8c 100644 --- a/libs/libc/libc.csv +++ b/libs/libc/libc.csv @@ -25,8 +25,8 @@ "basename","libgen.h","","FAR char *","FAR char *" "btowc","wchar.h","","wint_t","int" "calloc","stdlib.h","","FAR void *","size_t","size_t" -"cfgetspeed","termios.h","defined(CONFIG_SERIAL_TERMIOS)","speed_t","FAR const struct termios *" -"cfsetspeed","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","FAR struct termios *","speed_t" +"cfgetspeed","termios.h","","speed_t","FAR const struct termios *" +"cfsetspeed","termios.h","","int","FAR struct termios *","speed_t" "chdir","unistd.h","!defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char *" "clock","time.h","","clock_t" "crc32","nuttx/crc32.h","","uint32_t","FAR const uint8_t *","size_t" @@ -256,9 +256,9 @@ "swab","unistd.h","","void","FAR const void *","FAR void *","ssize_t" "swprintf","wchar.h","","int","FAR wchar_t *","size_t","FAR const wchar_t *","..." "syslog","syslog.h","","void","int","FAR const IPTR char *","..." -"tcflush","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","int","int" -"tcgetattr","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","int","FAR struct termios *" -"tcsetattr","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","int","int","FAR const struct termios *" +"tcflush","termios.h","","int","int","int" +"tcgetattr","termios.h","","int","int","FAR struct termios *" +"tcsetattr","termios.h","","int","int","int","FAR const struct termios *" "telldir","dirent.h","","off_t","FAR DIR *" "time","time.h","","time_t","FAR time_t *" "tolower","ctype.h","","int","int" diff --git a/libs/libc/termios/Make.defs b/libs/libc/termios/Make.defs index 7e1217c6640..fcb1dc7f33a 100644 --- a/libs/libc/termios/Make.defs +++ b/libs/libc/termios/Make.defs @@ -18,9 +18,6 @@ # ############################################################################ -# termios.h support requires file descriptors and that CONFIG_SERIAL_TERMIOS -# is defined - # Add the termios C files to the build CSRCS += lib_cfspeed.c lib_cfmakeraw.c lib_isatty.c lib_tcflush.c diff --git a/libs/libc/termios/lib_cfmakeraw.c b/libs/libc/termios/lib_cfmakeraw.c index faad8803056..ea84d4632d8 100644 --- a/libs/libc/termios/lib_cfmakeraw.c +++ b/libs/libc/termios/lib_cfmakeraw.c @@ -50,6 +50,8 @@ void cfmakeraw(FAR struct termios *termiosp) | INLCR | IGNCR | ICRNL | IXON); termiosp->c_oflag &= ~OPOST; termiosp->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); +#ifdef CONFIG_SERIAL_TERMIOS termiosp->c_cflag &= ~(CSIZE | PARENB); termiosp->c_cflag |= CS8; +#endif } diff --git a/libs/libc/termios/lib_isatty.c b/libs/libc/termios/lib_isatty.c index 6dffb3e4858..b3b236c2483 100644 --- a/libs/libc/termios/lib_isatty.c +++ b/libs/libc/termios/lib_isatty.c @@ -46,8 +46,6 @@ * responds wo tcgetattr() without an error -- that it, the driver supports * the NuttX TCGETS ioctl command. * - * Of course, that can only be true if CONFIG_SERIAL_TERMIOS=y. - * ****************************************************************************/ int isatty(int fd)