当前位置: 技术问答>linux和unix
串口接收数据有时会阻塞
来源: 互联网 发布时间:2016-04-09
本文导语: 就是有时传不上去,设置如下 struct termios term2; if( tcgetattr( serial_p->fd2, &term2 ) fd2, TCSANOW, &term2 ); 还有哪些项有影响的 | 1) // Disable software flow control? term2.c_iflag &= ~(IXON | ...
就是有时传不上去,设置如下
struct termios term2;
if( tcgetattr( serial_p->fd2, &term2 ) fd2, TCSANOW, &term2 );
还有哪些项有影响的
struct termios term2;
if( tcgetattr( serial_p->fd2, &term2 ) fd2, TCSANOW, &term2 );
还有哪些项有影响的
|
1) // Disable software flow control?
term2.c_iflag &= ~(IXON | IXOFF | IXANY);
2) change
term2.c_cc[VMIN] = 20;
to
term2.c_cc[VMIN] = 1; // blocking reading until 1 character arrives.
3) change the baudrate higher ?
cfsetispeed( &term2,B115200);
cfsetospeed( &term2,B115200);
term2.c_iflag &= ~(IXON | IXOFF | IXANY);
2) change
term2.c_cc[VMIN] = 20;
to
term2.c_cc[VMIN] = 1; // blocking reading until 1 character arrives.
3) change the baudrate higher ?
cfsetispeed( &term2,B115200);
cfsetospeed( &term2,B115200);