From 341bfeb8b6e2e059fb3f7d65756957c0a1e95fe5 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 27 Jan 2022 12:02:05 -0800 Subject: [PATCH] cdcacm:support returning c_cflag & speed via termios Implementation was incomplete. This can now be used to pass the lincodeing information to a real serial port. --- drivers/usbdev/cdcacm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usbdev/cdcacm.c b/drivers/usbdev/cdcacm.c index 91c574b182..9c6536b883 100644 --- a/drivers/usbdev/cdcacm.c +++ b/drivers/usbdev/cdcacm.c @@ -2342,7 +2342,11 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) termiosp->c_iflag = serdev->tc_iflag; termiosp->c_oflag = serdev->tc_oflag; termiosp->c_lflag = serdev->tc_lflag; - termiosp->c_cflag = CS8; + termiosp->c_cflag = + ((priv->linecoding.parity != CDC_PARITY_NONE) ? PARENB : 0) | + ((priv->linecoding.parity == CDC_PARITY_ODD) ? PARODD : 0) | + ((priv->linecoding.stop == CDC_CHFMT_STOP2) ? CSTOPB : 0) | + CS8; #ifdef CONFIG_CDCACM_OFLOWCONTROL /* Report state of output flow control */ @@ -2354,6 +2358,10 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) termiosp->c_cflag |= (priv->iflow) ? CRTS_IFLOW : 0; #endif + cfsetispeed(termiosp, (speed_t) priv->linecoding.baud[3] << 24 | + (speed_t) priv->linecoding.baud[2] << 16 | + (speed_t) priv->linecoding.baud[1] << 8 | + (speed_t) priv->linecoding.baud[0]); } break;