- 论坛徽章:
- 0
|
20可用积分
9260的板子,从串口DMA读取80个字节,然后通过tty驱动的tty_insert_flip_string,把数据插入到tty_buffer。
然后在用户层通过read操作读取数据。大多时候能成功读取80个字节。
但是有的时候出现read读出的数据少了2个字节,而且位置固定。假如把80个字节分成前后相等的2段,那么丢失的字节一般是在第15个字节处
read应该是读出tty_buffer这个环形缓冲区,但是怎么丢失的数据呢?
请问这是否是个BUG?什么地方干扰了正常的读入?
int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars,
size_t size)
{
int copied = 0;
do {
int space = tty_buffer_request_room(tty, size - copied);
struct tty_buffer *tb = tty->buf.tail;
/* If there is no space then tb may be NULL */
if(unlikely(space == 0))
break;
memcpy(tb->char_buf_ptr + tb->used, chars, space);
memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space);
tb->used += space;
copied += space;
chars += space;
/* There is a small chance that we need to split the data over
several buffers. If this is the case we must loop */
} while (unlikely(size > copied));
return copied; |
最佳答案
查看完整内容
请问一下,将数据插入到tty_buffer之后,tty_buffer的数据是完整的吧?也就是说数据丢失是发生在tty_buffer到应用层这一步吗?
|