标签:
串口配置流程struct termios newtio, oldtio; tcgetattr(fd, &oldtio);
newtio.c_cflag |= CLOCAL | CREAD;
cfsetispeed(&newtio, B115200); cfsetospeed(&newtio, B115200);
newtio.c_cflag &= ~CSIZE; newtio.c_cflag |= CS8
奇校验: newtio.c_cflag |= PARENB; newtio.c_cflag |= PARODD; newtio.c_iflag |= (INPCK | ISRIP); 偶校验: newtio.c_iflag |= (INPCK | ISRIP); newtio.c_cflag |= PARENB; newtio.c_cflag &= ~PARODD; 无校验: newtio.c_cflag &= ~PARENB;
newtio.c_cflag &= ~CSTOPB;
newtio.c_cc[VTIME] = 0; newtio.c_cc[VMIN] = 0;
tcflush函数刷新输入缓存(终端驱动程序已接收到,但用户程序尚未读)或输出缓存(用户程序已经写,但尚未发送) int tcflush(int fileds, int queue); queue数是下列3个常数之一: TCIFLUSH:刷新输入队列 TCOFLUSH:刷新输出队列 TCIOFLUSH:刷新输入输出队列
标签:
原文地址:http://blog.csdn.net/u011641885/article/details/46622669