mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 03:11:37 +08:00
Baud definitions (B9600 for example) are again encoded; Now supports the BOTHER settings which allows specifying the baud via c_ispeed and c_ospeed termios fields
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4970 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -70,24 +70,21 @@
|
||||
* This function shall return exactly the value in the termios data
|
||||
* structure, without interpretation.
|
||||
*
|
||||
* NON STANDARD BEHAVIOR. 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!
|
||||
* 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.
|
||||
*
|
||||
* Input Parameters:
|
||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||
*
|
||||
* Returned Value:
|
||||
* Baud value in the termios structure (not verified).
|
||||
* Encoded baud value from the termios structure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
speed_t cfgetispeed(const struct termios *termios_p)
|
||||
{
|
||||
DEBUGASSERT(termios_p);
|
||||
return termios_p->c_ispeed;
|
||||
return (termios_p->c_cflag & (CBAUD | CBAUDEX));
|
||||
}
|
||||
|
||||
@@ -70,24 +70,21 @@
|
||||
* This function shall return exactly the value in the termios data
|
||||
* structure, without interpretation.
|
||||
*
|
||||
* NON STANDARD BEHAVIOR. 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!
|
||||
* 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.
|
||||
*
|
||||
* Input Parameters:
|
||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||
*
|
||||
* Returned Value:
|
||||
* Baud value in the termios structure (not verified).
|
||||
* Encoded baud value from the termios structure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
speed_t cfgetospeed(const struct termios *termios_p)
|
||||
{
|
||||
DEBUGASSERT(termios_p);
|
||||
return termios_p->c_ospeed;
|
||||
return (termios_p->c_cflag & (CBAUD | CBAUDEX));
|
||||
}
|
||||
|
||||
@@ -71,26 +71,26 @@
|
||||
* There is no effect on the baud rates set in the hardware until a
|
||||
* subsequent successful call to tcsetattr() on the same termios structure.
|
||||
*
|
||||
* NON STANDARD BEHAVIOR. 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!
|
||||
* 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.
|
||||
*
|
||||
* Input Parameters:
|
||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||
* speed - The new input speed
|
||||
*
|
||||
* Returned Value:
|
||||
* Baud is not checked... OK is always returned.
|
||||
* Baud is not checked... OK is always returned (this is non-standard
|
||||
* behavior).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int cfsetispeed(struct termios *termios_p, speed_t speed)
|
||||
{
|
||||
DEBUGASSERT(termios_p);
|
||||
termios_p->c_ispeed = speed;
|
||||
speed &= (CBAUD | CBAUDEX);
|
||||
termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
|
||||
termios_p->c_cflag |= speed;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -71,26 +71,26 @@
|
||||
* There is no effect on the baud rates set in the hardware until a
|
||||
* subsequent successful call to tcsetattr() on the same termios structure.
|
||||
*
|
||||
* NON STANDARD BEHAVIOR. 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!
|
||||
* 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.
|
||||
*
|
||||
* Input Parameters:
|
||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||
* speed - The new output speed
|
||||
*
|
||||
* Returned Value:
|
||||
* Baud is not checked... OK is always returned.
|
||||
* Baud is not checked... OK is always returned (this is non-standard
|
||||
* behavior).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int cfsetospeed(struct termios *termios_p, speed_t speed)
|
||||
{
|
||||
DEBUGASSERT(termios_p);
|
||||
termios_p->c_ospeed = speed;
|
||||
speed &= (CBAUD | CBAUDEX);
|
||||
termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
|
||||
termios_p->c_cflag |= speed;
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user