串口的设置,
int set_Parity(int fd,int databits,int stopbits,int parity)
按行读(可能理解错误)
/* Set input parity option */
if (parity != 'n')
options.c_iflag |= INPCK;
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /*Input*/
options.c_oflag &= ~OPOST; /*Output*/
一个一个字读
/* Set input parity option */
if (parity != 'n')
options.c_iflag |= INPCK;
options.c_cflag |= CLOCAL | CREAD;
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /*Input*/
options.c_oflag &= ~OPOST; /*Output*/
options.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
由于网上的串口设置函数都是写好的,找到int set_Parity(int fd,int databits,int stopbits,int parity)
对里面的内容按所需进行添加或修改就能实现一个字符一个字符的读
串口实现一个一个读数据
最新推荐文章于 2024-05-11 13:51:31 发布