system/cu: do not reset baud rate to zero when parity options are used

cfsetspeed() now stores baud rate to c_cflag member of
struct termios, so it must not be overridden later on.

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
Juha Niskanen 2020-10-19 18:43:55 +03:00 committed by Xiang Xiao
parent a20cf0980d
commit 2b88677895
2 changed files with 9 additions and 9 deletions

View File

@ -70,7 +70,7 @@
struct cu_globals_s struct cu_globals_s
{ {
int infd; /* Incmoming data from serial port */ int infd; /* Incoming data from serial port */
int outfd; /* Outgoing data to serial port */ int outfd; /* Outgoing data to serial port */
pthread_t listener; /* Terminal listener thread */ pthread_t listener; /* Terminal listener thread */
}; };

View File

@ -82,7 +82,7 @@ enum parity_mode
static struct cu_globals_s g_cu; static struct cu_globals_s g_cu;
#ifdef CONFIG_SERIAL_TERMIOS #ifdef CONFIG_SERIAL_TERMIOS
int fd_std_tty; static int fd_std_tty;
static struct termios g_tio_std; static struct termios g_tio_std;
static struct termios g_tio_dev; static struct termios g_tio_dev;
#endif #endif
@ -144,13 +144,6 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
tio = g_tio_dev; tio = g_tio_dev;
/* set baudrate */
if (rate != 0)
{
cfsetspeed(&tio, rate);
}
switch (parity) switch (parity)
{ {
case PARITY_EVEN: case PARITY_EVEN:
@ -165,6 +158,13 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
break; break;
} }
/* set baudrate */
if (rate != 0)
{
cfsetspeed(&tio, rate);
}
if (rtscts) if (rtscts)
{ {
tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW; tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW;