Skip to content
Snippets Groups Projects
Commit 0f20d458 authored by Gregory Nutt's avatar Gregory Nutt
Browse files

Added FIONREAD and FIONWRITE to CDC/ACM driver. From Lorenz Meier

parent 82b528e0
No related branches found
No related tags found
No related merge requests found
......@@ -5347,3 +5347,6 @@
added TERMIOS input / output processing support for UART and CDCACM
serial ports. Implemented by Mike Smith, Andrew Tridgell and Lorenz
Meier (2013-8-10).
* drivers/usbdev/cdcacm.c: Added FIONREAD and FIONWRITE to CDC/ACM
driver based on serial.c implementation. From Lorenz Meier
(2013-8-10).
......@@ -1937,6 +1937,52 @@ static int cdcuart_ioctl(FAR struct file *filep,int cmd,unsigned long arg)
break;
#endif
case FIONREAD:
{
int count;
irqstate_t state = irqsave();
/* Determine the number of bytes available in the buffer. */
if (serdev->recv.tail <= serdev->recv.head)
{
count = serdev->recv.head - serdev->recv.tail;
}
else
{
count = serdev->recv.size - (serdev->recv.tail - serdev->recv.head);
}
irqrestore(state);
*(int *)arg = count;
ret = 0;
}
break;
case FIONWRITE:
{
int count;
irqstate_t state = irqsave();
/* Determine the number of bytes free in the buffer. */
if (serdev->xmit.head < serdev->xmit.tail)
{
count = serdev->xmit.tail - serdev->xmit.head - 1;
}
else
{
count = serdev->xmit.size - (serdev->xmit.head - serdev->xmit.tail) - 1;
}
irqrestore(state);
*(int *)arg = count;
ret = 0;
}
break;
default:
ret = -ENOTTY;
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment