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:
parent
63a847ebca
commit
3e41bd8b35
@ -790,6 +790,11 @@ static ssize_t uart_read(FAR struct file *filep,
|
|||||||
* IUCLC - Not Posix
|
* IUCLC - Not Posix
|
||||||
* IXON/OXOFF - no xon/xoff flow control.
|
* IXON/OXOFF - no xon/xoff flow control.
|
||||||
*/
|
*/
|
||||||
|
#else
|
||||||
|
if (dev->isconsole && ch == '\r')
|
||||||
|
{
|
||||||
|
ch = '\n';
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Store the received character */
|
/* 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_iflag = termiosp->c_iflag;
|
||||||
dev->tc_oflag = termiosp->c_oflag;
|
dev->tc_oflag = termiosp->c_oflag;
|
||||||
dev->tc_lflag = termiosp->c_lflag;
|
dev->tc_lflag = termiosp->c_lflag;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
break;
|
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 */
|
/* Enable \n -> \r\n translation for the console */
|
||||||
|
|
||||||
dev->tc_oflag = OPOST | ONLCR;
|
dev->tc_oflag = OPOST | ONLCR;
|
||||||
|
|
||||||
|
/* Convert CR to LF by default for console */
|
||||||
|
|
||||||
|
dev->tc_iflag |= ICRNL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user