aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-01-06 00:50:51 +0100
committerLorenz Meier <lm@inf.ethz.ch>2013-01-06 00:50:51 +0100
commit8eb8909a3c24c6028e4945e4a057d6d2f27f3d04 (patch)
tree5d3cc84f6e8e4114f19172f4db5fdb65a75d0a7c
parent803352e7225ace232ed4a419118956656f13b947 (diff)
parent69cdab9afc0215e26dc5084e21fd61725acb6c84 (diff)
downloadpx4-firmware-8eb8909a3c24c6028e4945e4a057d6d2f27f3d04.tar.gz
px4-firmware-8eb8909a3c24c6028e4945e4a057d6d2f27f3d04.tar.bz2
px4-firmware-8eb8909a3c24c6028e4945e4a057d6d2f27f3d04.zip
Merge branch 'master' of github.com:PX4/Firmware into px4io-adc-integration-battery-msg
-rw-r--r--apps/drivers/px4fmu/fmu.cpp2
-rw-r--r--nuttx/drivers/serial/serial.c39
-rw-r--r--nuttx/include/nuttx/fs/ioctl.h4
3 files changed, 42 insertions, 3 deletions
diff --git a/apps/drivers/px4fmu/fmu.cpp b/apps/drivers/px4fmu/fmu.cpp
index a995f6214..2e3b130a9 100644
--- a/apps/drivers/px4fmu/fmu.cpp
+++ b/apps/drivers/px4fmu/fmu.cpp
@@ -500,7 +500,7 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg)
/* FALLTHROUGH */
case PWM_SERVO_GET(0):
case PWM_SERVO_GET(1): {
- channel = cmd - PWM_SERVO_SET(0);
+ channel = cmd - PWM_SERVO_GET(0);
*(servo_position_t *)arg = up_pwm_servo_get(channel);
break;
}
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)