前言

微秒级别的延时。。。

1.能用

   #include <unistd.h>
 int usleep(useconds_t usec);              微秒级:1/10^-6

 

2.不能使用,每次使用的话,在CAN分析平台接收不到数据;

头文件:#include “sys/time.h”

struct timeval delay;
delay.tv_sec = 0;
delay.tv_usec = 20 * 1000; // 20 ms
select(0, NULL, NULL, NULL, &delay);

3.还没有试。。。

void microseconds_sleep(unsigned long uSec){
    struct timeval tv;
    tv.tv_sec=uSec/1000000;
    tv.tv_usec=uSec%1000000;
    int err;
    do{
        err=select(0,NULL,NULL,NULL,&tv);
    }while(err<0 && errno==EINTR);
}

 

参考

1.https://www.cnblogs.com/tdyizhen1314/p/4140643.html

2.https://www.cnblogs.com/longbiao831/p/4556246.html

3.https://blog.csdn.net/u010487568/article/details/52043136

相关文章:

  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2021-04-19
  • 2021-12-23
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
相关资源
相似解决方案