mirror of
https://github.com/apache/nuttx.git
synced 2026-03-27 02:29:15 +08:00
driver/serial: Convert CR to LF in driver
Enable the behavior by default for console,
but configurable by termios.
Binary size:
Before:
text data bss dec hex filename
326460 409 8164 335033 51cb9 nuttx/nuttx
After:
text data bss dec hex filename
326478 409 8164 335051 51ccb nuttx/nuttx
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
@@ -790,6 +790,11 @@ 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 */
|
||||
@@ -1423,7 +1428,6 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
dev->tc_iflag = termiosp->c_iflag;
|
||||
dev->tc_oflag = termiosp->c_oflag;
|
||||
dev->tc_lflag = termiosp->c_lflag;
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
@@ -1659,6 +1663,10 @@ int uart_register(FAR const char *path, FAR uart_dev_t *dev)
|
||||
/* Enable \n -> \r\n translation for the console */
|
||||
|
||||
dev->tc_oflag = OPOST | ONLCR;
|
||||
|
||||
/* Convert CR to LF by default for console */
|
||||
|
||||
dev->tc_iflag |= ICRNL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user