Chinaunix首页 | 论坛 | 博客
  • 博客访问: 294926
  • 博文数量: 65
  • 博客积分: 185
  • 博客等级: 入伍新兵
  • 技术积分: 609
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-06 21:41
个人简介

好好学习,天天向上

文章分类

全部博文(65)

文章存档

2022年(3)

2021年(25)

2020年(1)

2019年(3)

2016年(2)

2015年(3)

2014年(14)

2013年(7)

2012年(7)

我的朋友

分类: 嵌入式

2021-06-08 18:20:53

打印的内容会输出到串口

  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include <signal.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <errno.h>
  9. #include <time.h>
  10. #include <sys/reboot.h>
  11. #include <sys/wait.h>
  12. #include <stdarg.h>
  13. #include <string.h>
  14. #include <dirent.h>
  15. #include <sched.h>
  16. #include <time.h>
  17. #include <sys/time.h>
  18. #include <pthread.h>
  19. #include <mntent.h>
  20. #include <inttypes.h>
  21. #include <netdb.h>
  22. #include <setjmp.h>
  23. #include <stddef.h>
  24. #include <sys/poll.h>
  25. #include <sys/ioctl.h>
  26. #include <sys/mman.h>
  27. #include <sys/stat.h>
  28. #include <termios.h>
  29. #include <utime.h>
  30. #include <limits.h>
  31. #include <sys/param.h>
  32. #include <sys/mount.h>
  33. #include <sys/resource.h>

  34. +static void mp4api_dbprint_ttxgz(char* format,...)
  35. +{
  36. + va_list args;
  37. + int fd;
  38. + char string[1000];
  39. + va_start(args,format);
  40. + vsprintf(string,format,args);
  41. + va_end(args);
  42. +
  43. + fd = open("/dev/kmsg",O_RDWR);
  44. + if(fd == -1)
  45. + {
  46. + return;
  47. + }
  48. + write(fd,string,strlen(string)+1);
  49. + close(fd);
  50. +}


  51. + for (temp_j = 0; temp_j <= index; temp_j++) {
  52. + char tmpbuf[256];
  53. + sprintf(tmpbuf, "echo %s > /dev/kmsg", rcrd[temp_j].mount_dir);
  54. + system(tmpbuf); 【第一种方法】
  55. + mp4api_dbprint_ttxgz("[%d]mnt_delta=%ld, raw=%ld, %ld\n", temp_j, rcrd[temp_j].mnt_delta, rcrd[temp_j].timeend.tv_nsec, rcrd[temp_j].timenow.tv_nsec); 【第二种方法】
  56. +
  57. + }

其他:获取精确时间接口
struct record {
        struct timespec  timenow;
        struct timespec  timeend;
        long mnt_delta;
        char mount_dir  [PATH_MAX + 2];
} rcrd[MNT_COUNT];


+               clock_gettime(CLOCK_MONOTONIC, &rcrd[index].timenow);
           xxx
+               clock_gettime(CLOCK_MONOTONIC, &rcrd[index].timeend);
+               rcrd[index].mnt_delta = (rcrd[index].timeend.tv_nsec/(1000*1000) + rcrd[index].timeend.tv_sec*1000) - (rcrd[index].timenow.tv_nsec/(1000*1000) + rcrd[index].timenow.tv_sec*1000);



阅读(501) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~