Skip to content

Commit

Permalink
system/cu: do not reset baud rate to zero when parity options are used
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
juniskane authored and xiaoxiang781216 committed Oct 19, 2020
1 parent a20cf09 commit 2b88677
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion system/cu/cu.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

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 */
pthread_t listener; /* Terminal listener thread */
};
Expand Down
16 changes: 8 additions & 8 deletions system/cu/cu_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ enum parity_mode

static struct cu_globals_s g_cu;
#ifdef CONFIG_SERIAL_TERMIOS
int fd_std_tty;
static int fd_std_tty;
static struct termios g_tio_std;
static struct termios g_tio_dev;
#endif
Expand Down Expand Up @@ -144,13 +144,6 @@ static int set_termios(int fd, int rate, enum parity_mode parity,

tio = g_tio_dev;

/* set baudrate */

if (rate != 0)
{
cfsetspeed(&tio, rate);
}

switch (parity)
{
case PARITY_EVEN:
Expand All @@ -165,6 +158,13 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
break;
}

/* set baudrate */

if (rate != 0)
{
cfsetspeed(&tio, rate);
}

if (rtscts)
{
tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW;
Expand Down

0 comments on commit 2b88677

Please sign in to comment.