Ooops.. c_speed is now read-only

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4974 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-07-24 17:16:25 +00:00
parent b4e9cec9ca
commit f061660d50
3 changed files with 89 additions and 3 deletions

View File

@ -48,6 +48,10 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#ifdef CONFIG_SERIAL_TERMIOS
# include <termios.h>
#endif
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/serial/serial.h> #include <nuttx/serial/serial.h>
@ -1091,6 +1095,44 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
} }
break; break;
#ifdef CONFIG_SERIAL_TERMIOS
case TCGETS:
{
struct termios *termiosp = (struct termios*)arg;
if (!termiosp)
{
ret = -EINVAL;
break;
}
/* TODO: Other termios fields are not yet returned.
* Note that only cfsetospeed is not necessary because we have
* knowledge that only one speed is supported.
*/
cfsetispeed(termiosp, priv->baud);
}
break;
case TCSETS:
{
struct termios *termiosp = (struct termios*)arg;
if (!termiosp)
{
ret = -EINVAL;
break;
}
/* TODO: Handle other termios settings. */
priv->baud = termiosp->c_speed;
lpc43_setbaud(priv->uartbase, priv->basefreq, priv->baud);
}
break;
#endif
case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
{ {
irqstate_t flags = irqsave(); irqstate_t flags = irqsave();

View File

@ -1248,9 +1248,12 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break; break;
} }
/* TODO: Other termios fields are not yet returned. */ /* TODO: Other termios fields are not yet returned.
* Note that only cfsetospeed is not necessary because we have
* knowledge that only one speed is supported.
*/
termiosp->c_speed = priv->baud; cfsetispeed(termiosp, priv->baud);
} }
break; break;

View File

@ -48,6 +48,10 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#ifdef CONFIG_SERIAL_TERMIOS
# include <termios.h>
#endif
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/serial/serial.h> #include <nuttx/serial/serial.h>
@ -573,7 +577,7 @@ static int up_interrupt(int irq, void *context)
static int up_ioctl(struct file *filep, int cmd, unsigned long arg) static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
{ {
#if 0 /* Reserved for future growth */ #ifdef CONFIG_SERIAL_TERMIOS
struct inode *inode; struct inode *inode;
struct uart_dev_s *dev; struct uart_dev_s *dev;
struct up_dev_s *priv; struct up_dev_s *priv;
@ -591,6 +595,43 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
case xxx: /* Add commands here */ case xxx: /* Add commands here */
break; break;
case TCGETS:
{
struct termios *termiosp = (struct termios*)arg;
if (!termiosp)
{
ret = -EINVAL;
break;
}
/* TODO: Other termios fields are not yet returned.
* Note that only cfsetospeed is not necessary because we have
* knowledge that only one speed is supported.
*/
cfsetispeed(termiosp, priv->baud);
}
break;
case TCSETS:
{
struct termios *termiosp = (struct termios*)arg;
if (!termiosp)
{
ret = -EINVAL;
break;
}
/* TODO: Handle other termios settings. */
priv->baud = termiosp->c_speed;
pic32mx_uartconfigure(priv->uartbase, priv->baud, priv->parity,
priv->bits, priv->stopbits2);
}
break;
default: default:
ret = -ENOTTY; ret = -ENOTTY;
break; break;