打印的内容会输出到串口
-
#include <stdio.h>
-
#include <unistd.h>
-
#include <stdlib.h>
-
#include <signal.h>
-
#include <sys/types.h>
-
#include <sys/stat.h>
-
#include <fcntl.h>
-
#include <errno.h>
-
#include <time.h>
-
#include <sys/reboot.h>
-
#include <sys/wait.h>
-
#include <stdarg.h>
-
#include <string.h>
-
#include <dirent.h>
-
#include <sched.h>
-
#include <time.h>
-
#include <sys/time.h>
-
#include <pthread.h>
-
#include <mntent.h>
-
#include <inttypes.h>
-
#include <netdb.h>
-
#include <setjmp.h>
-
#include <stddef.h>
-
#include <sys/poll.h>
-
#include <sys/ioctl.h>
-
#include <sys/mman.h>
-
#include <sys/stat.h>
-
#include <termios.h>
-
#include <utime.h>
-
#include <limits.h>
-
#include <sys/param.h>
-
#include <sys/mount.h>
-
#include <sys/resource.h>
-
-
+static void mp4api_dbprint_ttxgz(char* format,...)
-
+{
-
+ va_list args;
-
+ int fd;
-
+ char string[1000];
-
+ va_start(args,format);
-
+ vsprintf(string,format,args);
-
+ va_end(args);
-
+
-
+ fd = open("/dev/kmsg",O_RDWR);
-
+ if(fd == -1)
-
+ {
-
+ return;
-
+ }
-
+ write(fd,string,strlen(string)+1);
-
+ close(fd);
-
+}
-
-
-
+ for (temp_j = 0; temp_j <= index; temp_j++) {
-
+ char tmpbuf[256];
-
+ sprintf(tmpbuf, "echo %s > /dev/kmsg", rcrd[temp_j].mount_dir);
-
+ system(tmpbuf); 【第一种方法】
-
+ 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); 【第二种方法】
-
+
-
+ }
其他:获取精确时间接口
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);
阅读(571) | 评论(0) | 转发(0) |