这次UART的试验的主要目的是掌握linux下串口通讯程序设计的基本方法,熟悉终端设备属性的设置,熟悉中断函数的使用。
linux下的串口驱动遵循POSIX标准,即将所有的设备都看成文件,因此使用POSIX标准可以想操作文件一样。就是利用那几个函数open,read,write。
Int(const char *pathname, int oflag);
ssize_t read(int fd, void *buf, size_t len);
ssize_t write(int fd,const void *buf, size_t len);
int tcgetattr(int fd, struct terios *option); //得到串口的终端属性值
int tcsetattr(int fd, int optact, const struct termios *option); //设置串口终端的属性
在设置串口终端属性的时候,有个叫termios结构体的东东,他是表征串口属性的结构体,修改它就是修改串口的属性啦!!!