|
在linux串口接收数据时,发现一整包数据被分割成多个接收,也没有超过缓冲区,想要发送不定长数据,也不设置帧头帧尾。这个问题该如何解决
void *recetive_thread(void *arg)
{
int count;
int bytes_read;
count = 0;
bytes_read = 0;
while(!flag){
bytes_read = read(fd, buf, sizeof(buf));
// bytes_read = read_data(fd, (char *)buf, len);
if (bytes_read > 0){
fprintf(stderr, "Recv %d byte(s) %X\n", bytes_read, *buf);
}
for (int i = 0; i < bytes_read; i++) {
fprintf(stderr, " %02X", (unsigned int)buf);
}
fprintf(stderr, "\n");
}
pthread_exit(NULL);
}
|
|