开发者

Can't detect the first data sent in the serial port

I am using C language and Linux as my programming platform. And I have problems in setting up the serial port(/dev/ttyS0). In my small program, I 开发者_如何学Goset my serial port using tcgetattr and tcsetattr

options.c_cflag |= B115200;
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag &= ~CRTSCTS;
options.c_cflag |= CS8;
options.c_cflag |= (CLOCAL | CREAD);
options.c_iflag &= ~(IXON | IXOFF | IXANY);

My problem is, my app doesn't get the first data that I sent. Did I missed some value?

Thanks.


Is it possible your app IS getting the first thing you send it, but it has junk at the beginning from connection/setup and is not being parsed properly?

You could try flushing the serial out just after init or sending CR/LF just after init to see if that clears things out before you send to your app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜