Serial FIONREAD, FIONWRITE, and TERMIOS I/O processing from Mike Smith, Andrew Tridgell, and and Lorenz Meier

This commit is contained in:
Gregory Nutt
2013-08-10 19:14:05 -06:00
parent 97e13b33ab
commit 82b528e0c8
5 changed files with 269 additions and 17 deletions
+43 -4
View File
@@ -941,7 +941,7 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
priv->usbdev = dev;
/* Save the reference to our private data structure in EP0 so that it
* can be recovered in ep0 completion events (Unless we are part of
* can be recovered in ep0 completion events (Unless we are part of
* a composite device and, in that case, the composite device owns
* EP0).
*/
@@ -1804,9 +1804,10 @@ static void cdcuart_detach(FAR struct uart_dev_s *dev)
static int cdcuart_ioctl(FAR struct file *filep,int cmd,unsigned long arg)
{
struct inode *inode = filep->f_inode;
struct cdcacm_dev_s *priv = inode->i_private;
int ret = OK;
struct inode *inode = filep->f_inode;
struct cdcacm_dev_s *priv = inode->i_private;
FAR uart_dev_t *serdev = &priv->serdev;
int ret = OK;
switch (cmd)
{
@@ -1898,6 +1899,44 @@ static int cdcuart_ioctl(FAR struct file *filep,int cmd,unsigned long arg)
}
break;
#ifdef CONFIG_SERIAL_TERMIOS
case TCGETS:
{
struct termios *termiosp = (struct termios*)arg;
if (!termiosp)
{
ret = -EINVAL;
break;
}
/* And update with flags from this layer */
termiosp->c_iflag = serdev->tc_iflag;
termiosp->c_oflag = serdev->tc_oflag;
termiosp->c_lflag = serdev->tc_lflag;
}
break;
case TCSETS:
{
struct termios *termiosp = (struct termios*)arg;
if (!termiosp)
{
ret = -EINVAL;
break;
}
/* Update the flags we keep at this layer */
serdev->tc_iflag = termiosp->c_iflag;
serdev->tc_oflag = termiosp->c_oflag;
serdev->tc_lflag = termiosp->c_lflag;
}
break;
#endif
default:
ret = -ENOTTY;
break;