From 393b2646c236cd126991d863a4e67be623363a4b Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 24 Jul 2012 15:10:21 +0000 Subject: Remove BOTHER git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4972 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/lib/termios/lib_cfgetispeed.c | 14 ++++++++------ nuttx/lib/termios/lib_cfgetospeed.c | 14 ++++++++------ nuttx/lib/termios/lib_cfsetispeed.c | 23 +++++++++++++++-------- nuttx/lib/termios/lib_cfsetospeed.c | 23 +++++++++++++++-------- 4 files changed, 46 insertions(+), 28 deletions(-) (limited to 'nuttx/lib') diff --git a/nuttx/lib/termios/lib_cfgetispeed.c b/nuttx/lib/termios/lib_cfgetispeed.c index d52b83774..ebb52106d 100644 --- a/nuttx/lib/termios/lib_cfgetispeed.c +++ b/nuttx/lib/termios/lib_cfgetispeed.c @@ -65,15 +65,17 @@ * * Descripton: * The cfgetispeed() function shall extract the input baud rate from the - * termios structure to which the termios_p argument points. + * termios structure to which the termiosp argument points. * * This function shall return exactly the value in the termios data * structure, without interpretation. * * NOTE 1: NuttX does not not control input/output baud rates independently * Hense, this function is *identical* to cfgetospeed. - * NOTE 2: If this function returns BOTHER and the more flexible input - * speed can be obtained from the Linux-like c_ispeed field. + * NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud + * encodings of termios.h are the actual baud values themselves. Therefore, + * any baud value may be returned here... not just those enumerated in + * termios.h * * Input Parameters: * termiosp - The termiosp argument is a pointer to a termios structure. @@ -83,8 +85,8 @@ * ****************************************************************************/ -speed_t cfgetispeed(const struct termios *termios_p) +speed_t cfgetispeed(FAR const struct termios *termiosp) { - DEBUGASSERT(termios_p); - return (termios_p->c_cflag & (CBAUD | CBAUDEX)); + DEBUGASSERT(termiosp); + return termiosp->c_speed; } diff --git a/nuttx/lib/termios/lib_cfgetospeed.c b/nuttx/lib/termios/lib_cfgetospeed.c index 904353332..b45c1b721 100644 --- a/nuttx/lib/termios/lib_cfgetospeed.c +++ b/nuttx/lib/termios/lib_cfgetospeed.c @@ -65,15 +65,17 @@ * * Descripton: * The cfgetospeed() function shall extract the output baud rate from the - * termios structure to which the termios_p argument points. + * termios structure to which the termiosp argument points. * * This function shall return exactly the value in the termios data * structure, without interpretation. * * NOTE 1: NuttX does not not control input/output baud rates independently * Hense, this function is *identical* to cfgetispeed. - * NOTE 2: If this function returns BOTHER and the more flexible input - * speed can be obtained from the Linux-like c_ospeed field. + * NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud + * encodings of termios.h are the actual baud values themselves. Therefore, + * any baud value may be returned here... not just those enumerated in + * termios.h * * Input Parameters: * termiosp - The termiosp argument is a pointer to a termios structure. @@ -83,8 +85,8 @@ * ****************************************************************************/ -speed_t cfgetospeed(const struct termios *termios_p) +speed_t cfgetospeed(FAR const struct termios *termiosp) { - DEBUGASSERT(termios_p); - return (termios_p->c_cflag & (CBAUD | CBAUDEX)); + DEBUGASSERT(termiosp); + return termiosp->c_speed; } diff --git a/nuttx/lib/termios/lib_cfsetispeed.c b/nuttx/lib/termios/lib_cfsetispeed.c index 2aefee083..9a4dfaef1 100644 --- a/nuttx/lib/termios/lib_cfsetispeed.c +++ b/nuttx/lib/termios/lib_cfsetispeed.c @@ -66,15 +66,19 @@ * * Descripton: * The cfsetispeed() function sets the input baud rate stored in the - * structure pointed to by termios_p to speed. + * structure pointed to by termiosp to speed. * * There is no effect on the baud rates set in the hardware until a * subsequent successful call to tcsetattr() on the same termios structure. * * NOTE 1: NuttX does not not control input/output baud rates independently * Hense, this function is *identical* to cfsetospeed. - * NOTE 2: If the specia value BOTHER is used, then the actual input baud - * must also be provided in the (non-standard) c_ispeed field. + * NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud + * encodings of termios.h are the actual baud values themselves. Therefore, + * any baud value can be provided as the speed argument here. However, if + * you do so, your code will *NOT* be portable to other environments where + * speed_t is smaller and where the termios.h baud values are encoded! To + * avoid portability issues, use the baud definitions in termios.h! * * Input Parameters: * termiosp - The termiosp argument is a pointer to a termios structure. @@ -86,11 +90,14 @@ * ****************************************************************************/ -int cfsetispeed(struct termios *termios_p, speed_t speed) +int cfsetispeed(FAR struct termios *termiosp, speed_t speed) { - DEBUGASSERT(termios_p); - speed &= (CBAUD | CBAUDEX); - termios_p->c_cflag &= ~(CBAUD | CBAUDEX); - termios_p->c_cflag |= speed; + FAR speed_t *speedp; + + DEBUGASSERT(termiosp); + + speedp = (FAR speed_t *)&termiosp->c_speed; + *speedp = speed; + return OK; } diff --git a/nuttx/lib/termios/lib_cfsetospeed.c b/nuttx/lib/termios/lib_cfsetospeed.c index cbf8e341b..e6d8fa3ad 100644 --- a/nuttx/lib/termios/lib_cfsetospeed.c +++ b/nuttx/lib/termios/lib_cfsetospeed.c @@ -66,15 +66,19 @@ * * Descripton: * The cfsetospeed() function sets the output baud rate stored in the - * structure pointed to by termios_p to speed. + * structure pointed to by termiosp to speed. * * There is no effect on the baud rates set in the hardware until a * subsequent successful call to tcsetattr() on the same termios structure. * * NOTE 1: NuttX does not not control input/output baud rates independently * Hense, this function is *identical* to cfsetispeed. - * NOTE 2: If the specia value BOTHER is used, then the actual input baud - * must also be provided in the (non-standard) c_ospeed field. + * NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud + * encodings of termios.h are the actual baud values themselves. Therefore, + * any baud value can be provided as the speed argument here. However, if + * you do so, your code will *NOT* be portable to other environments where + * speed_t is smaller and where the termios.h baud values are encoded! To + * avoid portability issues, use the baud definitions in termios.h! * * Input Parameters: * termiosp - The termiosp argument is a pointer to a termios structure. @@ -86,11 +90,14 @@ * ****************************************************************************/ -int cfsetospeed(struct termios *termios_p, speed_t speed) +int cfsetospeed(struct termios *termiosp, speed_t speed) { - DEBUGASSERT(termios_p); - speed &= (CBAUD | CBAUDEX); - termios_p->c_cflag &= ~(CBAUD | CBAUDEX); - termios_p->c_cflag |= speed; + FAR speed_t *speedp; + + DEBUGASSERT(termiosp); + + speedp = (FAR speed_t *)&termiosp->c_speed; + *speedp = speed; + return OK; } -- cgit v1.2.3