Programming Linux serial port, ttyS0

北城以北 提交于 2019-12-02 19:52:00

The following line will cause problems:

options.c_cflag &= CSTOPB;

It will reset all other bits of the c_cflag.

If you want to use 1 stop bit, then use:

options.c_cflag &= ~CSTOPB;

If you want to use 2 stop bits, then use:

options.c_cflag |= CSTOPB;

EDIT:

Also the following line cause problems:

fcntl(fd, F_SETFL, 0);

It will reset several important flags.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!