You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/10/19 17:09:31 UTC
[incubator-nuttx-apps] 02/02: system/cu: do not reset baud rate to
zero when parity options are used
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit 2b886778957af3ab8d6445d1d2f21cbc4426e66d
Author: Juha Niskanen <ju...@haltian.com>
AuthorDate: Mon Oct 19 18:43:55 2020 +0300
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 <ju...@haltian.com>
---
system/cu/cu.h | 2 +-
system/cu/cu_main.c | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/system/cu/cu.h b/system/cu/cu.h
index 9ca6c78..f16aec1 100644
--- a/system/cu/cu.h
+++ b/system/cu/cu.h
@@ -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 */
};
diff --git a/system/cu/cu_main.c b/system/cu/cu_main.c
index d914284..621088d 100644
--- a/system/cu/cu_main.c
+++ b/system/cu/cu_main.c
@@ -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
@@ -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:
@@ -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;