开发者

Missing characters using read() from unistd.h

We're using the read() method from unistd.h to receive data from the serial port in a Linux environment. To read data from /dev/ttys1 specifically.

Part of the data we're receiving include the characters 0x0A (line feed) and 0x0B (vertical tab), but the library seems to ignore them.

I mean, we use an unsigned char[] to store the data obtained from the port,开发者_运维技巧 and the array contains all the data except those characters.

What do you think it could be wrong?


ttys? Are you sure to put the terminal driver in the correct state to pass out those characters? (See tcgetattr and tcsetattr). Depending on your precise setting, you can play interactively with those settings with the stty program.


How do you know you should be reading 0x0A and 0x0B ? Are you using any mechanism to "debug" the wire to be sure what is the message that you should be reading ? The read() function makes no assumption about the data is reading, so if any bytes are lost, should be in any other part of your program.

Hopes this help you. Thanks, Sergio.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜