From f505b6cb0868f308fa4217040896c24b42ae9d02 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 29 Sep 2023 20:22:12 +0200 Subject: [PATCH] nxscope/serial: ignore baud configuration if set to 0 --- examples/nxscope/Kconfig | 2 ++ include/logging/nxscope/nxscope_intf.h | 2 +- logging/nxscope/nxscope_iser.c | 17 +++++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/nxscope/Kconfig b/examples/nxscope/Kconfig index 33cabeb61..1d453d2de 100644 --- a/examples/nxscope/Kconfig +++ b/examples/nxscope/Kconfig @@ -33,6 +33,8 @@ config EXAMPLES_NXSCOPE_SERIAL_PATH config EXAMPLES_NXSCOPE_SERIAL_BAUD int "nxscope serial baud" default 115200 + ---help--- + Ignored if set to 0 (for example for RTT interface) config EXAMPLES_NXSCOPE_CDCACM bool "nxscope CDCACM device support" diff --git a/include/logging/nxscope/nxscope_intf.h b/include/logging/nxscope/nxscope_intf.h index 0a4aa412a..61f7e7099 100644 --- a/include/logging/nxscope/nxscope_intf.h +++ b/include/logging/nxscope/nxscope_intf.h @@ -85,7 +85,7 @@ struct nxscope_ser_cfg_s { FAR char *path; /* Device path */ bool nonblock; /* Nonblocking operation */ - speed_t baud; /* Baud rate */ + speed_t baud; /* Baud rate. Ignored if set to 0 */ }; #endif diff --git a/logging/nxscope/nxscope_iser.c b/logging/nxscope/nxscope_iser.c index 816c096a6..d91cf61d5 100644 --- a/logging/nxscope/nxscope_iser.c +++ b/logging/nxscope/nxscope_iser.c @@ -207,15 +207,16 @@ int nxscope_ser_init(FAR struct nxscope_intf_s *intf, tcgetattr(priv->fd, &tio); #ifdef CONFIG_SERIAL_TERMIOS - /* Configure a baud rate */ - - DEBUGASSERT(priv->cfg->baud > 0); - - ret = cfsetspeed(&tio, priv->cfg->baud); - if (ret < 0) + if (priv->cfg->baud > 0) { - _err("ERROR: failed to set baud rate %d\n", errno); - goto errout; + /* Configure a baud rate */ + + ret = cfsetspeed(&tio, priv->cfg->baud); + if (ret < 0) + { + _err("ERROR: failed to set baud rate %d\n", errno); + goto errout; + } } #endif