- 论坛徽章:
- 0
|
8.2设置波特率
对于波特率的设置通常使用cfsetospeed和cfsetispeed函数来完成。获取波特率信息是通过cfgetispeed和cfgetospeed函数来完成的。
cfsetospeed函数
头文件:
#include
#include
函数原型:
int cfsetospeed(struct termios *termptr, speed_t speed);
参数:
struct termios *termptr - 指向termios结构的指针
speed_t speed - 需要设置的输出波特率
返回值:
如果成功返回0,否则返回-1
cfsetispeed函数
头文件:
#include
#include
函数原型:
int cfsetispeed(struct termios *termptr, speed_t speed);
参数:
struct termios *termptr - 指向termios结构的指针
speed_t speed - 需要设置的输入波特率
返回值:
如果成功返回0,否则返回-1
cfgetospeed函数
头文件:
#include
#include
函数原型:
speed_t cfgetospeed(const struct termios *termptr);
参数:
const struct termios - 指向termios结构的指针
返回值:
返回输出波特率
cfgetispeed函数
头文件:
#include
#include
函数原型:
speed_t cfgetispeed(const struct termios *termptr);
参数:
const struct termios *termptr - 指向termios结构的指针
返回值:
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/37319/showart_341577.html |
|