系统接口函数详解:波特率设置、目录切换与文件权限操作
1. 波特率相关函数
在系统编程中,波特率的设置和获取是与串口通信相关的重要操作。以下介绍几个关键的波特率相关函数。
1.1 cfgetospeed()
- 功能 :从
termios
结构体中提取输出波特率。 - 原型 :
#include <termios.h>
speed_t cfgetospeed(const struct termios *termios_p);
- 返回值 :成功时返回代表输出波特率的
speed_t
类型值。 - 错误情况 :无定义错误。
1.2 cfsetispeed()
- 功能 :将
termios
结构体中存储的输入波特率设置为指定值。 - 原型 :
#include <termios.h>
int cfsetispeed(struct termios *termios_p, speed_t spe