aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-01-04 21:28:26 -0800
committerpx4dev <px4@purgatory.org>2013-01-04 21:28:26 -0800
commit91ca80e6347feebb1e39b9d16df3f88fb8a68152 (patch)
tree2b416b476c464f2393d3d66af1062f306a616250
parente787fa5bce52e10179cae33df56caa765bfa75e2 (diff)
downloadpx4-firmware-91ca80e6347feebb1e39b9d16df3f88fb8a68152.tar.gz
px4-firmware-91ca80e6347feebb1e39b9d16df3f88fb8a68152.tar.bz2
px4-firmware-91ca80e6347feebb1e39b9d16df3f88fb8a68152.zip
Fix the handling of FIONREAD/FIONWRITE; thanks Tridge.
-rw-r--r--nuttx/drivers/serial/serial.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c
index 24744524f..28c657af0 100644
--- a/nuttx/drivers/serial/serial.c
+++ b/nuttx/drivers/serial/serial.c
@@ -660,9 +660,9 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
int ret = dev->ops->ioctl(filep, cmd, arg);
- /* Append any higher level TTY flags */
+ /* If the low-level handler didn't handle the call, see if we can handle it here */
- if (ret == OK)
+ if (ret == -ENOTTY)
{
switch (cmd)
{
@@ -686,6 +686,9 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
irqrestore(state);
*(int *)arg = count;
+ ret = 0;
+
+ break;
}
case FIONWRITE:
@@ -695,7 +698,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
/* determine the number of bytes free in the buffer */
- if (dev->xmit.head <= dev->xmit.tail)
+ if (dev->xmit.head < dev->xmit.tail)
{
count = dev->xmit.tail - dev->xmit.head - 1;
}
@@ -707,8 +710,19 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
irqrestore(state);
*(int *)arg = count;
+ ret = 0;
+
+ break;
}
+ }
+ }
+ /* Append any higher level TTY flags */
+
+ else if (ret == OK)
+ {
+ switch (cmd)
+ {
#ifdef CONFIG_SERIAL_TERMIOS
case TCGETS:
{