|
|

楼主 |
发表于 2005-7-13 11:22:33
|
显示全部楼层
我用下面这个程序测试了一下:
temp = select (fdCom + 1, &fs_read, NULL, NULL, NULL);
if (temp)
{
gettimeofday(&time_p7,NULL);
len = read(fdCom, str, 13);
gettimeofday(&time_pp7,NULL);
printf("after get 13 bytes command use time:%ld\n",(time_pp7.tv_sec*1000000 + time_pp7.tv_usec)-(time_p7.tv_sec*1000000 + time_p7.tv_usec));
结果是:
after get 13 bytes command use time:37 us
after get 13 bytes command use time:17 us
after get 13 bytes command use time:19 us
after get 13 bytes command use time:18 us
这个就是read函数执行的时间,都是微妙级的。应该不是楼上说的那样吧。
回2楼的:
我是用单片机发送到pc串口的数据,没有回车符。select是可以设置一个timeout的timeval,我这里用NULL代替了,使之成为阻塞读取 |
|