diff options
author | px4dev <px4@purgatory.org> | 2013-01-06 00:40:17 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2013-01-06 00:40:17 -0800 |
commit | 9df2aaf3128a14c49d5f82e624174fc55ff3da0c (patch) | |
tree | b61605113eb7feb56465e9c03bc1f1b406d098fe /nuttx | |
parent | dbb841b0dcad55e36d221fc83ac7bab283438a94 (diff) | |
parent | b3e16b48617ada1b72ba07fab2f9b3ef48cd5058 (diff) | |
download | px4-firmware-9df2aaf3128a14c49d5f82e624174fc55ff3da0c.tar.gz px4-firmware-9df2aaf3128a14c49d5f82e624174fc55ff3da0c.tar.bz2 px4-firmware-9df2aaf3128a14c49d5f82e624174fc55ff3da0c.zip |
Merge branch 'master' into #111-px4io-integrated-mixing
Fix a botched merge for #106 at the same time.
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/drivers/serial/serial.c | 39 | ||||
-rw-r--r-- | nuttx/include/nuttx/fs/ioctl.h | 4 |
2 files changed, 41 insertions, 2 deletions
diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c index c650da5db..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,8 +686,43 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) 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 (dev->xmit.head < dev->xmit.tail) + { + count = dev->xmit.tail - dev->xmit.head - 1; + } + else + { + count = dev->xmit.size - (dev->xmit.head - dev->xmit.tail) - 1; + } + + 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: { diff --git a/nuttx/include/nuttx/fs/ioctl.h b/nuttx/include/nuttx/fs/ioctl.h index 08f62e164..6d60c2ee9 100644 --- a/nuttx/include/nuttx/fs/ioctl.h +++ b/nuttx/include/nuttx/fs/ioctl.h @@ -110,6 +110,10 @@ * OUT: Bytes readable from this fd */ +#define FIONWRITE _FIOC(0x0005) /* IN: Location to return value (int *) + * OUT: Bytes writable to this fd + */ + /* NuttX file system ioctl definitions **************************************/ #define _DIOCVALID(c) (_IOC_TYPE(c)==_DIOCBASE) |