nxscope/serial: ignore baud configuration if set to 0

This commit is contained in:
raiden00pl 2023-09-29 20:22:12 +02:00 committed by Petro Karashchenko
parent 85eb37c62b
commit f505b6cb08
3 changed files with 12 additions and 9 deletions

View File

@ -33,6 +33,8 @@ config EXAMPLES_NXSCOPE_SERIAL_PATH
config EXAMPLES_NXSCOPE_SERIAL_BAUD config EXAMPLES_NXSCOPE_SERIAL_BAUD
int "nxscope serial baud" int "nxscope serial baud"
default 115200 default 115200
---help---
Ignored if set to 0 (for example for RTT interface)
config EXAMPLES_NXSCOPE_CDCACM config EXAMPLES_NXSCOPE_CDCACM
bool "nxscope CDCACM device support" bool "nxscope CDCACM device support"

View File

@ -85,7 +85,7 @@ struct nxscope_ser_cfg_s
{ {
FAR char *path; /* Device path */ FAR char *path; /* Device path */
bool nonblock; /* Nonblocking operation */ bool nonblock; /* Nonblocking operation */
speed_t baud; /* Baud rate */ speed_t baud; /* Baud rate. Ignored if set to 0 */
}; };
#endif #endif

View File

@ -207,16 +207,17 @@ int nxscope_ser_init(FAR struct nxscope_intf_s *intf,
tcgetattr(priv->fd, &tio); tcgetattr(priv->fd, &tio);
#ifdef CONFIG_SERIAL_TERMIOS #ifdef CONFIG_SERIAL_TERMIOS
if (priv->cfg->baud > 0)
{
/* Configure a baud rate */ /* Configure a baud rate */
DEBUGASSERT(priv->cfg->baud > 0);
ret = cfsetspeed(&tio, priv->cfg->baud); ret = cfsetspeed(&tio, priv->cfg->baud);
if (ret < 0) if (ret < 0)
{ {
_err("ERROR: failed to set baud rate %d\n", errno); _err("ERROR: failed to set baud rate %d\n", errno);
goto errout; goto errout;
} }
}
#endif #endif
/* Configure RAW mode */ /* Configure RAW mode */